If it hasn't been CLOUD_MIN_MS milliseconds since connected to the cloud, go into PRE SLEEP state.In PUBLISH state, the sensor is read and the value published to the Particle cloud.
While this example is simple enough you could do it with nested if statements, it's a good habit to get into using finite state machine design for your user firmware. cloudMinTime set to 0 (no waiting for firmware updates)Īll of the examples use a finite state machine.On Gen 3 devices, this example uses stop mode sleep with cellular off, because Gen 3 devices cannot wake from hibernate mode by time. In this mode, the power usage stays completely constant as the modem is turned off and the MCU is in deep sleep. On Gen 2 devices, the power usage is around 103 ♚ with this example (tested with an E Series E402 and Device OS 1.5.0). This is because connecting to cellular uses a significant amount of power, more than is saved by turning off the modem completely.Īlso you must not use hibernate with sleep periods of less than 10 minutes or your SIM could be blocked your mobile carrier for aggressive reconnection. For sleep periods less than 15 minutes, you'll use less power by using stop mode sleep (pin + time) with SLEEP_NETWORK_STANDBY. The hibernate mode uses the lowest power, however there is a trade-off. You can download the files associated with this app note as a zip file. Stay awake for firmware updates (optional).Hour sleep, uses hibernate mode ( SLEEP_MODE_DEEP).Sleep on multiple connection failure to preserve battery.Checking that the battery has sufficient capacity to connect.AN029 Wake publish sleep firmware example