Chapter 6. Battery Power and Sleeping
By now, you have created a real wireless sensor network, consisting of multiple nodes each containing some sensors and/or actuators that are controlled by a central coordinator.
However, all of your nodes have to be connected to the mains power, which limits the projects that you can build. You might not have a power outlet easily available everywhere and moving the nodes is cumbersome.
In this chapter, you will explore the various options for making your nodes battery-powered, allowing for a greater flexibility in deploying your projects and mobile or outdoor deployments.
Of course, battery power is not really useful if the battery is depleted in just hours or days. By applying the power saving techniques presented in this chapter, you will be able to let your nodes run for months or even years on a single battery charge.
In the first example, you will make the window sensor from Chapter 5, Standalone XBee Operation battery-powered. In addition to the components...
Even though it sounds simple, making your Arduino battery-powered is a complicated subject. There are a lot of different types of batteries and multiple ways to connect them, each with their own requirements and effects on the power that is used.
This section gives you a very concise summary of the battery terminology, intended to be exactly enough to make sense of the rest of this chapter. For more detailed information about the batteries and an overview of some common types that are available, see https://learn.adafruit.com/all-about-batteries.
Batteries are devices that store energy and can be used to power electrical devices. Every battery has a nominal voltage (such as 1.5V for alkaline batteries), indicating an average voltage of the battery over its entire lifetime.
Battery capacity is measured in mAh, or milliampere-hour. A battery of 1,000 mAh can supply 1,000 mA for 1 hour, 100 mA for 10 hours, 10 mA for 100 hours, and so on. To estimate the lifetime of a battery, divide...
To allow the running of your project on batteries for any meaningful time, you will have to take measures to reduce the current usage. The temperature sensor that you created in Chapter 2, Collecting Sensor Data, draws around 80 mA. Suppose you run it on some rechargeable AA batteries rated at 2,000 mAh. This means that the batteries are expected to last about 2,000 mAh / 80 mA, which equals 25 hours.
It is sufficient to say that a wireless sensor network is not so useful when the batteries have to be changed every morning. Fortunately, there are a lot of things that can be done to save power.
The first step in reducing the current usage is to find out where all this current is going. On this sensor, the current usage is roughly divided as follows:
Main microcontroller: 10-15 mA
16U2 microcontroller (serial-to-USB): 15-25 mA (even when not using USB)
Power LED: 6 mA
5 V regulator: 5 mA
3.3 V regulator on the Arduino: 0.1 mA (more when loaded)
3.3 V regulator on the XBee shield: 0.5...
Typically, a radio is responsible for a big part of a device's current draw. Even though the XBee radio modules are designed to be low in power, their maximum power usage is typically in the 40-80 mA range while receiving. The XBee modules have the same current usage while transmitting, with the long range XBee PRO modules needing up to 500 mA.
Fortunately, all these modules can be put to sleep just like your microcontroller, bringing their power usage in or below the μA range (less than 1 μA for the XBee ZB modules).
Of course, when an XBee module is sleeping, it will be unable to receive any messages that are addressed to it. This creates a number of problems that need to be solved by the networking stack. In a ZigBee network, this is done by introducing a new class of devices called end devices (in addition to the coordinator and routers that you saw before), which are allowed to sleep.
To allow these end devices to sleep, some things work differently for them than what...
Now that you have seen how you can reduce the XBee power usage to almost zero, it is time to look at the other power-hungry device: the Arduino. Most of the techniques listed earlier will be applied here, starting with the replacing of the hardware with other hardware running at a lower voltage and frequency and containing less components. Then, the microcontroller sleep mode will be discussed in detail, letting you reduce the power usage even further.
Normally, the Arduino and XBee module will be asleep and the DHT sensor is powered off. Once every five minutes, the Arduino wakes up to take a sensor reading. This happens as follows:
The Arduino briefly wakes up and powers up the DHT sensor (which needs about one second to start up before it can reliably measured).
The Arduino sleeps for one more second.
The Arduino reads the DHT sensor values and powers the sensor off again.
The Arduino pulls the SLEEP_RQ
pin on the XBee module to low, causing the XBee module to wake up...
By now, you will have created a full-blown sensor network consisting of different types of nodes and carrying different sensors and actuators. The network is able to respond to your input and its environment and can control the heating or cooling installation in your house. Some of your nodes are even battery-powered, making them mobile and easy to deploy.
You have all the ingredients to extend on the network that you built or start a completely new wireless project, limited only by your imagination!