Skip to content

moved hacking to retired #1733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bee5593
Create power-consumption.md
karlsoderby Jan 22, 2024
7319319
Update power-consumption.md
karlsoderby Jan 22, 2024
12c3f3b
Update power-consumption.md
karlsoderby Jan 25, 2024
2273ef0
Update power-consumption.md
karlsoderby Jan 25, 2024
e21f46b
Portenta C33 User Manual Pinout link fix
mcmchris Jan 25, 2024
33e4d5b
Difficulty metadata added to H7 family
mcmchris Jan 25, 2024
b10a03f
Lot of broken links fixed
mcmchris Jan 25, 2024
fd6154f
Portenta X8 related fixes
mcmchris Jan 26, 2024
61e1024
Update
karlsoderby Jan 29, 2024
226c0dc
Hat Carrier User Manual Links fix
mcmchris Jan 29, 2024
7a821ee
Max Carrier broken link library
mcmchris Jan 29, 2024
4376a41
Cat.M1 shield tutorial difficulty
mcmchris Jan 29, 2024
3c3ee54
LoRa trademarks on tech specs
mcmchris Jan 29, 2024
72cf9d1
Link fix (#1717)
jcarolinares Jan 29, 2024
2f299c1
Jcarolinares/wisgate firmware fix (#1719)
jcarolinares Jan 29, 2024
deb181f
Initial commit - Portenta Hat Carrier docs bash patch
TaddyHC Jan 30, 2024
b049772
Portenta Max Carrier code bash patch
TaddyHC Jan 30, 2024
6c2ff1c
Portenta X8 code bash patch and Hat Carrier
TaddyHC Jan 30, 2024
1d065c7
Portenta H7, Nicla and Opta code bash patch
TaddyHC Jan 30, 2024
84c3dff
PMC and PLC IDE code bash patch
TaddyHC Jan 30, 2024
6bde3b0
Update examples
karlsoderby Jan 30, 2024
f5c782b
Merge pull request #1714 from arduino/karlsoderby/giga-cs-rtc-ntp
karlsoderby Jan 30, 2024
8de2988
updated folder structure
jhansson-ard Jan 30, 2024
6af352a
Merge pull request #1722 from arduino/jhansson-ard/uno-wifi-folder
jacobhylen Jan 30, 2024
849076f
Update getting-started.md
karlsoderby Jan 31, 2024
de55dcb
Trying conflict solve
mcmchris Jan 31, 2024
2f46125
Merge branch 'main' into mcmchris/docs-2/maintenance
mcmchris Jan 31, 2024
e80df55
Merge pull request #1712 from arduino/mcmchris/docs-2/maintenance
mcmchris Jan 31, 2024
887018c
Update cheat-sheet.md
karlsoderby Jan 31, 2024
ddd10c2
[EC-313] Update Getting Started - Cloud for Education
g-castronovo Jan 31, 2024
a249722
Merge branch 'main' into taddy/portenta-bash-snippet-update
TaddyHC Feb 1, 2024
81071f0
Apply suggestions from code review
g-castronovo Feb 1, 2024
db15183
change image
g-castronovo Feb 1, 2024
654b566
Update content.md
g-castronovo Feb 1, 2024
dc08692
Update content.md
g-castronovo Feb 1, 2024
16a9bbc
Update content.md
g-castronovo Feb 1, 2024
363d9ab
[PC-1603] Docs 2.0 + Content Fixes - Nicla related changes (#1718)
mcmchris Feb 1, 2024
bfdb206
last updates
g-castronovo Feb 1, 2024
995af6d
Update content/arduino-cloud/10.education/00.arduino-cloud-for-educat…
g-castronovo Feb 1, 2024
22cdfd7
Update content/arduino-cloud/10.education/00.arduino-cloud-for-educat…
g-castronovo Feb 1, 2024
1c80ca7
Merge pull request #1726 from arduino/sync/g-castronovo/EC-313-update…
g-castronovo Feb 1, 2024
d9a4d6d
Update content.md
g-castronovo Feb 1, 2024
01984cb
add assets
Hannes7eicher Feb 1, 2024
b8ab453
minor fixes
Hannes7eicher Feb 1, 2024
e8d834e
Merge pull request #1709 from arduino/karlsoderby/learn-power-consump…
Hannes7eicher Feb 1, 2024
5fadb19
Merge pull request #1727 from arduino/g-castronovo/-typo--getting-sta…
g-castronovo Feb 1, 2024
83087c8
Merge pull request #1720 from arduino/taddy/portenta-bash-snippet-update
TaddyHC Feb 1, 2024
b5a8660
Merge pull request #1723 from arduino/karlsoderby/gds-pc-test
karlsoderby Feb 2, 2024
c09e900
Merge pull request #1724 from arduino/karlsoderby/esp32-default-sketch
karlsoderby Feb 2, 2024
bac3766
Unlist Power Consumption Aricle
Hannes7eicher Feb 2, 2024
bded490
Merge pull request #1730 from arduino/Hannes7eicher/Power-Consumption…
Hannes7eicher Feb 2, 2024
5e5e8d9
moved hacking to retired
jhansson-ard Feb 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
194 changes: 194 additions & 0 deletions content/_unlisted/11.power-consumption/power-consumption.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
---
title: "Power Consumption on Arduino Boards"
description: "Learn about measuring power consumption on an Arduino board."
tags: [Power Consumption]
author: "Karl Söderby"
---

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.

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.

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.

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

## Hardware & Software Needed

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

- [nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-Desktop/Download)
- [Power Profiler Kit II](https://www.nordicsemi.com/Products/Development-hardware/Power-Profiler-Kit-2)
- [Arduino board (link to store)](https://store.arduino.cc/)
- Jumper wires

## Measuring Power Consumption

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

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.

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**.

### Power Consumption Example

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**.

Now, if we wanted to power this application using a 300 mAh battery we need to calculate the time with the following formula:

![Formular](./assets/formula.png)

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.

**_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._**

## Software Setup

The software setup involves two steps: **uploading a sketch** and **installing nRF Connect for Desktop**.

### Upload Sketch

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.

```arduino
void setup() {}

void loop() {
int analog_value = analogRead(A0);
delay(1);
}
```

### Install Desktop App

To measure the power consumption, we are going to use the [nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-Desktop/Download) tool. This is a program that you install on your computer.

## Hardware Setup

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

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.
2. Use the provided cable from the kit, and connect it to your board's GND and power pin, following the illustration below:

![Connect the power profiler to the board.](./assets/circuit.png)

**_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._**

## Power Consumption Test

With the hardware and software set up, let's take a look at how to record the power consumption of your device.

1. Open the **nRF Desktop App**
2. instructions for setting up the PP
3. Enable the power output, by clicking the "Enable Power Output" option.

![Enable power output.](./assets/powerOutput.png)

4. Select sample period (60 seconds) and number of samples (100k).
5. Click on "Begin Sampling" to start the power consumption test.

![Start sampling.](./assets/startSampling.png)

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.

![Power consumption data.](./assets/consumption.png)

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.

## Example Results

In this section, you will find a number of tests we ran on a set of Arduino boards during different conditions.

### Simple Analog Read

The simple analog read sketch continuously reads an analog pin.

```arduino
void setup() {}

void loop() {
int analog_value = analogRead(A0);
delay(1);
}
```

In the table below, you can see the results of each board tested with the sketch:

| Board | Min | Max | Average |
| ------------ | -------- | --------- | -------- |
| UNO R4 WiFi | 82.86 mA | 124.04 mA | 92.63 mA |
| GIGA R1 WiFi | 51.02 mA | 94.08 mA | 58.05 mA |
| Nano ESP32 | 29.18 mA | 46.58 mA | 31.05 mA |

### Arduino Cloud Basic

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

```arduino
/*
Sketch generated by the Arduino IoT Cloud Thing "Cloud Blink"

Arduino IoT Cloud Variables description

The following variables are automatically generated and updated when changes are made to the Thing

bool led;

Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);

// Defined in thingProperties.h
initProperties();

// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
ArduinoCloud.update();
digitalWrite(LED_BUILTIN, led);
}

/*
Since Led is READ_WRITE variable, onLedChange() is
executed every time a new value is received from IoT Cloud.
*/
void onLedChange() {
Serial.print("Led status changed:");
Serial.println(led);
}

```

In the table below, you can see the results of each board tested with the sketch:

| Board | Min | Max | Average |
| ------------ | --------- | --------- | --------- |
| UNO R4 WiFi | 94.07 mA | 513.70 mA | 140.19 mA |
| GIGA R1 WiFi | 121.00 mA | 477.44 mA | 139.83 mA |
| Nano ESP32 | 36.70 mA | 274.19 mA | 58.81 mA |

## Summary

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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Loading