Skip to content

Commit 24a32ca

Browse files
authored
Merge pull request #903 from arduino/karlsoderby/multi-chart-widget
Advanced Chart Widget Docs
2 parents c253ca6 + 21f6042 commit 24a32ca

File tree

8 files changed

+151
-0
lines changed

8 files changed

+151
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
---
2+
title: Multiple Variable Chart Widget
3+
description: Learn how to use the advanced chart widget, which allows you to track several variables in real time or during a specific time period.
4+
author: Karl Söderby
5+
tags: [IoT Cloud, Charts, Data Plotting]
6+
---
7+
8+
The **advanced chart widget** is used to display data from several IoT Cloud variables in a single chart. You can track the data in both real time, select from a specific time period while selecting the variables you want to display.
9+
10+
![The advanced chart widget.](assets/advanced-chart.gif)
11+
12+
This widget can be added onto existing projects (if you are already tracking data), and is particularly interesting to use in projects such as:
13+
- Weather stations,
14+
- Environmental data tracking,
15+
- Energy consumption,
16+
- Various science projects where data comparison is needed.
17+
18+
This widget can use variables from **different Things**, so you can monitor data from various devices and plot it all in one place.
19+
20+
For example, you could set up a series of sensors around a city, and measure the CO2 emissions from your phone or laptop in a single chart!
21+
22+
## Hardware & Software Needed
23+
24+
- [Arduino IoT Cloud](https://create.arduino.cc/iot/).
25+
- Cloud compatible boards, [see full list](https://docs.arduino.cc/arduino-cloud/getting-started/iot-cloud-getting-started#compatible-hardware).
26+
27+
***In this tutorial, we use the [MKR WiFi 1010](/hardware/mkr-wifi-1010) and [MKR ENV Shield](/hardware/mkr-env-shield) for recording environmental values. This is not a requirement, you can use any board for this tutorial.***
28+
29+
## Setup & Configuration
30+
31+
To use the advanced widget, you will need to set up a Thing and some variables that you want to track. We choose to set up and track:
32+
- `temperature`
33+
- `humidity`
34+
- `pressure`
35+
- `light`
36+
37+
***If you are unfamiliar with how to set up a Thing and variables, head on over to the [Getting Started with the Arduino IoT Cloud](/arduino-cloud/getting-started/iot-cloud-getting-started) article.***
38+
39+
**1.** Head on over to the **"Dashboards"** in the Arduino IoT Cloud, and create a new dashboard (or use an existing dashboard).
40+
41+
**2.** Add a new **"Advanced Chart Widget"**, selecting it from the list of available widgets.
42+
43+
**3.** Link the variables you want to compare. In this case, we are using `temperature`, `humidity`, `pressure` and `light`.
44+
45+
![Link variables.](assets/select-variables.png)
46+
47+
>You can use up to a maximum of 5 variables.
48+
49+
**4.** After selection, your variables will appear in the right panel, with a number of configuration options. You can for example choose how each data point will be represented (line, spline, spline area, line area and bar).
50+
51+
![Advanced chart widget configuration.](assets/widget-config.png)
52+
53+
**5.** Click on **"Done"** when finished selecting the variables. If your board is connected and is sending data to the cloud, you will see the widget's data update frequently.
54+
55+
## Example Code
56+
57+
The sketch of your project does not require much complexity. In your automatically generated code, simply add the sensor reading code inside of the loop. We are using the [Arduino_MKRENV](https://www.arduino.cc/reference/en/libraries/arduino_mkrenv/) library, and we only needed to add these following lines to the loop to read all sensors:
58+
59+
```arduino
60+
temperature = ENV.readTemperature();
61+
humidity = ENV.readHumidity();
62+
pressure = ENV.readPressure();
63+
light = ENV.readIlluminance();
64+
```
65+
66+
The full sketch used is found below:
67+
68+
```arduino
69+
#include <Arduino_MKRENV.h>
70+
71+
#include "thingProperties.h"
72+
73+
void setup() {
74+
// Initialize serial and wait for port to open:
75+
Serial.begin(9600);
76+
77+
if (!ENV.begin()) {
78+
while (1);
79+
}
80+
81+
delay(1500);
82+
83+
initProperties();
84+
85+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
86+
87+
setDebugMessageLevel(2);
88+
ArduinoCloud.printDebugInfo();
89+
}
90+
91+
void loop() {
92+
ArduinoCloud.update();
93+
94+
temperature = ENV.readTemperature();
95+
humidity = ENV.readHumidity();
96+
pressure = ENV.readPressure();
97+
light = ENV.readIlluminance();
98+
99+
}
100+
```
101+
102+
## Usage
103+
104+
With the widget set up, let's explore some of its features.
105+
106+
### Toggle Variables
107+
108+
You can enable or disable to variables you want to display by simply clicking the name of the variable.
109+
110+
![Toggle variables.](assets/advanced-chart-toggle.gif)
111+
112+
### Value Tracking
113+
114+
Hover over a line to see what the value of a variable was in a specific point in time. In this case, we choose to check only the temperature and the humidity.
115+
116+
![View values.](assets/advanced-chart.gif)
117+
118+
### Specific Time Period
119+
120+
To see a specific time period, click on the calendar icon, where you can select the starting & end time & date.
121+
122+
![Select time & date.](assets/select-time-date.png)
123+
124+
As an example, the widget below shows the illuminance (LUX) recorded via the **MKR ENV Shield**, the `light` variable.
125+
126+
Here, we can see that sunset occurred around 18.00 (6PM), and sunrise sometime around 07.00 (7AM).
127+
128+
![Light tracking.](assets/light-tracking.png)
129+
130+
## Limitations
131+
132+
The following variables are not supported in the advanced chart widget.
133+
134+
- Character String
135+
- Schedule
136+
- Location
137+
- Color
138+
- Custom Variable
139+
- Colored Light
140+
- Dimmed Light
141+
- Contact Sensor
142+
- Motion Sensor
143+
- Television
144+
- Boolean
145+
- Light
146+
- Smart Plug
147+
- Switch
148+
149+
## Summary
150+
151+
The advanced chart widget can be used for **any** project that includes data monitoring. It is perfect for scientific projects when monitoring & comparing data over time is needed.
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)