OPEnSLab-OSU / Loom

Arduino library for Internet of Things Rapid Prototyping in environmental sensing
GNU General Public License v3.0
26 stars 3 forks source link

Multiplexer Deactivates Itself After Sleep #76

Closed prototypicalpro closed 4 years ago

prototypicalpro commented 4 years ago

Describe the bug When using the I2C multiplexer and LoomManager::sleep, the multiplexer will mark itself deactivated by setting Loom_Module::active to false during Loom_Multiplexer::power_up: https://github.com/OPEnSLab-OSU/Loom/blob/fc36a8df101e18fceca88510ed7e9ceb4cd5ef64/src/Multiplexer.cpp#L402-L410 causing subsequent measure calls to ignore the module: https://github.com/OPEnSLab-OSU/Loom/blob/fc36a8df101e18fceca88510ed7e9ceb4cd5ef64/src/Manager.cpp#L197-L200 The module will then remain deactivated even after calling LoomManager::power_up after the board has fully powered on.

While it makes sense to me that Loom_Multiplexer::power_up would deactivate the module because it cannot communicate with the multiplexer before the Hypnos is powered on, it is not clear to me why subsequent calls to Loom_Multiplexer::power_up do not reactivate the module. More investigation is needed.

Hardware in Use Tested on the SitkaNet setup, but should reproduce on any Feather/Hypnos/Multiplexer project (so long as the multiplexer power controlled by the Hypnos).

To Reproduce Any project using Loom::sleep with the multiplexer should be able to reproduce this issue. Simply load any sketch using sleep and the multiplexer, allow the board to sleep/wakeup once, and the board will no longer measure any multiplexer sensors.

prototypicalpro commented 4 years ago

https://github.com/OPEnSLab-OSU/Loom/commit/15999f7fc2f10b210bf8d436a68b567a2274b87e temporarily fixes the issue.

prototypicalpro commented 4 years ago

The solution proposed to this is to move all automatic re-initialization code in LoomManager::sleep() to the sketch. This will also resolve issues with the ordering of DS3231 power up and toggling of hypnos pins. More documentation on proper powering up routines will be needed after this change (https://github.com/OPEnSLab-OSU/Loom/issues/79).