DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Patch Management in the Age of IoT: Challenges and Solutions
  • IoT Communication Protocols for Efficient Device Integration
  • OPC-UA and MQTT: A Guide to Protocols, Python Implementations
  • How to Optimize Edge Devices for AI Processing

Trending

  • Microsoft Azure Synapse Analytics: Scaling Hurdles and Limitations
  • Create Your Own AI-Powered Virtual Tutor: An Easy Tutorial
  • While Performing Dependency Selection, I Avoid the Loss Of Sleep From Node.js Libraries' Dangers
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Device Power Management in IoT

Device Power Management in IoT

Learn how you can implement device power management in IoT.

By 
Francesco Azzola user avatar
Francesco Azzola
·
Feb. 14, 19 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
15.4K Views

Join the DZone community and get the full member experience.

Join For Free

power management iot

One aspect to consider while developing an IoT project is device power management. With the rise of the Internet of Things, the optimization of the battery-operated devices is an important aspect that can make a huge difference. Device power management in the IoT is a challenging task because a device could always be powered up and could be located everywhere. Often, IoT devices are located remotely and they must use a battery to work.

IoT Device Power Management: How to Implement It

The device power management in IoT involves all the steps related to the designing process, and it is very important to take into account how the device will behave and how this behavior affects energy consumption. The battery capacity and device behavior are two of the most important aspects. In more detail, the device behavior can have a bad impact on energy management. Usually, we can model an IoT device power consumption using three different areas:

  • Microcontroller
  • Radio operations
  • Sensors and actuators

A typical IoT device use case is:

  • Acquiring data from sensors
  • Sending and receiving data
  • Controlling actuators

Usually, an IoT device uses one or more sensors to acquire information related to the environment. The data acquired are used locally or remotely to take decisions. This information is acquired using sensors, and each sensor has specific power consumption. Therefore, it is very important to select sensors carefully in order to optimize power management.

An IoT device during its operations can send and receive data remotely. Usually, several IoT devices are connected to an IoT gateway that collects such information and sends them to the cloud. The sending and receiving operation is one of the most expensive tasks from the power management point of view. This operation involves the radio connection (cellular, Wi-Fi, Bluetooth, etc.).

Finally, using some specific business logic locally or remotely, an IoT device can control one or more actuators.

The microcontroller controls all the operations and is the brain of the device, and in order to work, it needs power.

Implementing Power Management in IoT

Now that we have introduced some aspects related to power management in an IoT device, it is time to describe how to implement it. To do it, we will describe some best practices from the development point of view, covering how to write the code that takes into account the device power management.

The easiest way we use to develop an IoT application using Arduino, ESP8266, and other compatible devices is implementing the code in the loop() method. For example, when we have to acquire data from a sensor at specific time intervals, we simply add the delay(..) method, specifying how long the device should wait before starting again and repeat the same tasks. This approach isn’t the best one when we consider the power management aspect. There are different ways we can use to achieve a better result.

In more details, for example, an ESP8266 device has four different modes to “sleep” or save the battery:

  • No sleep
  • Modem sleep
  • Light sleep
  • Deep-sleep

This table describes these different sleep modes:

source “ ESP8266 Low Power solution“

No Sleep

This is the most inefficient way to use this device. It is always on.

Modem-Sleep Mode

This mode is enabled only when the ESP8266 is connected to Wi-Fi. In this mode, the ESP8266 turns off the Wi-Fi module between two DTIM Beacon interval. The ESP8266 turns on again the Wi-Fi module before the next Beacon. Sleep mode is used when it is necessary to keep the CPU on.

Light-Sleep Mode

This is mode is very similar to the Modem-sleep mode but in this mode, ESP8266 suspends the CPU and turns off the clock. This mode is more efficient than the previous mode. In Light-sleep mode, the ESP8266 should be woken up using a GPIO pin.

Deep-Sleep Mode

In this mode, everything is turned off except the RTC (Real Time Clock), so that the ESP8266 can be turned on periodically. This is the most the most efficient mode. The deep-sleep mode can be used in scenarios where the device should send data at specific intervals. This is the example of an application that uses sensors. The application reads sensor data, sends the values and the goes into a deep-sleep mode.

More interesting resources:

  • How to Use Cayenne IoT With ESP8266 and MQTT: Complete Step-by-Step Guide

  • Build an IoT Soil Moisture Monitor Using the Arduino With an IFTTT Alert System

How to Use Power Management in ESP8266 to Reduce the Power Consumption

Now, it is time to build a simple example describing how to use the deep-sleep mode to handle power management in IoT. Let us suppose that our application has to read the temperature and send it to a remote IoT platform. The application structure must be:

  • Read data from the sensor
  • Send data
  • Goes into the deep-sleep mode for a predefined time interval
  • Repeat again from the first step

How to Enable Deep-Sleep Mode in ESP8266

The first step is enabling the deep-sleep mode. The schematic below shows how to do it:

Power Management in IoT

In this case, we are connecting the pin D0 to the RST. When you upload the code to your ESP8266, do not connect D0 to RST.

The ESP8266 code below shows how to do it:

#include <ESP8266WiFi.h>

const char* WIFI_SSID="---";
const char* WIFI_PWD="----";

void setup() {
  Serial.begin(9600); 

  connectToWifi();
  // send data

  Serial.println("Going to deep sleep for 15 sec");
  ESP.deepSleep(15e6);
}

void loop() {
  // put your main code here, to run repeatedly:
}

void connectToWifi() {
  Serial.print("Connecting to Wifi:");
  Serial.println(WIFI_SSID);
  WiFi.begin(WIFI_SSID, WIFI_PWD);

   while (WiFi.status() != WL_CONNECTED) {
    if (WiFi.status() == WL_CONNECT_FAILED) {
      Serial.println("Error during WiFi connection- ");
      delay(10000);
    }
    delay(1000);
   }

    Serial.print("Wifi IP:");
    Serial.println(WiFi.localIP());
}


In this case, the ESP8266 goes into the deep-sleep mode for 15 seconds. When it wakes up, it starts from the beginning again, connecting to the Wi-Fi and so on.

It is possible to use this approach to wake up the ESP8266 using a button to start it. We will cover it in another post.

Summary

At the end of this post, hopefully, you gained the knowledge about how to manage the power in IoT using some example. The power management is very important in IoT, so it is important to take it into account.

IoT

Published at DZone with permission of Francesco Azzola, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Patch Management in the Age of IoT: Challenges and Solutions
  • IoT Communication Protocols for Efficient Device Integration
  • OPC-UA and MQTT: A Guide to Protocols, Python Implementations
  • How to Optimize Edge Devices for AI Processing

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!