Arduino has released a new power management library designed for Arduino Pro modules to help users monitor battery usage, fine-tune charging parameters, and optimize the power consumption of their Arduino code by notably enabling sleep and standby modes on supported devices.
Currently, the Arduino Portenta H7 boards, the Arduino Portenta C33, and the Nicla Vision module are supported by the new power management library. The company explains some boards consume under 100 microamperes in deep sleep mode enabling months or even years of continuous runtime on a single charge, so making use of those features is important to lower the power consumption of battery-powered IoT devices and wearables.
Arduino power management library key features:
- Battery monitoring – Reports battery metrics such as voltage, current, percentage, and temperature.
- Battery health tracking – Monitors battery health with detailed insights into temperature and reported capacity.
- Charging control – Monitors and adjusts charging parameters to better battery management
- Sleep and Standby modes – Portenta C33 or Portenta H7 can be put into low-power Sleep and Standby modes for a longer battery life. Support for the Nicla Vision module is not implemented yet but is coming soon.
- Power rail control – Fine-tune power usage by toggling and setting voltages on various power rails of the board.
Installing the library is super easy just search for “PowerManagement” and the new Arduino library will show up and can be installed from the IDE like any other library. You’ll also find it with the source code and documentation on GitHub.
To give it a quick try, Arduino provides five example sketches for battery monitoring, charging, and standby/wake-up management, You can load then directly from the Arduino IDE or find them on GitHub.
Arduino also shared some power consumption numbers before and after optimization using the Nordic Power Profiler Kit II through the JST power connector of the Portenta boards. The company notes that numbers might be higher when powering through the VIN or 5V pin because it involves more power regulators that are not as efficient as the PF1550’s integrated regulators. Here are the results…
If your application allows it, going into standby with peripherals off yields the best power savings. The Renesas and STMicro MCUs found in the Portenta boards provide granular control of peripherals so you can only disable those that are not needed. Arduino has more information and recommendations in the announcement explaining how to optimize power and battery using the new power management library.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
Who uses Arduino and care about power consumption?
As far as I’m concerned, the Arduino API is primarily for prototyping, and then you build the real product using the API from the chip maker.
(Talking from a senior embedded c/c++ developer perspective)
For example: me (as to your first question). Nowadays, there are hundreds of Arduino compatible small modules (from 20x10mm and upwards), that can be integrated in end products. The advantage of going the Arduino way is that you maintain one code base for modules from different chip vendors, IDEs, and even architectures (ARM, RISC) and you can easily switch from one to other, as they appear on the market. Believe me, in terms of price and development time (which is price squared), they are unbeatable for not very large quantities. For battèry operated products, current draw (sleep mode, deep sleep) is of primary importance and even this is managable from within the Arduino environment although with some device specific code. Arduino can do much more than you think…
How do they achieve such portability? With a lot of bloat and inefficient code that also harms performance quite significantly.
All your Arduino compatible modules and MCUs you talk about will likely not be officially supported by Arduino, they will rely on community made ports or BSPs which unless you are going through their code yourself and checking it over, shouldn’t be used for any serious tasks and especially not anything safety critical. If you use those ports or BSPs then you are running code from an untrusted source and likely have no idea what it is actually doing.
Well written C/C++ code is already portable, especially if you separate out the code that interfaces with the microcontrollers hardware from your application code which is all you are doing with Arduino anyway.
Having used Arduino a lot myself in the past it just doesn’t compare to using vendor provided SDKs or HALs, both in features and performance.
Up to now, I didn’t notice any “bloat” or “inefficient code” while doing and 8k FFT, subsequent digital filtering, and other DSP on a 5 bucks Arduino compatible board in under 0.2 seconds. Supposed your vendor specific SDK does it in half the time, when yours is ready, I can take a coffee and wait for mine to complete.
Furthermore, you completely forget about connectivity, offered by Arduino. By changing only one #define statement, I can compile a 1.5k line BLE capable code for different chip architectures. In your case, this goes with a learning curve of at least a couple of months…