Skip to content

Power and Sleep

Juan A. edited this page Oct 15, 2026 · 1 revision

Power and Sleep

The unit is battery powered and spends almost all of its time in deep sleep. Items marked unconfirmed have not been checked on a unit.

Wake sources

Source Pin Meaning
Power-up none first power-on or reset
Timer none next scheduled dispense, or a periodic sync
Front button GPIO6 button press (active low, pull-up)
Bottle eject GPIO13 bottle removed or changed; any change of the pin wakes the unit
Float switch GPIO7 bottle level float
External power GPIO16 external power present (active high, pull-down)

How the pins can wake the chip

  • Timer: deep-sleep timer, sleep time in seconds times 1,000,000.
  • Button: ext1 wake, this pin only, wake when low, RTC pull-up enabled.
  • Bottle eject: ext0 wake. Arm the wake level opposite to the pin's current level, so any change wakes the unit. RTC pulls disabled.
  • Float switch and external power: these two cannot share the ext0/ext1 sources used above (different polarity), so they need the ULP coprocessor or periodic timer polling. A ULP program would sample both pins: wake on any GPIO7 change, and wake when GPIO16 is high.
  • Valve pins: GPIO9/10 are not held in deep sleep, so the board must keep the valve driver off while the chip sleeps (unconfirmed, check at a unit before enabling sleep). Switch the LED outputs off before sleeping.

Awake window

After a wake the unit stays awake long enough to do its work: about 60 s when it is paired and talking to a server, about 300 s while WiFi is being set up. The window is extended while work is pending, and a button press while awake can send the unit back to sleep.

Sleep duration

Sleep until the next scheduled dispense (waking a little early), or for a long interval (days) when nothing is scheduled.

Periodic report

The unit wakes on the timer even with nothing to dispense: it connects to WiFi, syncs the clock over NTP, asks the server for bottle information (remaining and maximum doses), and sends a status report.

Bottle workflow

A bottle change wakes the unit. The bottle moves through states such as new bottle installed, bottle ejected, bottle empty, and installed-but-not-authorized until the server approves it and returns its maximum dose count. A standalone replacement has to supply the maximum dose count itself.

ESPHome feasibility

ESPHome's deep sleep can express the timer, the button (esp32_ext1_wakeup, all-low) and the bottle eject (wakeup_pin with inverted wake level). RTC pull-ups must be enabled in an on_before_sleep lambda. ESPHome has no ULP support, so the float switch and external power need periodic timer polling or a custom component. See ESPHome Replication Plan.

Clone this wiki locally