Advertisement

Managing energy consumption in wireless IoT devices

March 31, 2018

Jacob_Beningo-March 31, 2018

As the IoT develops and more edge devices are deployed in the field, undoubtedly a significant portion of those devices will be battery operated. Battery operated wireless edge nodes are convenient and cost effective because they require no access to electrical infrastructure and can be easily deployed. The potential problem with battery operated devices is that when developers are under the gun to get their devices built and out the door, battery life is one of the last things on their mind. There are several things that a developer can do throughout their development cycle to ensure that they will be able to properly manage their device’s energy consumption.

First, when a developer is designing their hardware, they need to break-up their hardware into subsystems and provide the ability to add a current shunt resistor to measure the current consumption for each subsystem. Developers should consider adding the current shunt resistor to circuits and subsystems such as:

  • The microcontroller

  • The wireless controller

  • Sensor arrays

  • The power supplies inputs and outputs

  • And any other specific subsystems that could potentially draw significant current

Being able to monitor the current in these systems will allow a developer to determine where energy is being consumed and devise ways to minimize that consumption. The nice thing about these current shunts is that in production they can be replaced with zero-ohm resistors or the on-board microcontroller's analog to digital convert could be connected to them so that the energy consumption could be monitored remotely.

Next, a developer has a huge amount of control over the energy consumption based just on the software that they are writing for their embedded controller. The microcontroller has the ability to not just manage its own energy consumption but also manage the wireless controller and other onboard circuits. For example, a developer with an Arm Cortex-M processor can put their system into a low power mode and wait for an interrupt to wake the system. The code to implement such a behavior is as simple as writing a few lines of code:

while(true)
{
   _WFI();
}


which quite literally means “Wait For Interrupt” and puts the system into a low power state. That interrupt could be from the wireless controller, telling the microcontroller that there is data to be processed or it could from any other event in the system that has been deemed important enough to wake the system. Don’t forget that battery powered devices should be architected so that they are event driven and otherwise spend most of their time sleeping waiting for events to occur.

Another favorite method that can help manage energy consumption is the to use the Sleep On Exit capabilities in the Arm Cortex-M processors. This essentially tells the processor to skip the context switch that occurs at the start and end of an interrupt because the same interrupt is expected to fire again. This can shave dozens of clock cycles off the software execution which can add up significantly over the course of weeks and months. This feature is usually enabled by enabling the sleep-on-exit feature in the system control block as follows:

SCB->SCR = SCB | 0x2U;
while(true)
{
   _WFI();
}


Now these last two techniques are simple things that can be done in the software to help minimize the microcontroller's energy consumption. The real secret though to managing the energy consumption in an IoT device is that you have to measure the energy consumption and correlate it to the code that is being executed. Without making measurements, there is no way to understand if an interrupt is firing too often; to realize if a particular function is executing longer than expected; or to determine where the energy is going in the system. Once measurements are performed, a developer can then intelligently dig in and determine the best optimizations for the system that can then lead to a finely tuned and efficient wireless IoT node.

Optimizing and managing the energy consumption in a wireless IoT device is usually one of the last things a developer considers before they push the product out the door. In some circumstances, it’s more important to get to market and then tune and update later. Still, managing energy consumption will be difficult if a developer hasn’t thought through the problem and ensured that the hardware and software is in place to easily update the system or monitor its field behavior. We’ve looked at a few simple ideas to get you started today which can at least ensure you have a few fundamental starting points to managing your own system's energy consumption.

Additional Resources:


Jacob Beningo is an embedded software consultant, advisor and educator who currently works with clients in more than a dozen countries to dramatically transform their software, systems and processes. Feel free to contact him at jacob@beningo.com, at his website www.beningo.com, and sign-up for his monthly Embedded Bytes Newsletter.

 

Loading comments...