Measuring ESP8266 power usage with uCurrent and a scope


This is a follow up to the ESP8266 article on agocontrol news. The GY-63 sensor board is drawing a lot current (around 2mA) due to its level shifters and the voltage regulation. Hence I’ve abandoned my plan to use one. I’ll probably get a few test units of the Bosch BE280, it might be a good option for a esp8266 based battery powered weather station. For now I’m going to use a DHT22 as I want to measure a scenario with real sensors. I’m providing the complete files so that Robert Hekkers can compare his measurements to mine.

Test setup

This is the „init.lua“:

tmr.alarm(0, 2000, 0, function()

And here we’re doing the measurement and transmit the data – „mqtt.lua“:

BRPORT = 1883
BRUSER = "user"
BRPWD = "pwd"
CLIENTID = "ESP8266-" .. node.chipid()
PIN = 6 -- GPIO 12

dht22 = require("dht22")
t = dht22.getTemperature() /10
h = dht22.getHumidity() /10

-- print "Connecting to MQTT broker. Please wait..."
m = mqtt.Client( CLIENTID, 120, BRUSER, BRPWD)
m:connect( BROKER , BRPORT, 0, function(conn)
-- print("Connected to MQTT:" .. BROKER .. ":" .. BRPORT .." as " .. CLIENTID )
m:publish("sensors/".. CLIENTID .. "/temperature",t,0,0, function(conn)
-- print ("temp published")
-- tmr.delay(10000)
m:publish("sensors/".. CLIENTID .. "/humidity",h,0,0, function(conn)
-- print ("pressure published")

The dht22.lua comes from the nodemcu git. dht22.lua and mqtt.lua have been compiled.

Scope captures

Complete wake-up phase (200ms/DIV horizontal, 30mA/DIV vertical with the uCurrent being in mA mode)

Next steps

Verify measurements and calculate total power usage over time: The scope is calculating the area as 174.2mVs. So with a total wakeup time of about 2.6s that would be an average of 66mA current draw while being awake. With 4 wakeups/h what would give 0.19mAh (4*2.6s/3600*66mA). The rest of the hour sleeping would draw 0.022mAh, resulting in 0.212mAh total. With 2500mAh AA NiMH (low self discharge, assuming 80% after 1y) that would be about a year (ignoring step-up losses).

5 Gedanken zu „Measuring ESP8266 power usage with uCurrent and a scope“

  1. Just an FYI, i got a GY-63 from reading your previous blog post about it and didn’t see this post about drawing a lot of current till afterwards. It looks like its mostly from its power on LED. I tried prising that LED off the GY-63 board with a little screwdriver and the current use drops to about 8 microamps.

  2. thanks for your comment. Funny enough I did remove the GY63 LED (and the one from the power regulator) a few hours ago. Let’s see how long it runs off two black Eneloop AA now.

  3. Maybe a little off topic, but how did you manage to get such a clear (noiseless) picture of power consumption on the scope. I am struggling with nRF24 power measurements in a similar setup. (uCurrent & Rigol, battery powered circuit) but everything keeps drowning in noise… thanks for a response.

Schreib einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *