Environmental data in the Arduino Cloud

Learn how to collect environmental data from the MKR ENV Shield and display it in the Arduino Cloud.


In this tutorial, we will combine the functionality of the MKR WiFi 1010 and the MKR ENV Shield. The shield, mounted on top of the board, will record environmental data, such as temperature, humidity, pressure and illuminance. This data will be synced with the Arduino Cloud, a service that allows us to remotely control and monitor our devices.

This means that whenever we read data on the board, it will also be visible in the Cloud dashboard, where we can create different ways of visualizing the data.

Note: Newer versions of the MKR ENV Shield does not have the UV sensor component. You can read more about the different versions in this Arduino Help Center article.


The goals of this project are:

  • Configure the Arduino Cloud.
  • Create a program to read the sensors on the MKR ENV shield.
  • Read the data live in the Cloud dashboard.

Hardware & Software needed


Mount the shield.
Mount the shield.

Configuring the Cloud

This tutorial assumes you know the basics of the Arduino Cloud. If you are new check out our Getting Started Guide.

  • Create a Thing with the following variables:
NameData typePermission
temperaturefloatRead Only
humidityfloatRead Only
illuminancefloatRead Only
pressurefloatRead Only
uva*floatRead Only
uvb*floatRead Only
uvIndex*floatRead Only

Note: the

variables will only work with the MKR ENV Shield v1. Newer versions does not have the UV sensor. If you have a newer version, do not add these variables. You can read more about the different versions in the this Arduino Help Center article.

When we have added these, the variable list will look something like this:

full list of variables.
full list of variables.

  • Set up your MKR WiFi 1010 and configure your network credentials.

Creating the program

Now, the final thing needed is the actual program that will run on the MKR 1010 board. We can edit the program directly in the Arduino Cloud, by clicking on the "Sketch" tab. This will open up the built-in editor, where we can write the program directly.

The sketch tab.
The sketch tab.

For the program, we will need to include the Arduino_MKRENV library, which is used to read all the sensors. Below is the code that will allow us to do so, and you can see that the variables in the code is identical to the ones we just created.

Copy and paste the code below, and upload the program to the board, by clicking the upload button at the top of the editor.

Note: Newer versions of the MKR ENV Shield does not have the UV sensor component. You will need to remove the

functions in the program if you have a newer version.

1#include "thingProperties.h"
2#include <Arduino_MKRENV.h>
4void setup() {
5 // Initialize serial and wait for port to open:
6 Serial.begin(9600);
8 while(!Serial);
9 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
10 delay(1500);
12 // Defined in thingProperties.h
13 initProperties();
15 // Connect to Arduino Cloud
16 ArduinoCloud.begin(ArduinoIoTPreferredConnection);
18 /*
19 The following function allows you to obtain more information
20 related to the state of network and Cloud connection and errors
21 the higher number the more granular information you’ll get.
22 The default is 0 (only errors).
23 Maximum is 4
24 */
25 setDebugMessageLevel(2);
26 ArduinoCloud.printDebugInfo();
28 if (!ENV.begin()) {
29 Serial.println("Failed to initialize MKR ENV shield!");
30 while (1);
31 }
35void loop() {
36 ArduinoCloud.update();
37 // Your code here
38 temperature = ENV.readTemperature();
39 humidity = ENV.readHumidity();
40 pressure = ENV.readPressure();
41 illuminance = ENV.readIlluminance();
42 uva = ENV.readUVA(); //comment out if using a newer version of the ENV shield
43 uvb = ENV.readUVB(); //comment out if using a newer version of the ENV shield
44 uvIndex = ENV.readUVIndex(); //comment out if using a newer version of the ENV shield

Once the code has been uploaded, open the Serial Monitor (tab next to sketch) to initialize the program. If everything went well, it should like the image below:

Information regarding connection to network & Cloud.
Information regarding connection to network & Cloud.

The most important thing is that the two following commands are printed:

1Connected to "Network"
2Connect to the Arduino Cloud

Over the Air Uploads

Did you know that the Arduino Cloud supports over-the-air uploads? When you've uploaded a sketch to your board once, it will become available for you to upload a new sketch to the board without connecting it to your computer!

Over the Air uploads require an Entry plan to the Arduino Cloud. Read more about it here

To use this feature, make sure the board has power. If your board is already connected to the Cloud, you will be able to upload to it over the air. Navigate to the Things sketch tab in the Arduino Cloud interface, and you should see it being discovered just as if it was connected via USB.

Building a dashboard

Once we have confirmed that the board is connected to the Cloud, the last step is to build the dashboard that we can monitor the environmental data in. Click on the "Dashboards" tab, which will take you to the dashboards page. Here, we need to click on the "Build Dashboard" button.

Building a new dashboard.
Building a new dashboard.

We will now see an empty dashboard, where we are now going to create something called widgets. Widgets are the visual representation of our variables. There's two ways of creating widgets: either we add them one by one, and link them manually, or we can add and link them all at once. To save some time, let's do that!

Simply click on the "Add" button, and a dropdown menu will appear. Here we will click on "Things", and select the Thing that appears here.

Find and click on your Thing.
Find and click on your Thing.

In this case, we changed the name to Environmental Data, but whatever you name your thing will appear here. By clicking on it, it gives you a list of variables with a checkpoint, and we can simply click "Create widgets"

Generate widgets from the variables in your Thing.
Generate widgets from the variables in your Thing.

All new widgets will now appear here, and when the board is connected to the cload, it will continue to update these values.

The complete dashboard.
The complete dashboard.

Congratulations! You can now view your real time data directly in the dashboard.


In this tutorial, we demonstrated simply how a MKR WiFi 1010, a MKR ENV Shield and the Arduino Cloud is used to create a simple IoT application. This, without having to connect a single wire, or create a difficult program: the Cloud takes care of all of that.

You can now start thinking about how this application might work in real life. There are a lot of different things you can add to it, such as wind sensors (anemometers), rain sensors, CO2 sensors and much more. With some easy connections, you can build anything you want to, connect it to the Cloud and view all the data live from anywhere in the world!

More tutorials

You can find more tutorials in the Arduino Cloud documentation page.

Suggested changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.


The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.