Skip to content

Commit 01984cb

Browse files
committed
add assets
1 parent 2273ef0 commit 01984cb

File tree

6 files changed

+87
-35
lines changed

6 files changed

+87
-35
lines changed
Loading
Loading
Loading
Loading
Loading
Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
2-
title: 'Power Consumption on Arduino Boards'
3-
description: 'Learn about measuring power consumption on an Arduino board.'
2+
title: "Power Consumption on Arduino Boards"
3+
description: "Learn about measuring power consumption on an Arduino board."
44
tags: [Power Consumption]
5-
author: 'Karl Söderby'
5+
author: "Karl Söderby"
66
---
77

8-
All electronic devices, including Arduino boards, consume power. The power consumption is measured in ampere hours (Ah), and with low voltage devices, it is typically measured in mAh.
8+
All electronic devices, including Arduino boards, consume power. The power consumption is measured in ampere-hours (Ah), and with low-voltage devices, it is typically measured in mAh.
99

10-
When creating projects that run on a battery or is power-constrained, taking power consumption into account can be critical. It will among other things help you decide which kind of battery you need to use.
10+
When creating projects that run on a battery or are power-constrained, taking power consumption into account can be critical. It will among other things help you decide which kind of battery you need to use.
1111

12-
In this article, we will demonstrate how you can perform power consumption tests, using a **power profiler**. A power profiler is used to measure consumption over a specific time period, where we record several thousands samples. You will find instructions for both the hardware setup, the software setup, and the actual power consumption tests in this article.
12+
In this article, we will demonstrate how you can perform power consumption tests, using a **power profiler**. A power profiler is used to measure consumption over a specific time, where we record several thousand samples. You will find instructions for both the hardware setup, the software setup, and the actual power consumption tests in this article.
1313

14-
***Note that in this article, third party products are being used.***
14+
**_Note that in this article, third-party products are being used._**
1515

1616
## Hardware & Software Needed
1717

18-
For power consumption tests in this article, we used the following hardware & software. Note that there are many alternatives on the market.
18+
For the power consumption tests in this article, we used the following hardware & software. Note that there are many alternatives on the market.
1919

2020
- [nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-Desktop/Download)
2121
- [Power Profiler Kit II](https://www.nordicsemi.com/Products/Development-hardware/Power-Profiler-Kit-2)
@@ -24,35 +24,39 @@ For power consumption tests in this article, we used the following hardware & so
2424

2525
## Measuring Power Consumption
2626

27-
Power consumption measurements are done by connecting a power profiler between your Arduino and computer. The power profiler is connected to the computer via USB, and then to the Arduino via jumper wires. For power consumption measurements, we simply use two wires: **power** and **ground**. The power cable is connected to your Arduino's power pins, and ground goes to one of the GND pins on the board.
27+
Power consumption measurements are done by connecting a power profiler between your Arduino and computer. The power profiler is connected to the computer via USB, and then to the Arduino via jumper wires. For power consumption measurements, we simply use two wires: **power** and **ground**. The power cable is connected to your Arduino's power pins, and the ground cable goes to one of the GND pins on the board.
2828

29-
When it is connected, the power profiler can measure the power consumption of your board with a high accuracy. Any power that your board consumes can now be detected, and with a software tool (such as the [nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-Desktop/Download)), we can record power consumption over time.
29+
When connected, the power profiler can measure the power consumption of your board with high accuracy. Any power that your board consumes can now be detected, and with a software tool (such as the [nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-Desktop/Download)), we can record power consumption over time.
3030

3131
So what is it that we are measuring? In very simple terms, all electronic devices draw current, whether it is small or big. A small LED can for example draw 10 mA (0.01 A), while a servo motor can draw up towards 1000 mA (1 A). If you have an LED on for an hour that draws 10 mA, we can express it as **mAh**, which means **milli-ampers consumed per hour**.
3232

3333
### Power Consumption Example
3434

35-
To provide a practical example, let's take the [Nano ESP32](). We ran a simple sketch on the board, which continuously runs the `analogRead()` function. The test ran for 60 seconds, and recorded 100'000 samples. The result was an average of **31.05 mA**.
35+
To provide a practical example, let's take the [Nano ESP32](https://store.arduino.cc/products/nano-esp32) and run a simple sketch on the board, which continuously runs the `analogRead()` function. Running the test for 60 seconds recording 100'000 samples, results in an average consumption of **31.05 mA**.
3636

37-
Now, if we wanted to power this application using a battery, we know that the power consumption is 31.05 mA. If we intend to run the application with a fully re-charged 300 mAh battery, we would be able to run for approximately 9 hours, as we would be consuming **31.05 * 9 = 279.45**, according to the formula below:
37+
Now, if we wanted to power this application using a 300 mAh battery we need to calculate the time with the following formula:
3838

39-
- **milli-ampere hours (mAh) = power consumption * hours**
39+
![Formular](./assets/formula.png)
4040

4141
With that information, we can make an educated guess of what type of battery we should get. For example, a battery with more capacity, let's say 600 mAh, would in theory last for twice the period.
4242

43-
***Note that there are other factors at play, such as the battery's discharge rate and the general quality of the battery. The above formulas and measurements are to be considered guidelines.***
44-
43+
**_Note that there are other factors at play, such as the battery's discharge rate and the general quality of the battery. The above formulas and measurements are to be considered guidelines._**
4544

4645
## Software Setup
4746

48-
The software setup involves two steps: **upload a sketch** and **insatlling nRF Connect for Desktop**.
47+
The software setup involves two steps: **uploading a sketch** and **installing nRF Connect for Desktop**.
4948

5049
### Upload Sketch
5150

52-
This step is rather straightforward. Upload the sketch that you want to measure the power consumption of. Below is a minimal sketch that reads an analog pin continuously.
51+
This step is rather straightforward. Upload the sketch that you want to measure the power consumption of. Below is a minimal sketch that reads an analog pin continuously.
5352

5453
```arduino
54+
void setup() {}
5555
56+
void loop() {
57+
int analog_value = analogRead(A0);
58+
delay(1);
59+
}
5660
```
5761

5862
### Install Desktop App
@@ -63,12 +67,12 @@ To measure the power consumption, we are going to use the [nRF Connect for Deskt
6367

6468
The profiler we used is the [Power Profiler Kit II](https://www.nordicsemi.com/Products/Development-hardware/Power-Profiler-Kit-2).
6569

66-
1. First disconnect the USB cable from your board. You will be powering the board directly from the power profiler, so there's no need for the USB cable at this point.
70+
1. First, disconnect the USB cable from your board. You will be powering the board directly from the power profiler, so there's no need for the USB cable at this point.
6771
2. Use the provided cable from the kit, and connect it to your board's GND and power pin, following the illustration below:
6872

69-
![Connect the power profiler to the board.]()
73+
![Connect the power profiler to the board.](./assets/circuit.png)
7074

71-
***Important note! In the software setup you enable the "Power Output" of the power profiler. Make sure that the voltage (3.3 V or 5 V) matches the voltage on the power pin of the board. Applying 5 V to a 3.3 V pin will damage your board.***
75+
**_Important note! In the software setup, you enable the "Power Output" of the power profiler. Make sure that the voltage (3.3 V or 5 V) matches the voltage on the power pin of the board. Applying 5 V to a 3.3 V pin will damage your board._**
7276

7377
## Power Consumption Test
7478

@@ -77,17 +81,17 @@ With the hardware and software set up, let's take a look at how to record the po
7781
1. Open the **nRF Desktop App**
7882
2. instructions for setting up the PP
7983
3. Enable the power output, by clicking the "Enable Power Output" option.
80-
81-
![Enable power output.]()
84+
85+
![Enable power output.](./assets/powerOutput.png)
8286

8387
4. Select sample period (60 seconds) and number of samples (100k).
84-
5. Click on the "Begin Sampling" to start the power consumption test.
85-
86-
![Start sampling.]()
88+
5. Click on "Begin Sampling" to start the power consumption test.
89+
90+
![Start sampling.](./assets/startSampling.png)
8791

88-
6. During the test, you can see the power consumption in real-time. After 60 seconds (or when specified sample period ends), you will have the data, which includes the **max** and **avg** consumption. You can also zoom in to view the data.
89-
90-
![Power consumption data.]()
92+
6. During the test, you can see the power consumption in real-time. After 60 seconds (or when the specified sample period ends), you will have the data, which includes the **max** and **avg** consumption. You can also zoom in to view the data.
93+
94+
![Power consumption data.](./assets/consumption.png)
9195

9296
You have now recorded the power consumption of your device. You can note down the results, export it as a `.csv` or take a screenshot for future reference.
9397

@@ -100,9 +104,7 @@ In this section, you will find a number of tests we ran on a set of Arduino boar
100104
The simple analog read sketch continuously reads an analog pin.
101105

102106
```arduino
103-
void setup() {
104-
105-
}
107+
void setup() {}
106108
107109
void loop() {
108110
int analog_value = analogRead(A0);
@@ -118,13 +120,64 @@ In the table below, you can see the results of each board tested with the sketch
118120
| GIGA R1 WiFi | 51.02 mA | 94.08 mA | 58.05 mA |
119121
| Nano ESP32 | 29.18 mA | 46.58 mA | 31.05 mA |
120122

121-
122-
123123
### Arduino Cloud Basic
124124

125125
The **Arduino Cloud Basic** sketch sends sensor data to the Arduino Cloud, and turns on the built-in LED whenever activated from a dashboard.
126126

127127
```arduino
128+
/*
129+
Sketch generated by the Arduino IoT Cloud Thing "Cloud Blink"
130+
131+
Arduino IoT Cloud Variables description
132+
133+
The following variables are automatically generated and updated when changes are made to the Thing
134+
135+
bool led;
136+
137+
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
138+
which are called when their values are changed from the Dashboard.
139+
These functions are generated with the Thing and added at the end of this sketch.
140+
*/
141+
142+
#include "thingProperties.h"
143+
144+
void setup() {
145+
// Initialize serial and wait for port to open:
146+
Serial.begin(9600);
147+
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
148+
delay(1500);
149+
150+
// Defined in thingProperties.h
151+
initProperties();
152+
153+
// Connect to Arduino IoT Cloud
154+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
155+
156+
/*
157+
The following function allows you to obtain more information
158+
related to the state of network and IoT Cloud connection and errors
159+
the higher number the more granular information you’ll get.
160+
The default is 0 (only errors).
161+
Maximum is 4
162+
*/
163+
setDebugMessageLevel(2);
164+
ArduinoCloud.printDebugInfo();
165+
pinMode(LED_BUILTIN, OUTPUT);
166+
}
167+
168+
void loop() {
169+
ArduinoCloud.update();
170+
digitalWrite(LED_BUILTIN, led);
171+
}
172+
173+
/*
174+
Since Led is READ_WRITE variable, onLedChange() is
175+
executed every time a new value is received from IoT Cloud.
176+
*/
177+
void onLedChange() {
178+
Serial.print("Led status changed:");
179+
Serial.println(led);
180+
}
128181
129182
```
130183

@@ -138,5 +191,4 @@ In the table below, you can see the results of each board tested with the sketch
138191

139192
## Summary
140193

141-
In this guide we have learned how to use a power profiler to record power consumption data. This is an incredibly good utility, as it helps you identify the power needs of your application, which can aid your decision in selecting the right power source.
142-
194+
In this guide, we have learned how to use a power profiler to record power consumption data. This is an incredibly good utility, as it helps you identify the power needs of your application, which can aid your decision in selecting the right power source.

0 commit comments

Comments
 (0)