sparkfun / OpenLog_Artemis

The OpenLog Artemis is an open source datalogger the comes preprogrammed to automatically log IMU, GPS, serial data, and various pressure, humidity, and distance sensors. All without writing a single line of code!
https://www.sparkfun.com/products/15846
Other
88 stars 47 forks source link

Sleep on pin 32 #64

Closed ryanneve closed 3 years ago

ryanneve commented 3 years ago

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 commented 3 years ago

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

PaulZC commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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