feat: optional Wake-on-Weight mode via RTC timer polling - #180
Open
Sofronio wants to merge 4 commits into
Open
Conversation
After deep sleep, an RTC timer wakes the scale on a user-selectable interval (0.5/1/2 s or off, Power menu 'Wake:' row, NVS wow_interval); the micro-wakeup powers the load-cell rail, reads one raw ADS1232 conversion at 10 SPS, and either re-enters deep sleep (|raw - baseline| under a 50 g-equivalent threshold stored in RTC_DATA_ATTR at sleep entry) or falls through to a full normal boot. Disabled on low battery, inert until calibrated; charging allowed; button/charging EXT1 wake unchanged. Co-Authored-By: Claude <[email protected]>
Changes validated on V8.1 hardware (two units): - rail settle 100 ms and a 900 ms read window: the first ADS1232 DRDY after rail power arrives ~415 ms at 10 SPS; the original 250 ms window never caught a sample - run the micro-wake at the 20 MHz minimum and restore the boot frequency (240 MHz) before continuing into a full boot on weight detection (getCpuFrequencyMhz already returns MHz) - threshold uses fabsf of the calibration factor (signed factors otherwise collapsed to the 500-count floor) - arm the RTC timer only after baseline capture, and gate the timer disable on having enabled it this boot (avoids ESP-IDF 'Incorrect wakeup source' noise on ordinary sleeps) - menu setting back to a cycling row: Off / 2s / 3s / 4s; interval is snapshotted into RTC memory at sleep entry Co-Authored-By: Claude <[email protected]>
Row cycles o/2/3/4 (off / interval seconds); the press confirmation message keeps the unit (Off/2s/3s/4s). Co-Authored-By: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements the optional Wake-on-Weight mode from #173: after deep sleep, an
RTC timer wakes the scale for a brief load-cell check and either goes back
to sleep (nothing placed) or continues into a full normal boot (weight
placed).
Design (as validated on hardware)
WakeOnWeight o/2/3/4(o = off; 2/3/4 =detection interval in seconds), NVS key
wow_interval, defaults to off.coexists with the existing EXT1 button/charging wake), downclocks to the
20 MHz minimum, raises the main switched rail (
PWR_CTRL), reads oneraw ADS1232 conversion at 10 SPS, and compares |raw − baseline| against a
50 g-equivalent threshold stored in
RTC_DATA_ATTRat sleep entry.power arrives ~415 ms, so a tick costs ~850 ms end to end (≈300 ms boot +
100 ms settle + ~415 ms read). 0.5/1 s intervals are physically wasteful;
the menu therefore offers 2/3/4 s.
calibration factors handled via
fabsf), charging allowed, ticks nevertouch NVS or read the battery, and on weight detection the boot frequency
is restored before continuing the normal
setup()flow (boot tare zeroeswhatever was placed).
include/wake_on_weight.hholds the micro-wake, baseline captureand timer arming;
power.h'sesp32_sleep()gained two hooks. First useof
RTC_DATA_ATTRin the repo.tools/test_wake_on_weight_contract.pypins the sourcestructure; docs in
docs/wake-on-weight.md(incl. estimated power budgetpending ammeter measurement).
Testing
esp32s3,esp32s3-grinder,esp32s3-energy-menuall green.contracts) all green.
well under threshold; placing a weight wakes the scale into a normal full
boot; button wake coexists with ticks; no crashes.