Real time + Low Power (10mW) ESP8266 Expirments - Page 1
Forum section: electronics / projects

author: LeonV
author_rank: Contributor
timestamp: May 18, 2017, 10:11:59 am
content: Hi All,In case anyone is interested, i have been playing around with Light Sleep modes on the ESP8266 and recently been getting some good results.I currently have the ESP8266 waking every ~5 seconds while maintaining WiFi connectivity when asleep so it can send data immediately when an interrupt is triggered.It will also respond to TCP requests! (While awake)All while averaging 10mW.My intention was to make a real time sensor network for things link alarming when someone comes up my driveway while being battery powered and possibly stay running for ever with a small solar cell.I i think my code is at a point where this is becoming a reality.At the current 10mW, i should be able to get ~50 days up-time from a NCR18650I'm not sure if there are any other projects out there that do this while maintaining WiFi so you can transmit something very quickly. Has anyone seen any ?Code uses the NON-OS SDKGit repository here:https://github.com/leon-v/ESP8266-NONOS-SDK-2.0-Low-Power-WiFi-NodeIts just a super rough build log...1 - Yellow Trace: The current between the NCR18650 and the 3.3V switching regulator.2 - Green Trace: The battery voltage.3 - Blue Trace: The interrupt timing capacitor (accidentally left in A instead of V)M1 Pink Trace: Math 1 is 1 * 2. so is the wattage drawn from the battery.Comments & recommendations welcome! They all help!

author: Dave_PT
author_rank: Frequent Contributor
timestamp: May 18, 2017, 11:52:39 am
content: Hello.I'm doing something very similar, but my sensor is mobile and I need to use DHCP.To save more energy I control the ESP with another MCU (which I really need to have) and just turn ESP on when I need to send something.The problem is the time to get IP. Sometimes it takes more than 10 seconds to get IP ...Some advice?NOTE: I have been using nodemcu and also the Espressif SDK and so far I do not see any advantages (in the space of time I am using) so nodemcu has a faster development ...

author: LeonV
author_rank: Contributor
timestamp: May 19, 2017, 12:46:41 am
content: That sounds like it might be more of an issue with the way the ESP8266 is requesting an IP, and how your router / DCHP server is responding.Its likely to be the ESP8266 trying to re-use its previous IP, but the DHCP server not allowing it for various reasons. Which after time will cause the ESP8266 to try and lease a new IP instead. Or visa versa.Install Wireshark on a PC on the same network and monitor the network traffic for DHCP packets.Keep in mind that you will only be seeing the broadcast packets, not all of them.This will likely tell you what is going on.I did think it was quite impressive that the ESP8266 can re-connect to Wifi in just a few seconds.. But i wanted <= 300ms repose times for rel time events.

author: Dave_PT
author_rank: Frequent Contributor
timestamp: May 22, 2017, 09:16:59 am
content: Sorry for the delay.I got an "airPcap" and I'm looking at all packets with wireshark.But I have doubts about the beginning. This takes 1.8sec to do something, before starting DHCP.From DHCP Discovery to DHCP Request takes about 1s.I have to understand what it's doing to take 1.8sec ... but networking is not my area.

author: LeonV
author_rank: Contributor
timestamp: May 25, 2017, 05:32:19 am
content: What defines the 'beginning'?Is it waking from deep sleep, forced or auto light sleep?Or just power up?1.8s sounds suspiciously like the time it takes for the ESP8266 to connect to to the WiFi access point when the SSID and password are cached, which is pretty quick!The lowest power modes that everyone seems to use is Deep Sleep, which triggers a reset to wake, this is required since the RAM turned off in deep sleep and the CPU needs to start from scratch.This is why i started experimenting with Auto Light Sleep. Since only the CPU gets turned off, and WiFi maintains connectivity.Another thing that i have found to be super useful is the debugging serial port.It took me a while to realise what the garbled text that i was getting though the serial port was.It turned out that the ESP8266 has info that gets put through UART0 at 74880bps.This includes boot information before the uploaded software is run.Also, Sorry for the late reply.I did start a reply but then i realised i had my SSID and WiFi password in the git repositoryI must say its not like me to forget about that stuff, but at least that password was one of my more generic public ones.So to anyone writing source for the ESP, just put your SSID and Password in a header file out of the main repository.

author: Dave_PT
author_rank: Frequent Contributor
timestamp: May 25, 2017, 09:01:38 am
content: In this case ESP always starts from power-up. That's the way to keep it at "zero" consumption.The time between power-on, can take from a few times to a few times per hour. It is not predictable.In the case of a few times per hour, it compensates the Light Sleep, but in case of a few times per day no compensates.1.8s I find plenty of time for the connection. There are not so many packets to be sent ... should not connect faster?I say this because I have here an old work, using a wifi module from Microchip, which can register in 0.4s (I did not do it nor did I see it working, I only have wireshark log).It also seems to me (see previous image) that ESP is trying to do something up to 0.584s. Failing, after 1.8s does deauthentication and repeats all over again.This process always takes place this way every time. Could there be an error in the SDK related to the connection?Quote from: LeonV on May 25, 2017, 05:32:19 am

author: bitseeker
author_rank: Super Contributor
timestamp: May 25, 2017, 10:06:46 pm
content: Leon, thanks for the info on your project. I had not seen this kind of low-power setup before where Wi-Fi is kept running during sleep for faster response upon waking. I like it and will be considering doing something similar for a network-enabled thermostat.

author: LeonV
author_rank: Contributor
timestamp: May 27, 2017, 08:25:15 am
content: Thanks for the interestI had read a number of things in the Low Power Solutions PDF for the ESP8266, but i had not seen anyone implement it.And this became more obvious when researching how to use the ESP8266 in these ways.The silicon has quite a few quirks when used like this, so most of the time was spent learning those, but in the end, i believe the proof of concept is there. ~10mW and mostly real time.Feel free to ask anything if you do use this method.I will eventually be adding basic a web client to transmit JSON data along with the server, and adding an 8 channel analogue switch with some limit detection that is configurable by sending JSON data to the ESP8266.Do let me know how you get on if you do use this technique :-) The more quirks i know, the easier this thing is to get stable when run for years on end.

author: LeonV
author_rank: Contributor
timestamp: June 03, 2017, 02:36:47 am
content: Just an update for this project.I have decided to implement a reasonably standard REST server. It still needs some tidying up, but its working, and endpoints are modular.Currently only has dummy response at endpoint /adc/0I still have an issue where the ESP8266 stays awake for no apparent reason, So power consumption changes daily. Some days it will sleep when expected, and some days it wont.Anyway, still the most efficient real time solution i have found.

author: bitseeker
author_rank: Super Contributor
timestamp: June 05, 2017, 03:27:25 am
content: Quote from: LeonV on May 27, 2017, 08:25:15 amI shall. The module with ESP8266 and relay just arrived. My work schedule is kind of crazy now, but I will post any interesting results, quirks, or other findings.

author: alexluke
author_rank: Newbie
timestamp: June 05, 2017, 05:32:27 am
content: Quote from: LeonV on June 03, 2017, 02:36:47 amI just finished debugging an issue where writing past the end of a buffer was preventing the ESP8266 from deep sleeping. It appeared to sleep, but power consumption remained high. Not sure if that's related at all to your issue, but it might be something to double check.

author: Muxr
author_rank: Super Contributor
timestamp: June 05, 2017, 05:47:29 am
content: Quote from: Dave_PT on May 22, 2017, 09:16:59 amSome DHCP servers will actually ping the IP address they are trying to issue via DHCP in order to make sure there is no IP conflict. I would first check your DHCP server that's issuing the IP. See if it's sending any ICMP packets to the IP it ends up issuing.If that's the source of your delay, perhaps don't release the DHCP address when you go offline and try reusing it before attempting to request a new lease.

author: LeonV
author_rank: Contributor
timestamp: June 05, 2017, 10:14:28 am
content: Updated repository with working REST server, but not actually attached to the ADC. Still need to make the REST client to finish off that stuff.The stability issues were caused by the sudden current draw on GPIO14 to charge the interrupt capacitor.My testing now involves making REST requests to the ESP8266 every 60 seconds.Current power consumption is 86mW, but i can see that it is staying awake a lot! So there may well be some buffer overflows or something happening.Resetting the sleep states sometimes helps with this, will try again tomorrow.The readme.md is also more useful for people trying to use this source.Let me know of anything that i missed since i have no idea what is it like starting from scratch with this repository.Cheers!

author: LeonV
author_rank: Contributor
timestamp: June 06, 2017, 10:18:34 am
content: Pushed another version.. Read the notes in Git.Has unstable, but working REST client now, still messy and ugly.. But proof of concept is working.

author: LeonV
author_rank: Contributor
timestamp: June 07, 2017, 08:44:10 am
content: Also forgot to mention that i had a play with the sleep settings again and managed to get 37.2mW RMS / 18mW Average after close to 7 hours of testing.This could be halved by the wake delay. And this is still with the IC receiving REST requests every 60 seconds.1 / Yellow: Current2 / Green: Supply voltageM1 / Pink: Power (Current * Voltage)Blue trace is the capacitor on GPIO14 used to wake the IC.

author: tatus1969
author_rank: Super Contributor
timestamp: June 07, 2017, 10:58:02 am
content: maybe I'm overlooking something, but what is mW RMS?

author: LeonV
author_rank: Contributor
timestamp: June 07, 2017, 10:04:39 pm
content: Quote from: tatus1969 on June 07, 2017, 10:58:02 amMilliwatt, measured using RMS value of the full screen of the scope (Not per cycle) - DC RMS - FSI also have the average value for comparison.I will check my scope for area calculations as well, that would be more useful than RMS.RMS isn't really the right method to use, but it was yielding good enough numbers for me to compare power consumption between modifications.Edit - Added quote of what i am replying to

author: tatus1969
author_rank: Super Contributor
timestamp: June 08, 2017, 04:05:12 pm
content: Quote from: LeonV on June 07, 2017, 10:04:39 pmRoot Mean Square is only valid for voltages and currents, when you want to compare power consumption, then the average function is the right one. The averaging function should be actually doing just what you want: it calculates the surface area of your trace, and divides it by the time interval. That is not to confuse with display averaging, where the scope calculates a pixel wise average.

author: LeonV
author_rank: Contributor
timestamp: June 09, 2017, 05:11:11 am
content: Quote from: tatus1969 on June 08, 2017, 04:05:12 pmI don't know why i didn't just think about that earlier. That makes perfect sense.I guess i was just trying to get relative data and didn't really care too much about the actual data, which i need to now..I will be using mW/s area calculations going forward.Annoyingly though, I think i am getting a lot of noise that is not showing up because i am using high resolution mode, and it is causing the baseline current to be ~-800uW/s.Which is skewing the results, since the power consumption i am reading is about 4mW/s (without REST requests), but realistically closer to 5mW/s.And i need to watch my ground paths, might need to only run it from a battery going forward since i don't have any fancy active or current probes.

author: tatus1969
author_rank: Super Contributor
timestamp: June 09, 2017, 05:57:59 am
content: Quote from: LeonV on June 09, 2017, 05:11:11 amit is important for such a measurement to let the scope either measure an integer multiple of intervals (variable time base available?) or, if not possible (or if waveform is not cyclic), a large number of intervals.

author: LeonV
author_rank: Contributor
timestamp: June 13, 2017, 05:02:46 am
content: Quote from: tatus1969 on June 09, 2017, 05:57:59 amI usually use the scopes statistics feature as pictured in screen shots in earlier posts. Then once i think i have something working as i wanted it, i will leave it running for around 12 hours to get a large sample size then look at the mean.I do get variations based on the battery voltage. But my main concern is the tiny below zero readings i am getting which could skew the results far too much.This was happening when i used two probes over a resistor and subtracting them together to get the voltage difference on the high side. And also when using a single probe across the shunt resistor common with a single ground and USB powered.Ill be adding a separate RS232 to USB to it which will just be for listening to the ESP8266 as the output lines on the one used for programming does all sorts of crazy things to the ground and also feeds current into the RX pin on the ESP8266 which does skew the power readings.

author: LeonV
author_rank: Contributor
timestamp: September 11, 2017, 11:45:16 am
content: UPDATE:I have started back on this, and i have just grabbed the MQTT example code and mashed my sleep code into it and it seems to work well!If you need a low power sensor that can fire an MQTT message in real time, this should do the trick.MQTT is working both ways, but only client -> broker can be real time while sleep is enabled.https://github.com/leon-v/ESP8266-Real-Time-Low-Power

author: LeonV
author_rank: Contributor
timestamp: August 13, 2018, 04:08:22 am
content: UPDATE:The ESP8266 was only capable of using the low power i wanted when using a router that had configurable DITM intervals and felt like using them.This was not a good solution since i can't expect anyone who may use this to buy a new router.So i have made a router that routers MQTT data from radio modules to an MQTT server.Currently working on re-coding the router into the RTOS for the ESP8266, and polishing my NRF24L01+ drivers.https://github.com/leon-v/MQTT-ESP8266-nRF24L01-Solar-Battery-I-O-Network

author: ZigmundRat
author_rank: Regular Contributor
timestamp: August 14, 2018, 02:32:24 pm
content: I know this reply doesn't contribute anything exactly, but there's folks out here watching the thread, so thanks for the update. I will continue to watch the thread- and hopefully have more time to work on this kind of stuff before long.

author: bitseeker
author_rank: Super Contributor
timestamp: August 14, 2018, 09:06:53 pm
content: Thanks for the update, Leon.For my project, the relay module with onboard ESP8266 that I got wasn't designed with sleep in mind. So, it'll need some bodging to get it to work, or I might make my own PCB. Not sure which road I'll take, yet, as other projects jumped ahead of the line.