
{"id":319,"date":"2017-05-25T00:44:25","date_gmt":"2017-05-24T14:44:25","guid":{"rendered":"http:\/\/bakke.online\/?p=319"},"modified":"2022-01-22T20:10:56","modified_gmt":"2022-01-22T09:10:56","slug":"further-reducing-wifi-power-consumption-on-esp8266","status":"publish","type":"post","link":"https:\/\/www.bakke.online\/index.php\/2017\/05\/25\/further-reducing-wifi-power-consumption-on-esp8266\/","title":{"rendered":"Further reducing power consumption on ESP8266"},"content":{"rendered":"<p>By carefully rearranging the operations my weather station does each time it wakes up, I have reduced the power consumption even further.<\/p>\n<p>As it wakes up, it needs to make a series of measurements:<\/p>\n<ul>\n<li>Read the current battery voltage<\/li>\n<li>Read the current temperature from a DHT22<\/li>\n<li>Read the current humidity from a DHT22<\/li>\n<li>Read the current temperature from a BMP180<\/li>\n<li>Read the current air pressure from a BMP180<\/li>\n<\/ul>\n<p>The battery voltage is read through a resistor voltage divider feeding into the analog input of the ESP8266. \u00a0This reading is very sensitive, and a massive power drain from the WiFi function will bring down the measured voltage. \u00a0This can be mitigated by using capacitors to buffer the analog readings, but if I have a choice I&#8217;d still prefer to have the WiFi function off when reading this.<\/p>\n<p>The rest of the readings, however, are digital and not that sensitive to overall system power drain, and that gives us an opportunity to do things in parallel.<\/p>\n<p><!--more-->A 470\u03bcF\u00a0capacitor across the power supply pins of the Huzzah breakout board provides enough of a buffer that we can actually start the WiFi function as soon as the analog voltage reading has been taken. \u00a0The ESP8266 is able to handle the WiFi connection\u00a0in the background (as long as the code is sprinkled with delay() or yield() statements, and the code that reads the DHT22 and BMP180 have them. \u00a0Thus, the WiFi connection can proceed in parallel with reading these two sensors.<\/p>\n<p>This is beneficial, especially as the DHT22 (and other sensors) will have a minimum time from the sensor wakes up until the first reading can be taken. \u00a0For the DHT22 this is 1 second.<\/p>\n<p>The result? \u00a0The whole reading\/reporting cycle takes about 1.2-1.3 seconds less than before, and while we do use a fair bit more power early in the process, this is more than offset by being able to go back to sleep a lot sooner:<\/p>\n<p><a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/05\/version6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-320\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/05\/version6-1024x513.png\" alt=\"\" width=\"840\" height=\"421\" \/><\/a><\/p>\n<p>We see the slight gap between the boot loader finishing and the WiFi radio switching on. \u00a0This is where the analog reading happens. \u00a0Then, as soon as the WiFi is switched on, we start waiting for the sensors to become ready and then read them.<\/p>\n<p>The sensors are powered by a GPIO output so I can switch them off as soon as I have all the information I need. \u00a0We can see this as a slightly lower power consumption at about the 1800ms mark.<\/p>\n<p>With this change, the power consumption is now down to 0.054 mAh per cycle, that&#8217;s 54\u00a0\u03bcAh, or approximately one third of where we started.<\/p>\n<h3>What&#8217;s next?<\/h3>\n<p>There&#8217;s not much more that can be done without modifying the current sensor. \u00a0A couple of weeks, at least, before I get another sensor so I can modify one without risking breaking the one I already have.<\/p>\n<p>In the mean time, I&#8217;ll start looking at what I can do with the additional headroom I have achieved. \u00a0As I&#8217;m getting tired of running around updating the devices, getting some form of OTA updates up and running will be an interesting project.<\/p>\n<p>A <a href=\"https:\/\/www.bakke.online\/index.php\/2017\/06\/24\/esp8266-wifi-power-reduction-avoiding-network-scan\/\">follow-up post<\/a> is now online, with more power savings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By carefully rearranging the operations my weather station does each time it wakes up, I have reduced the power consumption even further. As it wakes up, it needs to make a series of measurements: Read the current battery voltage Read the current temperature from a DHT22 Read the current humidity from a DHT22 Read the &hellip; <a href=\"https:\/\/www.bakke.online\/index.php\/2017\/05\/25\/further-reducing-wifi-power-consumption-on-esp8266\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Further reducing power consumption on ESP8266&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,25,1],"tags":[8,27,9,23,24],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-arduino","category-the-notwork","category-uncategorized","tag-arduino","tag-energy-efficience","tag-esp8266","tag-internet-of-things","tag-notwork"],"_links":{"self":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":1,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":1337,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions\/1337"}],"wp:attachment":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}