low power detector module for nRF52 #8778
Open
+104
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello again! This pull request replaces PR #8766. Presented by @Columbo818 and myself, it enables nRF52-based nodes to run the DetectionSensor module in low or even shutdown power modes.
The code takes effect when the following conditions are met:
Its behavior is configurable via the Minimum Sleep Time and the State Broadcast Interval and Minimum Broadcast.
Minimum sleep time (min_wake_secs) determines how long the device stays awake after a detection (and also after the very first boot).
State Broadcast Interval (state_broadcast_secs), determines the interval between wake-ups, if desired.
Setting the interval to unset (0) results in an eternal sleep, which can only be interrupted by the defined GPIO event/state.
If a interval is set, the module runs
cpuDeepSleep(someTime)and latersd_power_mode_set(NRF_POWER_MODE_LOWPWR), followed by a loop polling the pin (this code is new).If the interval is unset, it runs
cpuDeepSleep(forever)and finishes withsd_power_system_off(), essentially a complete shutdown — but using Nordic’s 'sense' feature, it can still be woken by a GPIO.Minimum Broadcast determines the minimal time why has to pass between reported detection events (this is ignored in eteral sleep, see comment below).
Currently I only have a T114 for power-consumption measurements
using a USB meter. The T114 is not known to be very efficient regarding power consumption, but my measurements are promising. All tests were done with the internal pull-up of a GPIO. New measurements with aFluke 77IVdirectly at the battery:15 mA9-10mA5 mA0.02mA<2 mA0.01mASee Haruki’s Meshtastic Experiments for measurements of other devices.
In a nutshell: this commit makes it possible to run a detection sensor node at a remote location
for months or evenfor years on a small battery.There are two small catches in the current implementation:
To distinguish between a wake-up by timeout and those triggered by GPIO i introduced the 'general purpose retention register'
GPREGRET2(as GPREGRET is already taken), which is available in nRF52840 (and nRF52833, nRF52820, all of the nRF53 and nRF54 series), but not in older ones.It shouldn't be a problem, because currently all available nodes with Nordic chips use the nRF52840 and it is very unlikely that Nordic will drop the register in future releases.
As in shutdown the RTC is off we loose track of time. So the 'Minimum Broadcast Interval' of the 'Detection Sensor Module Config' is completely ignored using this power saving mode.
In 'worst case' a misbehaving node, when triggered all the time, will start sending messages every ~12s, if the wake_time is set to low 5s.
This issue shouldn't be major, because using the power save mode we rather aim to transmit rare events.
🤝 Attestations
[✅] I have tested that my proposed changes behave as described.
[✅] I have tested that my proposed changes do not cause any obvious regressions on the following devices:
[✅] Heltec WiFi LoRa 32 (V2)
[✅] Heltec T114
*PR #7882 enables ADC and drives ADC_CTRL to high. because of the the 1kOhm resistor used this adds 2.9mA to power consumption during shutdown on the T114. The effect could be less or more severe on other modules.
PR #8800 is proposed to fix that.
As a hotfix i suggest to use interval sleep with 72h as interval, instead of an eternal sleep.