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:
- ECO Mode (Default): normal deep sleep (~100µA); physical button press to wake. Target battery life: 7+ months (700mAh battery).
- 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
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:
Expected Behavior:
Behavior notes:
Implementation Approach (Arduino framework):
setup(): ifesp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_TIMER, run the micro-wakeup; otherwise boot normallyRTC_DATA_ATTRmemory — survives deep sleep without wearing NVSesp32_sleep()teardown chain (after the energy-menu timer disable); explicitly disarmed when the setting is Offwow_interval, default Off)