-
Notifications
You must be signed in to change notification settings - Fork 50
Sleep on pin 32 #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sleep on pin 32 #64
Conversation
bringing fork up to date(?)
* Added uint32_t setting called deepSleepAlarmSecs. When set to 0, nothing changes, but when > 0, it will set an alarm that many seconds into the future whewn entering Deep Sleep. * Added provision to menuPower for setting deepSleepAlarmSecs * When waking up, if deepSleepAlarmSecs != 0 and useGPIO32ForStopLogging = true, will set stopLoggingSeen based on PIN_STOP_LOGGING rather than assume false.
The goToSleep function is now called with an argument msToSleep so it can be used either when sleeping between samples, or for a potentially much longer sleep when triggered on an external pin.
|
Hi Ryan (@ryanneve ), |
| settings.enablePwrLedDuringSleep ^= 1; | ||
| Serial.println(F("Please enter RTC wakeup time (sec) when put in deep sleep. 0=disable:")); | ||
| uint32_t tempRTCwakeUp = (uint32_t)getDouble(menuTimeout); | ||
| if ( tempRTCwakeUp == 0 or tempRTCwakeUp >= 60 ) // This value should be defined elsewhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the minimum sleep time 60 seconds is somewhat arbitrary, and should perhaps be something like 2 seconds to match the minimum for sampling. I was also wondering if this value should be set elsewhere.
|
Hi Ryan, |
|
@PaulZC, It seems to be working and I don't think I need the RTC code anymore as this should add the functionality I need. This change should allow the OLA to have two different sample rates. The fast rate it has now, and a slow rate when pin32 is low. This change may have broader uses. Thinking of another issue, it may not be hard to go to the slow rate when the IMU meets certain criteria (no motion or a certain orientation). All you need to do is call sleepUntilWoken(). I wonder if rather than settings.usBetweenReadings and settings.deepSleepAlarmSecs it should be fastSampleRate_us/shortSleep() and slowSampleRate_s/longSleep() or something like that? |
The new version of v1.9 BETA contains partially-tested code: - Corrected an issue when using multiple MS8607's: #62 - Add a feature to use the TX and RX pins as a duplicate Terminal - Add serial log timestamps with a token (as suggested by @DennisMelamed in PR #70 and Issue #63) - Add "sleep on pin" functionality based @ryanneve's PR #64 and Issue #46 - Add "wake at specified times" functionality based on Issue #46
|
Hi Ryan (@ryanneve ), |
This change related to issue #60 allows the OLA to optionally go to sleep when pin32 is pulled low then wake up later and resume sampling. Currently pin32 just shuts down the OLA. I've added a single setting for number of seconds to sleep when pin32 is pulled low. If set to 0, the current functionality is retained. I've also added a way to edit this setting in the menus.
I've done a little testing and it seems to work as intended, even if pin32 is held low through the entire sleep period in which case it takes a sample and goes back to sleep.
As for practical applications, pin32 can now be used to signal when conditions are right for logging (day time, high tide, rainfall, etc.) allowing the RTA to spend much of the rest of the time asleep.