How UART debugging affects power consumption on a nRF52840

Last week, I shared about my first goal when receiving a XIAO nRF52840, measuring energy consumption using Otii Ace Pro, and the results obtained powering up the system using the stand-module in comparison when its being powered with the expansion board.

But of course, my experiments didn’t stop there. A good practice when optimizing device’s power consumption is to use UART for debugging, as it allows you to quickly identify which part of your code is responsible for higher power usage. Once identified, you can address it at the hardware or firmware level to eliminate those extra amps that no one wants, right?

For example, take a look at the image below to see how the UART logs can be correlated with the measurement graph during the active period of the device while it performs a blink sequence.

You can also send commands (TX) directly to your device from the Otii App, making it perfect for sending AT commands and configuring your device–allowing you to quickly monitor and identify the device’s energy consumption peaks while running those configurations.

But, what’s the difference in power consumption when having UART enabled in the system? With a 3.3V power supply, we can quickly observe at the upper right corner of the image above, the following power consumption during the active period:

  • UART ON: 1.34 mA
  • UART OFF: 460 µA

We can see a quite difference just by having the UART enabled in the firmware. This got me thinking—what would happen if I accidentally left debug messages enabled in the final production version? How much additional power would it consume?

So, I ran a quick test to corroborate the impact of UART on battery life. I tested two versions of the firmware, one with UART enabled and one with it disabled, considering a battery capacity of 220mA while keeping the device in a 3600-second sleep cycle for the battery life estimation.

Here’s what I found using the Otii Product Suite from Qoitech.

:red_circle: UART ON – 3.1 years of battery life (26,822 iterations)

:green_circle: UART OFF – 5.9 years of battery life (51,705 iterations)

That’s quite a difference, right? So, if you’re constantly debugging, make sure UART is disabled before merging the final firmware version to the main branch. Otherwise, it could have a big impact on maintenance costs if you’re deploying thousands of devices. Save yourself the headache by verifying that everything functions as expected with continuous integration testing.

If you’d like to explore further into these measurements, you can download the project here and open it in the Otii Desktop App. The app is completely free, and you can download it right here.

Fore more info, you can check Qoitech docs.