Skip to content

Conversation

@ryanneve
Copy link
Contributor

@ryanneve ryanneve commented Jan 4, 2021

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.

PaulZC and others added 5 commits December 6, 2020 10:00
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.
@PaulZC
Copy link
Collaborator

PaulZC commented Jan 5, 2021

Hi Ryan (@ryanneve ),
Thank you for submitting this PR. We'll need to test it before we can merge it into the master branch. Can you please re-target the PR at the release_candidate branch so we can test it off-line? Instructions are here:
https://github.com/sparkfun/OpenLog_Artemis/blob/master/CONTRIBUTING.md
Many thanks!
Paul

@ryanneve ryanneve changed the base branch from master to release_candidate January 5, 2021 19:50
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.
Copy link
Contributor Author

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.

@PaulZC
Copy link
Collaborator

PaulZC commented Jan 7, 2021

Hi Ryan,
This is starting to look nice - thank you. Are you still working on this - or do you think it is ready for testing? Maybe you need to add the RTC code first?
All the best,
Paul

@ryanneve
Copy link
Contributor Author

ryanneve commented Jan 7, 2021

@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?

PaulZC added a commit that referenced this pull request Jan 29, 2021
These changes are based on code by @ryanneve in PR #64 and suggestions in Issue #46
PaulZC added a commit that referenced this pull request Jan 29, 2021
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
@PaulZC
Copy link
Collaborator

PaulZC commented Jan 29, 2021

Hi Ryan (@ryanneve ),
Many thanks for submitting this PR - and sincere apologies for the long delay in coming back to you.
I wasn't able to merge your code changes as-is but your code did make me think about if it would be possible to give you what you need and the "wake at specified times" functionality @alino93 asked for in #46. I think I've come pretty close!
For you, you can now use Pin 11 to switch into a slow logging mode. Have a look at the new entries in the Terminal Logging menu. You can set if a high or a low on Pin 11 engages slow logging. And can set the slow logging interval.
The code changes are here.
The v1.9 BETA binary includes the changes too. I'd be grateful if you can give it a try and let me know if you find any gremlins!
Very best wishes,
Paul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants