Skip to content

[Feature Request] Optional "Wake-on-Weight" mode via low-frequency RTC timer polling #173

Description

@Sofronio

I want to add an optional, user-configurable "Wake-on-Weight" mode to the smart scale, allowing the device to automatically power up when an object is placed on it. Implemented entirely via software as a user-configurable setting; no hardware PCB modifications.

Hardware Context:

  • MCU: ESP32-S3 (dual-core, supports RTC IO and dynamic clock scaling)
  • External ADC: ADS1232, running at 10 SPS (one conversion ≈ 100 ms) — this bounds the minimum micro-wakeup duration
  • Power Control: GPIO 3 connected to a Load Switch controlling VCC of OLED and ADS1232 (main switched rail)
  • Pin Mapping: DOUT = GPIO 11, SCLK = GPIO 12, PWDN = GPIO 13, Load Switch = GPIO 3
  • Normal operating CPU frequency: 80 MHz (restore target after wake)
  • Current Deep Sleep Baseline: ~100µA (with Load Switch OFF and RTC pins latched)

Expected Behavior:

  1. ECO Mode (Default): normal deep sleep (~100µA); physical button press to wake. Target battery life: 7+ months (700mAh battery).
  2. Wake-on-Weight Mode (Optional): the device wakes via RTC timer on a user-selectable interval (0.5 s / 1 s / 2 s, or Off), performs a ~130 ms micro-wakeup burst (power the load-cell rail, PDWN reset pulse, wait for the first conversion at 10 SPS, read one raw 24-bit sample), and compares |sample − stored baseline| against a 50 g equivalent threshold (converted to raw counts at sleep time). Below threshold → immediately re-enter deep sleep and re-arm the timer. Above → continue the full normal boot at 80 MHz (OLED, BLE). Estimated average current ~3.1 mA @ 0.5 s, ~1.7 mA @ 1 s, ~0.9 mA @ 2 s (≈ 9 / 18 / 33 days standby on 700mAh, to be confirmed by hardware measurement).

Behavior notes:

  • Works while charging (charging still wakes the device on plug-in as before)
  • Disabled when the battery is low — the micro-wakeup never reads battery level; arming is suppressed once low battery is confirmed
  • Feature is inert until the scale is calibrated (threshold needs the calibration factor)

Implementation Approach (Arduino framework):

  • Boot-stage interceptor in setup(): if esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_TIMER, run the micro-wakeup; otherwise boot normally
  • State (baseline raw value, threshold in raw counts, interval, armed flag) in RTC_DATA_ATTR memory — survives deep sleep without wearing NVS
  • Timer armed in the esp32_sleep() teardown chain (after the energy-menu timer disable); explicitly disarmed when the setting is Off
  • User setting in the OLED Power menu ("Wake: Off / 0.5s / 1s / 2s" cycling row, NVS key wow_interval, default Off)
  • Button wake and charging wake paths unchanged

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions