We all know the ESP8266 and its more recent sibling the ESP32. They’re used in just about everything under the sun, both hobbyist and commercial. Mostly this is because they’re cheap, but also because they’re easy to work with.

But how much power do they consume?

That’s what I set out to determine in my latest experiment. One would think that it wouldn’t matter; the project needs WiFi, and the ESP is not regarded as power-hungry in that arena. There are other considerations, however.

For example, do we want the ESP to be the only processor in the system? Or will it be better to have a dedicated low-power MCU to handle the display, and keep the ESP powered down at all other times? Inquiring minds want to know!

Experimental Setup

This experiment is argually a bit simpler than the last one. All I needed was an MQTT server, a bit of code, and an ESP8266 hooked up to a meter with which to measure the power draw.

MQTT is easy enough; I just fired up mosquitto on one of my machines. It’s an old version, but that doesn’t really matter. A simple utility written in Go enables messages to be sent to a particular topic that I’m using for testing. MQTT is really fairly easy to use, so that’s not hard.

The ESP code is… not that much harder.

All it does is connect to WiFi, connect to MQTT, and grab a message off the topic. That done, it goes back to sleep for the next five seconds or so. It does report all this over serial of course, so we can see that it’s working properly. And that’s all we need.

To measure, we install the unit (an Adafruit Feather HUZZAH) on a breadboard, being fed by my benchtop power supply through a 1-ohm resistor. We can measure the voltage drop across that resistor and use it to calculate current draw, or at least, that’s the intent. As a nice bonus, my power supply also has a current meter, though I don’t really trust its accuracy.

You’re not going to measure something like this with a DMM, though; instead, it gets hooked up to my oscilloscope. A bit of settings tinkering later, and we have something that can record a waveform representing the power utilization of the unit for the few seconds that it’s awake and working. That gives us a visual representation, and on top of which, the oscilloscope allows us to save the waveform data to storage as well.

Yes, I have a CSV file containing all the samples taken by the oscilloscope. There are about 600 samples all told.

The goal here is simple; run it, collect the usage data, and use that to help determine our requirements and limits for this project.

Oh, and note that the Huzzah has GPIO16 connected to RST; that’s the red wire in the image. That is absolutely necessary to allow the ESP8266 to wake itself up again periodically. Without it, it will go out to lunch the first time it goes to sleep, and it will never come back.

The Results

The waveform is, unsurprisingly, rather dirty. I did clean it up a bit by adding a bulk capacitor, but it was only a very minimal help. The power draw is not steady, and it shows in the waveform recorded.

Note that this captured two and a half runs; the actual run-time is only about six and a half seconds (as can be seen by counting the grid squares it occupies; they’re set for two seconds per square). In theory, we can calculate a rough average power utilization during that timeframe…

Each grid square is 100mV; the recorded signal seems to average around 90 or 95% of a grid square (note that the zero line is not lined up with the grid; it’s denoted by the yellow arrow on the left). We’ll go with 95% to be conservative, and I’m going to mostly ignore the massive spikes since they’re so short-lived.

To calculate the used current we need to know the actual resistance we’re measuring across; in this case, it measured at 1.2 ohms. From there it’s just Ohm’s Law, right? I=V/R, so (0.95*0.100)/1.2, or around 79mA.

Oddly enough, that’s exactly what my power supply says in the picture up top. That’s more coincidence than anything, though; it tends to fluctuate between around 65 and 90 mA. Still, this is a good enough range for our purposes.

A little more interesting is the timing; we can tell just by looking at the graph that it takes, as I said before, about 6.5 seconds for an update, give or take. If we assume we’ll update once a minute and factor that in, we get 79mA * (6.5/60), or 8.56mA on average.

That’s a great deal lower than I was expecting.

Other Notes

The only other item of note is the idle draw. I don’t have it pictured, but it the ESP pulls significant power at all times, even when in deep sleep mode; my trusty Fluke measured it at 6.5mA. I don’t actually know if that’s the ESP or the surrounding circuitry on the Huzzah board, but I would bet on the former.

That means that there’s room for improvement just by cutting power to the ESP entirely when it isn’t in use. That’s something to think about.

And…?

In the end, the ESP8266 is an expensive chip to run. Looking at the technical documentation from the ESP32, it’s not much better; the lowest you could probably go is ~20mA without wireless. There is the ESP32’s ULP, but it looks rather like a hack.

My current thinking is to go with the STM32G0. It’s a very low-power chip (according to the datasheet, at least). I should be able to run it at less than 100uA typical at 32KHz, which should be more than enough speed to run the display. Going up to 2MHz can still be less than a quarter of a milliamp.

That doesn’t include the display’s power draw, of course, but it makes the display controller power truly negligible.

I figure the STM32 can manage the display, and simply wake the 8266 up whenever it wants an update. Optionally, it can also power-manage the 8266 if I want to reclaim that 6mA constant idle draw (which is a good possibility). Should be easy enough to implement either way.

Maybe someday I’ll play with the ESP32 and its ULP, but not today; I don’t fancy writing the display code in assembly. The only C compiler(s) for that thing are experimental as near as I can tell.

And that… is really all I need to know, I think. I’ll sleep on it, but I think I’m ready to throw a design together. I find that I’m rather looking forward to it!