Skip to content
You Start with one site
Amounts in Start with one site
Embedded Systems · Concept

Sleep and low power

One idea Intermediate 5 min read
Found this useful?

A phone with the screen on is empty by the evening. The same phone with the screen off lasts for days, because almost everything inside it is switched off between uses. A battery sensor is designed in the same way. Sleep is a mode in which a microcontroller switches off nearly all of itself, and a low power device is one that sleeps almost all the time.

While asleepIt is 99% of the time, so it must be most of the charge.True only for a bad board
While awakeTwo seconds with the radio on can cost more than five minutes asleep.True for a good board
Two numbers decideHow long it is awake, and what it draws while asleep.Measure both

See it

Predict first

A sensor node wakes every 5 minutes. It is awake for 2 s and draws 120 mA while it measures and sends. Then it sleeps for 298 s and draws 0.01 mA. In one cycle, which part uses more charge from the battery?

See it: where the battery goes in one cycle

Average current
Share of the charge used asleep
Life of two AA cells

The node draws 120 mA while awake and wakes every 5 minutes. The upper bar is time and the lower bar is charge. With a good sleep current, a thin slice of time takes nearly all the charge. With a poor one, the sleep takes it.

The idea

A battery holds a fixed amount of charge, written in milliampere hours (mAh). A device that draws 1 mA empties a 2,500 mAh battery in 2,500 hours. So the life of a battery depends on one number: the average current.

A node that measures every few minutes has nothing to do between measurements. In deep sleep the processor, the radio and most of the memory are off, and only a small timer runs. One common module draws about 0.01 mA in deep sleep, against 100 mA or more with its radio on.

Iaverage = (Iawake × tawake + Isleep × tsleep) ÷ tcycle

I is a current and t is a time within one cycle. Battery life in hours = capacity in mAh ÷ Iaverage in mA.

Deep sleep has a price. When the timer wakes the chip, the program starts again from the beginning, and only values placed in a small kept memory survive. The lesson on power management and deep sleep shows how to keep them.

The formula also assumes a perfect battery. Real cells lose charge by themselves and give less in the cold, so a calculated life of several years is too optimistic.

One worked number

The question

A node wakes every 5 minutes (300 s). It is awake for 2 s at 120 mA and asleep for 298 s at 0.01 mA. How long do two AA cells of 2,500 mAh last?

Show the worked solution, 3 steps
  1. Find the charge used in each part

    Awake: 120 mA × 2 s = 240 mA s. Asleep: 0.01 mA × 298 s = 2.98 mA s.

  2. Spread it over the whole cycle

    Average = (240 + 2.98) ÷ 300 = 0.810 mA.

  3. Divide the capacity by the average

    2,500 mAh ÷ 0.810 mA = 3,086 h. Divide by 24: about 129 days. The figure opens on this case.

The mistake to avoid

The sleep current in the data sheet of the chip is not the sleep current of your board. A development board keeps a power lamp, a voltage regulator and a USB chip running while the processor sleeps, and together they draw 5 to 20 mA. At 5 mA asleep the same node lasts 18 days, not 129. Measure the current of the whole board in sleep before you trust any estimate.

Check yourself

Question 1

The node of the worked number is changed to connect faster, so it is awake for 1 s, not 2 s. Nothing else changes. What happens to the battery life?

Question 2

A node built on a development board should last 129 days by calculation. Its cells are empty after 18 days. The program is correct and the cells were new. What is the most likely cause?

Question 3

A node counts the readings it has sent in an ordinary variable. After every deep sleep the count is back at its first value. Why?

Where you meet it

  • A tank level sensor on a remote siteIt wakes every 15 minutes, measures, sends and sleeps. On paper two AA cells then last about a year.
  • A temperature tag in a cold roomIt sleeps until a timer or the door switch wakes it, so nobody runs a cable to it.
  • A water meter with a radioIts sealed battery must last for many years, so it is awake for a fraction of a second each time.
Key points
  • Battery life = capacity ÷ average current.
  • The awake time is short but can use nearly all the charge. Make it shorter.
  • The sleep current of the whole board counts, not that of the chip alone.
  • After deep sleep the program starts again from the beginning.
Found this useful?

Discussion

    Comments show your name. Be kind, stay on the topic.