In an earlier blog post, we presented tricks to increase the battery life of your typical ESP8266 or ESP32 application. In this blog post, we show you how to prolong your device’s battery life from 7 months to 44(!) months.
We got to love the ESP32 because of its communication skills and also because it is easy to program. When you read the ESP32′ datasheet you can see that it supports not only WiFi but also Bluetooth Low Energy. But the ESP32 also supports a proprietary communication protocol by Espressif called ESP-NOW. This protocol also uses the 2.4GHz band but is optimized for sending short messages to other ESP-NOW nodes with as little overhead as possible.
And here you have two very important pre-conditions. The devices on both sides need to support the ESP-NOW protocol and it’s made for applications with short messages. You have to decide if these two pre-conditions are acceptable for your use case but if they are you can get a lot more runtime out of your batteries.
So why ESP-NOW is so much more battery-friendly? By avoiding the overhead of a WiFi, DHCP and HTTP handshake the ESP-NOW node can transmit the message much faster. And faster means a shorter duty cycle and more time to sleep. And since the ESP32 consumes far less energy when it is asleep our node can run much longer with one battery charge.
As mentioned earlier both sender and receiver of a ESP-NOW message need to speak the ESP-NOW protocol. And this means to forward the ESP-NOW message over regular WiFi channels you need some kind of a gateway for translating one protocol to the other.
This is one of the use cases we had in mind when we designed the ESPGateway. We put two ESP32-Wrover modules into the gateway. Then connected them with two GPIO pins so that the could communicate with each other. You could do a ESP-NOW-to-WiFi gateway also with just one ESP32. But WiFi and ESP-NOW cannot run at the same time in this setup. Because of this you’d have to listen with ESP-NOW for new messages. Once you receive a message switch over to WiFi and forward the message to the final destination. During this time, which can take several seconds you would miss incoming ESP-NOW messages. This might be unlikely if your system has just one node but with an increasing number of nodes you would miss more and more messages.
Our ESP-NOW Test Setup
In our experimental setup we have ESP32 nodes sending messages over ESP-NOW to one of the to ESP32-Wrovers in the ESPGateway. The first WRover then takes the ESP-NOW message and sends it over a serial line to the other one. This second ESP32 is constantly connected over WiFi and MQTT to a Raspberry Pi running an MQTT broker and Node-Red to log the messages.
This design has clearly the advantage that one ESP32 can constantly listen on the ESP-NOW channel while the other one can forward messages with no delay to the upstream server. In addition, the ESPGateway comes with two external antennas which clearly should increase the range of both ESP-NOW communication as well as MQTT over WiFi.
We optimized the ePulse dev board for use cases where the micro-controller sleeps most of the time, wakes up, sends the message and goes back to sleep. With only 25uA power consumption in deep sleep, the ePulse is in the top league of development boards.
The node will wake up by a time trigger, send a message and go back to sleep for 15 minutes. We will compare the consumption of sending a message over WiFi with the consumption of using ESP-NOW.
We measure the power consumption with the fantastic Otii Arc from Qoitech. The Otii is a power supply and power analyzer. You can measure the power consumption over a given time
The Test Results
Let’s start with sending the message directly over WiFi and MQTT. As expected, it takes several seconds for the ESP32 to wake up, connect to WiFi, get an IP address from the DHCP server and to connect and send the message over MQTT. 3.877 seconds, to be precise. Assuming a 2500mAh battery and ignoring self discharge such a node could run for 6.9 months.
Now let’s use the setup described above where we send the message over ESP-NOW. Here the node is active 564ms! The total runtime increases from 6.9 months to 3.7 years!!! The node could send 6.4 times more messages over ESP-NOW than by using WiFi!
We love the ESP32 because it is easy to program and because you can easily integrate it into your existing WiFi infrastructure. And you can build devices that run for a long time from batteries. But with a bit of additional hardware we can build sensor nodes which can run more than 6 times longer from the same battery! You don’t need to change your ESP32 based device, just adapt the code to use ESP-NOW.
If you plan to go that way the ThingPulse hardware can be your friend. The ESPGateway can collect data over ESP-NOW and forward it to your server. Our ePulse is great for prototyping such sensor nodes with its low deep sleep consumption.