On devices equipped with obniz Board 1Y or OS7 (and later), you can reduce power consumption by putting the device into a sleep state. This enables battery-powered, cable-free operation.
For more details on sleep behavior for each OS, please refer to the OS Sleep Page.

How Sleep Mode Works
When the device enters sleep mode, all functions are suspended to achieve ultra-low power consumption (see the bottom of this page for actual current consumption). This includes the deactivation of Wi-Fi and the onboard display.
The device will automatically wake up and restart based on a specific "Trigger" defined when entering sleep mode. You can specify the following triggers:
- Elapsed Time (Seconds): From 1 second up to 64,800 seconds (18 hours).
- Elapsed Time (Minutes): From 1 minute up to 64,800 minutes (45 days).
- IO0 Rising Edge (obniz Board 1Y only): Wakes up when the voltage on pin
io0rises. (Threshold is TTL level, depending on the supplied voltage). - IO0 Falling Edge (obniz Board 1Y only): Wakes up when the voltage on pin
io0falls. (Threshold is TTL level, depending on the supplied voltage).
When the sleep period ends or a trigger is activated, the device reboots and reconnects to the cloud, just as if it were power-cycled. If you manually turn the power off and on during sleep, the device will wake up and start immediately.
obniz.sleepSeconds(number)
obniz.sleepMinute(number)
You can trigger a timed sleep using obniz.sleepSeconds() or obniz.sleepMinute(). Additionally, obniz.sleep() allows you to use a Date object to specify a precise wakeup time.
// Javascript Example
obniz.sleepSeconds(60); // Sleep for 60 seconds (1 min)
obniz.sleepMinute(60 * 24); // Sleep for one day
const dt = new Date();
dt.setHours(dt.getHours() + 1, 0, 0, 0); // Wake up at the start of the next hour
obniz.sleep(dt);
obniz.sleepIoTrigger(boolean)
For the obniz Board 1Y, in addition to time-based triggers, you can use obniz.sleepIoTrigger() to remain in sleep mode until a change is detected on pin io0.
// Javascript Example
obniz.sleepIoTrigger(true); // Wake up on a rising edge on io0
Battery Life Estimation (For obniz Board 1Y)
Battery life varies depending on the device; please refer to the specific documentation for your hardware. For example, the current consumption of the obniz Board 1Y during sleep is approximately 20uA - 40uA (at 5V). You can estimate the total runtime based on the average active power consumption (approx. 120mA) as follows:
// Simple calculation (ignoring battery self-discharge and voltage drop):
// S: Average active time per hour (minutes)
// Q: Battery capacity (mAh)
// Formula:
// Runtime (hours) = Q / ( (S/60 * 120) + ((60-S)/60 * 0.04) )
/* Example:
Using 3x AA Alkaline batteries (approx. 2000mAh):
If the device wakes up once a day for 2 minutes and sleeps for the rest of the time,
it will last for approximately 1 year.
*/