element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • 'Choose another store...'
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs ESP8266 Power Consumption - Further Studies
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: neilk
  • Date Created: 17 Feb 2019 4:26 PM Date Created
  • Views 297 views
  • Likes 9 likes
  • Comments 3 comments
  • power_consumption;
  • wemos d1
  • esp8266
  • sketch_execution_time
Related
Recommended

ESP8266 Power Consumption - Further Studies

neilk
neilk
17 Feb 2019

Introduction

 

In a postscript to my last Blog:

 

https://www.element14.com/community/people/neilk/blog/2019/02/14/investigating-the-power-consumption-of-a-wemos-d1-mini-esp8266

 

I concluded that the power consumption of the Wemos ESP8266 during Deep Sleep was negligible - around 227 microAmps. This includes the current drawn by the USB-Serial interface and extra current drawn by the battery monitoring resistor chain.

 

This represents 22.7 mAh over 100 hours and is pretty negligible when set against a 2400 mAh battery. Therefore, anything that could be done to shorten the execution time of the sketch should be beneficial.

 

My only Wemos d1 mini is currently running a long term battery life test.However, I have a Witty ESP8266 which I can use to investigate whether I can shorten the execution time of the sketch.

 

Experiment 1 - Removal of Diagnostic Messages

 

The original sketch contained an abundance of diagnostic messages intended for output to Arduino IDE serial monitor. Obviously when the device is operating on battery, these messages are going nowhere but are presumably taking time to execute and, possibly, using extra power by driving the USB-serial interface.

 

I commented out all the diagnostic messages and uploaded the sketch to a Witty. My first attempt was a failure because the Wemos d1 and the Witty are not completely pin compatible and I picked the wrong Pin for the GPIO16 WakeUP to Reset pin jumper. After a bit of squinting to read the pin labels, I sorted that out and let the Witty run for 60 readings. Inspecting one of the log files, I could see that the time interval between readings was typically  59 seconds and sometimes 58 seconds. In fact,  60 readings took 58 minutes 48 seconds instead of 1 hour. This means that I need to shorten the Sleep Time correction factor by 1 second.

 

Experiment 2 - Stop listening to the Server Response

 

When the data has been posted to the server (or even if the posting fails), the Server replies with a substantial message, which the sketch was listening to and then copying to the serial interface for diagnostics. What happens if we stop listening to this message?

 

I commented out this section of the code and reduced the Sleep Time correction factor by 1 second - now 4 seconds - as in Experiment 1, above..

 

After running the Witty for only a few readings I could see that time interval was now around 56 seconds and the LED indicating that a reading was being taken was just a flash, not 4 seconds of continuous illumination. So I have shortened the execution time by ignoring the server response. This also reduces the length of time for which the LED is on - a further power saving?.

 

I removed the sleep time correction factor completely, recompiled and repeated the test. After running the Witty for 60 readings, I could see that the interval between readings was now frequently LESS than 1 minute and that 60 readings now took about 59 minutes 40 seconds!

 

Somewhat confused, I consulted Mr Google and soon discovered that the Sleep Timer is not very precise - not the best crystal. The suggestion was to trim the Sleep Time to achieve the desired value. However, before I get into that, I have one further software change to try.

 

Experiment 3 - Don't start the Serial Interface

 

The first thing the sketch does in setup() is:

 

  Serial.begin(9600);
  delay(100);

 

I think a delay after Serial.begin is fairly traditional!

 

Commenting these out will slightly shorten the execution time. I modified accordingly and ran a test.

 

After a few minutes I checked one of the log files and found that the time interval between readings appears to be slipping consistently by around 0.5 seconds per reading. I decided to let this run for 100 readings before calculating a correction factor and modifying the sketch accordingly. Over the period of 100 readings, the time lost was 41 seconds, so the correction factor should be 41 / 99 = 414 mSecs (this may be excessively precise!.)

 

I modified the sketch to incorporate this correction factor and ran another test for a much longer period - necessary since we are looking for a much smaller potential error in each interval. Over around 550 readings, the interval between readings is almost consistent at 60 seconds. Now and again a 61 second interval appears, usually, but not always, followed sometime later by a 59 second interval. Over the 550 readings, the total time slip is 4 seconds.

 

Further Thoughts

 

A more important consideration is what will happen to the actual time interval between readings if we set the sleep time to be 5 minutes? The sketch takes a finite time to execute - maybe a second or two - and yet a sleep time of 1 minute results in a time interval between readings of approximately 59.5 seconds, unless we include a correction factor. This implies that the real error in sleep time is actually greater, perhaps more than 1.5 seconds in 1 minute. So, setting the sleep time to 5 minutes could result in a much bigger error.

 

Modifying the sketch and setting the Witty off on another long term test which I will report on later.

 

Meanwhile, the final version of the sketch, as described above, will be uploaded to the Wemos d1 and another long term battery test set off. Again I will report on the results of this much later!

 

Watch this space......

  • Sign in to reply

Top Comments

  • neilk
    neilk over 4 years ago in reply to genebren +3
    Thanks Gene. I like the idea of the super cap to allow "hot" battery swap, but I don't think my particular application - greenhouse temperature monitoring - really justifies it! A warning that the battery…
  • genebren
    genebren over 4 years ago +2
    Good luck on getting the energy drain down to the lowest level possible. It is nice to get a nice extended time between charges. If you need really long, uninterrupted run times, you might want to consider…
  • neilk
    neilk over 4 years ago +2
    UPDATE A more important consideration is what will happen to the actual time interval between readings if we set the sleep time to be 5 minutes? The sketch takes a finite time to execute - maybe a second…
  • neilk
    neilk over 4 years ago

    UPDATE

     

    A more important consideration is what will happen to the actual time interval between readings if we set the sleep time to be 5 minutes? The sketch takes a finite time to execute - maybe a second or two - and yet a sleep time of 1 minute results in a time interval between readings of approximately 59.5 seconds, unless we include a correction factor. This implies that the real error in sleep time is actually greater, perhaps more than 1.5 seconds in 1 minute. So, setting the sleep time to 5 minutes could result in a much bigger error.

     

    Modifying the sketch and setting the Witty off on another long term test which I will report on later.

     

     

     

    A first test run of about 10 x 5 minute interval readings showed that the Witty Sleep Time was under by between 8.5 and 9 seconds per 5 minute Sleep Interval

     

    I am running further tests to get this more accurate.

     

    The Wemos d1  long term battery test, using the optimised sketch, has now been running for over 90 hours and and the battery voltage has fallen to just under 3.8V. This is already much much better than the original sketch

     

    However, there is another issue to resolve - the Wemos d1 does not seem to have the same sleep time error as the Witty: with the same correction factor of 414 mSecs added to a 60 Second sleep time, the Wemos d1 is sleeping by around 300 mSecs longer than it should in every 60 second period. I will investigate this further when the long term battery test is over.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neilk
    neilk over 4 years ago in reply to genebren

    Thanks Gene.

     

    I like the idea of the super cap to allow "hot" battery swap, but I don't think my particular application - greenhouse temperature monitoring - really justifies it!

     

    A warning that the battery only has a few hours left might be a good idea.

     

    Neil

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 4 years ago

    Good luck on getting the energy drain down to the lowest level possible.  It is nice to get a nice extended time between charges.  If you need really long, uninterrupted run times, you might want to consider the ability to hot swap the battery pack (with or without the boost), by having a small super cap to maintain power across the changeover.

     

    Gene

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube