Skip to content

Conversation

@rbomze
Copy link

@rbomze rbomze commented Nov 27, 2025

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:

  • The device is nRF52840-based
  • The node role is Sensor
  • Power-saving mode is enabled
  • And, of course, the DetectionSensor module is enabled with a valid GPIO pin

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 later sd_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 with sd_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 a Fluke 77IV directly at the battery:

  • In “ON” state: 15 mA 9-10mA
  • In the low-power loop: 5 mA 0.02mA
  • In shutdown state with sensing pin: <2 mA 0.01mA
  • In shutdown state with sensing pin (with, buggy* ADC monitoring): 2.91mA

See 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 even for 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.

Using low power polling during intervaled wake ups (state_broadcast_secs set)
or Nordics GPIO sense feature in shutdown mode if state_broadcast_secs unset (=0).
Introduces GPREGRET2 to distinguish between wakeups by timeout or event.
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.

1 participant