Server.sleepfor() duration and current draw

I have measured the time spent in deep sleep after calling server.sleepfor() [… as an aside, why is this a server method and not an imp method?]. Here are my results:

sleepfor(duration)   Actual

10                          14

8                            12

6                            10

4                            8

2                            6

0                            4

And yes, 0.0 did work. A negative value bricked my imp though, until I power cycled it. There appears to be a +4 second offset applied to the sleepfor duration (for positive values only).

I have an April board powered from an external 3.5V power supply. I am measuring about 2 mA during deep sleep. This is considerably more than the 6 uA that the IMP should be drawing, even after adding in the operating current for the TPS62172 and efficiency losses. Any ideas?


The reason it’s called “server.sleepfor” is because before going to sleep, it tells the server how long it’ll be sleeping for (so the server knows when it should expect it to come back, at the latest). This allows the server to be cleverer about buffering messages and to be able to tell clients when buffered messages should be delivered to the imp.


You’re right that the actual duration is not exact; the intention is generally to not use this function for short sleeps right now, because the overhead of booting is currently significant (this will be much reduced in the future when a “wake” does not need to bring the wifi up, allowing for shallow wakes where squirrel code can run and examine the device state before deciding whether wifi is needed). This will improve in the future.

As for power, that’s interesting. We’ve looked at power often and never seen anything of that magnitude. I just tried here - bare april, powered by 5v, Agilent 34410A in-line, and saw 25uA when sleeping - which matches fairly well with the typ 17, max 25uA TPS62172 consumption and imp power consumption.

How are you measuring the current, and is there anything else connected to the imp pins?

Just looked a bit deeper here. I can replicate the higher current draw at 3.5v, and even higher (2.2mA) at 3.6v, but at 3.7v it drops to the twenty-something microamp range.


This appears to be due to the TPS62172 staying in PWM mode (and is borne out by looking at the LX node of the 62172 as the voltage is changed), see the note on the bottom of page 15 of the TPS62172 datasheet:

"When VIN decreases to typically 15% above VOUT, the TPS6217X won’t enter Power Save Mode, regardless of
the load current. The device maintains output regulation in PWM mode. "

The TPS62172 was mainly picked for April due to its wide input range. Previous boards we made internally (Angie) used the TPS62237, which is smaller and cheaper, but has a max 6v input. The 62237, experimentally at least (the datasheet is quiet on the exact low voltage behavior) behaves at 3.5v, but goes up to 1mA at 3.4v.

In summary - your mileage may vary depending on the PSU chip you pick. If you’re looking for the lowest power buck to run from a Li-Ion pack across the full Li-Ion range, you may want to check out other devices. We’ll see what we can find and put some details on the wiki when we have something that maintains good low current for ~3.4-4.2v input.

Thanks for the info. I can confirm that in the area of 3.7V the current draw drops to about 25 uA. I should have read the TI data sheet more carefully.

And I like the use of the FET for the power input reverse-polarity protection. Very clever.

…though, that’s probably not the best FET for that use (Vgs is max +/-12v, but the buck is ~16v). Should really have been a DMG2307 in there which has a 20v max Vgs.