Sleep is entering low power consumption mode by shutting almost all functions. It makes available working with batteries for long time by continueing sleep and wake up.
Some device like obniz Board 1Y has a sleep function. Depending on usage, It will keep over 1 year. It makes you put obniz Board 1Y where no power supply.
Below is example usages
- Watering a plant in intervals.
- Monitoring a temperature in intervals.
- To handle nexpected events like humandetect or exceeding temperature.
Integrating with Serverless Event is useful to use sleep function.
Entering Sleep
Wi-Fi and Displays and other almost all functions are no longer available while sleep. It will wake up from sleep when specified trigger occurred.
You can choose on of below triggers.
- Past time(second) 1sec to 64800sec(18 hours)
- Past time(minutes) 1min to 64800min(45 days)
- edge up detection of io0(Level is TTL. But it depend on VCC level)
- edge down detection of io0(Level is TTL. But it depend on VCC level)
When waking up from sleep, a device start same as first power up. A device will wake up by cutting and supplying a power again regardless sleep mode.
obniz.sleepSeconds() and obniz.sleepMinute() start sleep until time past. obniz.sleep() accept date object to determine next wakeup time. It is useful to calculate time.
// Javascript Example
obniz.sleepSeconds(60); //60 sec = 1min
obniz.sleepMinute(60*24); // one day
let dt = new Date();
dt.setHours(dt.getHours()+1,0,0,0); // Next 00 minites.
obniz.sleep(dt);
obniz.sleepIoTrigger() start sleep until io0 changed.
// Javascript Example
obniz.sleepIoTrigger(true); // wake up when rising edge on io0
How long does it work
It depends on average power consumption on each device. Power consumption while sleep is 20uA-40uA(VCC=5V) for obniz Board 1Y.
You need to calculate with standard power consumption (120mA avg).
// Javascript Example
Simple method is below.
S: average waking up time in minutes in one hour.
Q: Capacity of a battery(mA)
(Available Time(h)) = Q/(S/60*120 + (60-s)/60*0.04)
(Example)
AAA Battery(2000mA)x3
2 minutes in one day(0.083minutes/hour) will work over 1 year.