Espruino Wifi Power Consumption in Deep Sleep at 2mA #4883
Replies: 1 comment
-
Posted at 2020-02-21 by Robin Thr 2020.02.20 Hi @narath, and thank you for your interest in the world of Espruino! Not able to respond with an intuitive answer just yet, but which version of Espruino is currently flashed? It's possible that recent updates have improved on sleep mode. Please post the result of > 'I still get a current draw of 2.3 mA (not the hoped for 0.05 mA)' How is the Wifi device being powered?
Typical 40K Are there any LED's on? What does the switch resistor(s) on 'A0' or input cirucit appear like? Is there a resistor constanly drawing current during the test? A picture might assist us here. Are you able to confirm *ALL* the five listed items beneath 'you must' heading 'Conditions for Deep Sleep' > http://www.espruino.com/Power+Consumption Posted at 2020-02-22 by narath Hi Robin, Thanks for the thoughtful reply. Some responses:
It was being powered by a LiPoly battery (also tested it with USB power breakout - with the same result). Have no external LEDs. Had set the SleepIndicator as per the code, but turning that off did not seem to change anything. The pull down resistor was 10K, I increased this to 100K and it did not change the current draw (and the button still worked). Picture of that attached. I have noticed that there is a small blue LED on the Espruino that is faintly active when powered by battery. Thanks again for your help. Hopefully we can get this down to 0.05mA Attachments: Posted at 2020-02-22 by narath Hey Robin, and yes - all 5 conditions for deep sleep should be met. Posted at 2020-02-22 by Robin Sat 2020.02.22 Thank you @narath for the images as they provide immense confirmation. That said, I'm with you on this one, with your attention to detail following the tutorial, and am a bit baffled myself. Up to date firmware. Check Running on battery, not USB. Check - okay. Do we know the limits on the current measuring meter. Do we have a spec sheet indicating it's limits? e.g. can it measure down beneath milliamp to microamp? Beneath heading 'Debugging Sleep'
Does the Red LED1 illuminate ever? (and it's opposite state)
As it was indicated that all five bullet items, post #4 were confirmed, it is known that power save mode will not work using USB.
This may be the clue, although I am not able to say definitively, as I'm unable to locate specific documentation on the Blue LED and it's indication under battery usage. Nothing jumps out from the programmability side of things: Has the powersave parameter been supplied an argument to test that as an option? The note that followed indicated for ESP8266, so maybe disregard?
Fifth bullet item below 'Features'
I suppose it might be possible that one or more of the output pins are taking on a state, not being explicitly defined. Maybe (a bit redundant though) setting every pin to a known state might provide a bit more peace of mind. Hang in there, I'm sure someone with a bit more knowledge or even been down this path will now have enough information to provide the answer. > EDIT: Checking the schematic, there is a note referring to 'Debug output' on the Blue LED line, also limited by a 100 ohm resistor. > https://github.com/espruino/EspruinoBoard/blob/master/WiFi/pdf/espruino_wifi_sch.pdf
Posted at 2020-02-22 by narath Hi Robin, thanks for sticking with me on this.
It can go from milli down to microamps.
It does when I have the chip "doing stuff", but then does go off after setDeepSleep(1).
Yes - thanks, had noticed this when trying to test sleep while connected through the Web IDE :-)
I see that the blue led is faintly lit on the top surface and another blue led on the undersurface. It does seem that there might be some ongoing power to the 8266 chip. I have tried reflashing the Espruino and then upgrading the Esp8266 chip. Has not changed the power consumption.
Interestingly, that is not an option for me. I get an error when trying to setConfig on wifi:
Thanks - it looks like setDeepSleep might not be appropriately powering down the wifi, or the wifi leds.
Will certainly try this if no further progress. I suspect based on https://www.electro-tech-online.com/articles/achieving-low-power-on-adafruit-trinket.830/ that this would only account for a few micro amps. Thanks again for your help. Hoping we can get to low power sleep at some point. Posted at 2020-02-22 by Robin Sat 2020.02.22
Ahhhh, you wouldn't know this, but I have a bit of a selfish reason to do so. Eventually, I'll get around to battery powering, then this will come in handy!
Had a hunch that the note regarding ESP8266 might reign here, and your trial seems to confirm that. It is still good info though. Unless there are other power users that see this in the short term, there (most likely) is enough here for @gfwilliams to pipe in, but as he is a bit underwater with the Bangle KickStarter, it might take a few days. In any event, he may need to take a break from flashing those ~1000 units, and welcome this as a nice diversion!! p. 73 indicates that the designated mimimum is achievable: So, my hunch is that as we know the LED full on is 33mA and it is currently dimly lit, that it's ~3mA draw is likely the culprit. Posted at 2020-02-23 by maze1980 I see Posted at 2020-02-23 by Robin Sun 2020.02.23 Good catch @maze1980.
It's very likely L7 is processed but not line 10, as the watch would trigger on the rising edge as the button is released. Two seconds elapse, the L10 log message is cued and Espruino immediately executes and enters Deep Sleep long before the (same for L16) log message is processed.
Posted at 2020-02-24 by @gfwilliams Hi! Yes, this could be an issue with the default config of the WiFi pins... Most of the testing would have been done after having turned WiFi on then off. Does:
help you at all? edit: Posted at 2020-02-24 by narath Thanks all. @robin and @maze1980 re console: it did not make a difference when I did not include these messages. @gfwilliams: unfortunately wifi.disconnect() does not change power consumption, and surprisingly does not change the small blue light on the top or bottom. Posted at 2020-02-25 by @gfwilliams Hi - I've just looked into this, and found it was due to the pin state on the boot mode selection pin of the WiFi board. I've now made some changes to the firmware which will be in the 2v05 release (when it happens), or are in 'cutting edge' firmwares downloaded from http://www.espruino.com/binaries/travis/master right now. However, you should be able to get the same effect just by adding Posted at 2020-02-26 by narath Awesome Gordon! Thanks will try it out and let you know. Posted at 2020-02-27 by narath Added this to my code:
And the blue led is now off. The power consumption in sleep unfortunately still seems to be around 2.3 mA Posted at 2020-02-27 by Robin Wed 2020.02.27
YIPEE !!
Didn't expect it to be close to the same, but a bit more of a lesser value. Can we confirm that we don't have an off by 1000 setting on the current measuring device? I've burned myself thinking uA but reading mA and vice-versa Time for a 1% resistor and battery only circuit to prove out the meter will actually read that on the low end? e.g. the meter can actually read below 2uA Posted at 2020-02-27 by @gfwilliams Please can you post up your finished code? It's possible that if you're still calling Posted at 2020-02-28 by narath Okay - I am a believer! Great suggestion by @robin
I used a 100K resistor on the battery circuit and verified getting uA readings. Then tested the espruino with the A13.read() and got the readings seen below with pressing the button (no wifi, just turns on, then sets sleep mode) Attachments: Posted at 2020-02-28 by narath And then when going to sleep got this!! 0.03 mA - in the microAmp category - woot! Attachments: Posted at 2020-02-28 by narath I will be getting an oscilloscope this weekend and will do more testing (esp launching wifi and then disconnecting before sleep), but so far this seems very promising. Thank you both for your help. Posted at 2020-02-28 by Robin Thr 2020.02.27 I like the positive feedback image of the stand in actor, in the lower image, side left. How much additional was needed (bribe) for that shot? So, was it as simple as just powering down the device, thus clearing memory, or was it discovered the meter was upside down? ;-) . . . . or,
a discovered code anomaly, breadboard issue, unknown? Has setting the pinMode to known states been included yet? suggestion from #5 post - and second sentence from last response in #6 post Posted at 2020-02-28 by @gfwilliams Great! Not quite sure I understand though - what did you change that managed to get it to the lower power consumption? Posted at 2020-03-01 by narath Hey guys, unfortunately - Gordon was right - without me clearly knowing what I had changed to fix it - it returned to it's previous power consumption. I did get an oscilloscope, but unfortunately no current probe (I have a shunt resistor, but have no differential probe, so have not tried reading it yet). I did get an analog meter as well, and it gets the same power reading. @gfwilliams, here is my current code on the device:
@robin, seems reasonable to explicitly set the pinmodes: pinMode looks like it can be all of these: analog', 'input', 'input_pullup', 'input_pulldown', 'output', 'opendrain', 'af_output' or 'af_opendrain'. These are the pinModes I expect to set, what would you recommend the others be set to:
The pins I expect to set are: A4, A5, A6, A7, B0, B1, B3, B4, B5, B6, B7, B8, B9, B10, B13, B14 Best, Posted at 2020-03-02 by Robin Sun 2020.03.01 Link from post #7 p.96 indicates pull-up and pull-down of 40K nominal. Although I can't find the post just yet, there was a suggestion to set to a known state. Still searching. The other idea was to use getPinMode() to see what the defaults are at start-up and see if they remain in that state. Regarding the code snippet, ref L9 I've had issues with timers running after cut-n-paste into the Lefthand console side of the WebIDE, under the assumption they were cleared. From another post I use the following to see if any are running:
It might be that constantly pressing the button creates a new timer instance L9, leaving the previous there in memory. Should that be the case, code might be running not allowing the deep sleep state to occur. Just a guess, but worth checking. Posted at 2020-03-03 by @gfwilliams Thanks for sending over the code. The pulldown mode seems reasonable (as long as you don't have a normally-closed switch that's constantly pulling against it!). Also you'd see LED1 (your sleep indicator LED) blinking if you had something waking the WiFi up. Please could you ensure that you've uploaded your code to Either that or add:
There's some info on http://www.espruino.com/Saving But basically: When you save to RAM the code executes right away, and when you then run The issue here is that because it knows that A13 is a pin that's used internally by WiFi, Espruino WiFi may not save the state of that pin for you, so after the initial upload the Posted at 2020-03-03 by maze1980 I see console.log("doing stuff"); in your code, but no serial port connected on the picture. Do you have data waiting at the serial port? Posted at 2020-03-03 by Robin Tue 2020.03.03 Hi @maze1980 I see that post #25 is identical to post #8 Maybe the edit to post #9 from a week ago was missed? While your concern is valid, the additional note indicates deep sleep couldn't occur in that case. I believe that @narath addressed that, but I'll agree there doesn't appear to be a validation from him. Posted at 2020-03-04 by narath @gfwilliams - I was using the following commands to save:
Interestingly, the Blue LED is now showing again, and A13.read() no longer turns it off, nor does wifi.disconnect(); I did download the latest edge firmware and flash it - unfortunately no change - power consumption still 2.3 mA Posted at 2020-03-04 by narath @maze1980 - thanks for pointing that out. I removed all the console lines - and the same power consumption. @robin - I tried checking all the pin modes - they don't seem to change. I used this code:
And got this output:
Posted at 2020-03-04 by Robin Tue 2020.03.03 @narath thank you for the validation and pin mode output as that will assist us all.
Please post Please see Gordon's comment in post #24 before setting all to a known state. Has that suggestion been tried? When done, please post pre and post pin mode output to verify none are changing. I wish I could find the post, (first read by me around three months ago - @allObjects was this one of yours?) that provided some insight as to setting to a known state, and the consequences that might result if not done. (even after chip power on to it's default state)
Also remember a comment, but I think pertained to USART port pins, about not leaving in a certain state as that left the oscillator on. (still searching. . . . ) A S.W.A.G. hunch here, but in 'analog' mode, maybe related to PWM reads, possibly requiring that oscillator? Narath I know you are extremely detailed and vigilant, but is there a chance something else has changed in the setup? Originally, I started to think that the flash process disconnected the battery-resistor test circuit, and this was cured by that (thumbs up image) task. But, as has been indicated, other things changed, such as code line clean-up and technique etc. Posted at 2020-03-06 by narath Hey @robin, you are right, I had been trying a lot of different things at once. Let me try to bring us back to a shared baseline. Here is process.env:
Here is the code - including the state checking:
Here is the console output:
Here is the dump - after reset, upload, save and then reset:
And here is the power consumption: 2.4 mA again. I'd certainly welcome any ideas. Posted at 2020-03-06 by narath Okay - so I tried a different tack. I had it do what I ultimately wanted it to do - wake on button, turn on wifi, send a GET request, turn off wifi and go to sleep. I had hoped to send the battery voltage with the GET request, but it looks like E.getBattery is only for the Pico. Is there a way to read the battery voltage level? I saved the code given below, and checked the power consumption - and low and behold - it appears to sleep at 0.64 mA ! I am using a LiPo 3.7V 500mAh battery. I have it wired to the + and - terminal. Should I wire it to the 3.3V instead and skip the power regulator to possibly save power (hopefully without nuking the chip). I'm also ordering more Espruino's from Adafruit, as this is getting very exciting! Thanks,
Posted at 2020-03-06 by @allObjects Nope, do NOT connect battery to 3.3V terminal... if the battery is really full - up to 4.2V - it puts too much stress on the mc, which has a limit of 3.6... neither STM nor ESP may survive... A good, low drop, low loss voltage regulator is the answer. Posted at 2020-03-06 by Robin Thr 2020.03.05
I'll defer to @gfwilliams for the designer recommendation. LiPo and Lion have a tendancy to allow for a higher voltage when fully charged. I don't know if All the external parts have the same non 3V3 rating tolerance, protected by the regulator. IMO I wouldn't risk a $40 board without a definitive response from the designer, but what about a Buck 3V7 to 3V3 down converter? (I've orderd parts to make some test circuit current comparisons but the Corvid-19 has most of that delayed right now) > '3.3 is a 3.3v output from the on-board Voltage regulator' The pin adjacent to B3 is an output. Note 'On-board 3.3v 250mA voltage regulator, accepts voltages from 3.5v to 5v' at: The schematic implies connections at VDD are 3V3
Your 0.64 vs 0.05
Maybe time for that (0.05) test to be re-visited? or at least what the setup was then An *Interesting* read - regulator power consumption: Post #15 thru post #17 answers the statement on floating pins I posed earlier in post #29 but for nRF devices and not STM devices, so not sure it would apply here with WiFi. Posted at 2020-03-06 by @gfwilliams Ok, great - glad you're getting there! 0.64mA is still more than I'd expect though...
As others have said, please don't try that :) The Espruino WiFi actually has a pretty decent voltage regulator on board - the quiescent current (that drawn by the regulator) is something in the range of 0.002mA so there are definitely other issues :)
Not directly, since the battery voltage is never connected to the MCU. You can use If you want to get a proper reading you'd need to set up a potential divider (maybe 2x 100k resistors) to halve the battery voltage, then put that into an ADC pin (with a small capacitor between it and GND to help keep the voltage constant) and read the value.
As I mentioned above, I actually ran the code and got this figure with up to date firmwares just a few days ago. Posted at 2020-03-10 by narath Thanks @robin and @gfwilliams. I will stay away from connecting to 3.3V I will try E.getAnalogVRef() and if not enough warning will setup the divided resistors. Best, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2020-02-21 by narath
Really enjoying getting to know my Espruino Wifi. I'm trying to build a test simple device that wakes on a button press and sends a signal. I want it to be battery powered so was super excited about the very low power consumption in deep sleep mode and easy wake on interrupt.
When I set this up to wake on a signal to A0, and then go back to sleep I still get a current draw of 2.3 mA (not the hoped for 0.05 mA). Is there something that I need to instruct to power down (like explicitly telling the wifi to power down) to get to the low power consumption?
Thanks in advance,
Narath
Beta Was this translation helpful? Give feedback.
All reactions