You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -34,183 +34,87 @@ The goals of this project are:
34
34
35
35

36
36
37
-
## Step 1: Setting up the Arduino IoT Cloud
37
+
## Overview
38
38
39
-
To do so, we will first need to configure our MKR 1010 device in the Arduino IoT Cloud. Let's start by navigating to the <ahref="https://create.arduino.cc/iot/"target="_blank">Arduino IoT Cloud</a>.
39
+
In this guide we will:
40
+
- Configure a manual device in the Arduino Cloud,
41
+
- install the Arduino IoT Cloud Python library,
42
+
- write a Python script that connects to the Arduino Cloud.
40
43
41
-
>**Note:** You will need a Arduino account to use the Arduino IoT Cloud. If you do not have one, you will be directed to the account registration.
44
+
## Requirements
42
45
43
-
### Configure a new device
46
+
To follow this guide, make sure to have:
44
47
45
-
Once we are in the Arduino IoT Cloud, we will need to click on the **"Devices"** tab. This will open a new page which will ask you to add a new device. Click on the **"Add device"** button.
48
+
- An [Arduino account](https://login.arduino.cc/login),
49
+
- a version of [Python](https://www.python.org/downloads/) installed,
- A code editor (we recommend [VSCode](https://code.visualstudio.com/) with the Python extension installed).
46
53
47
-

54
+
***The experience with Python and the `pip` package mangager varies depending on your computer and operating system. Python needs to be in your PATH to use the Arduino IoT Cloud Python client.***
48
55
49
-
You will now have an option of either configuring a new Arduino device, or a third party device. Select the **"Set up an Arduino device** option.
56
+
## Cloud Setup
50
57
51
-

58
+
To set up the Arduino Cloud, follow the steps below. In there, we will
59
+
- create and configure a device,
60
+
- create a Thing,
61
+
- create cloud variables.
52
62
53
-
At this point, you will need to connect your cloud compatible board to your computer. You will also need to have installed the Arduino Create Agent. If if it is not installed, the set up wizard will ask you to install it. Your device should now show up, and you will need to click on the **"Configure"**
54
-
button.
55
63
56
-

64
+
### Device Configuration
57
65
58
-
You will now be asked to name your device. In this case, a name was randomly generated, which is **Phil**. Click on **"Next"** to proceed.
66
+
To configure a device, navigate to the [app.arduino.cc/devices](app.arduino.cc/devices) and click on the **"create a new device"** button. Connect your board to your computer, and make sure you have the [Create Agent](https://create.arduino.cc/getting-started/plugin/welcome) installed. Your board will appear, and the installation takes a couple of minutes.
59
67
60
-

68
+
***Learn more about Devices in the [Devices documentation]().***
61
69
62
-
After clicking on next, the board will start to configure. This process may take a few minutes.
1. Create a new Thing, by clicking on the **"Create Thing"** button.
73
+
2. Click on the **"Select Device"** in the **"Associated Devices"** section of your Thing. Your previously configured device will appear from the list.
74
+
3. In the network section, enter your network credentials.
65
75
66
-
Once it is done, we will be directed to the devices page, where we can see our device. Congratulations, you have just made your first device IoT ready!
76
+
***Learn more about Things in the [Things documentation]().***
Next step is to create some cloud variables, which we will later sync with our Arduino MKR WiFi 1010 board.
71
81
72
-
After our device is configured, we can move on to the next step: creating our very first Thing. Click on the **"Things"**tab. You should now see a button that says **"Create thing"**, which we will need to click.
82
+
While in Thing configuration, click on **"Add Variable"**which will open a new window. Add the following variables with the specified configurations:
73
83
74
-

84
+
| Variable Name | Data Type | Permission |
85
+
| ------------- | --------- | ------------ |
86
+
|`relay_1`| Boolean | Read & Write |
87
+
|`relay_2`| Boolean | Read & Write |
75
88
76
-
We will now see an interface with multiple options. This is your Thing configuration overview. Here we can select what network we are connecting to, what device we are using and create variables that we want to sync.
89
+
Your Thing interface should now look something like this:
77
90
78
-

91
+
![]()
79
92
80
-
Let's start by linking our freshly configured device, by clicking on the **"Select Device"** button to the right. This will open up a window, where we can **"Associate"** the board with this Thing.
93
+
***Need help understanding cloud variables? Check out the [Variables]() section.***
81
94
82
-

95
+
### Create Sketch
83
96
84
-
### Creating variables
85
-
86
-
Now, we can continue to create **variables** for our Thing. These variables will be synced with the cloud, as long as the board is connected to Internet and the cloud.
87
-
88
-
For this application, we will create two **boolean** variables: one for each relay on the MKR Relay Shield.
89
-
90
-
To create a new variable, click on the **"Add Variable"** button.
Let's name it **relay_1**, and select the **boolean** data type. Then click on **"Add Variable"**.
95
-
96
-

97
-
98
-
Let's add another variable, but let's name this one **relay_2**, which is also a boolean variable.
99
-
100
-

101
-
102
-
Great, now we have two **boolean variables** named **relay_1** and **relay_2**.
103
-
104
-
### Adding your network details
105
-
106
-
Now that we have created the variables, we can configure the **network details**. This is done by clicking on the **"Configure"** button in the **"Network"** section.
>**Note:** You can't enter any network details until you have added a variable.
111
-
112
-
113
-
### Over the Air Uploads
114
-
115
-
Did you know that the Arduino IoT 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!
116
-
117
-
***Over the Air uploads require an Entry plan to the Arduino IoT Cloud***
118
-
119
-
120
-
To use this feature, make sure the board has power. If your board is already connected to the IoT Cloud, you will be able to upload to it over the air. Navigate to the Things sketch tab in the Arduino IoT Cloud interface, and you should see it being discovered just as if it was connected via USB.
121
-
122
-
123
-
### Creating the program
124
-
125
-
Once we are finished with all the configurations, we can move on to creating the sketch that we are going to upload to our MKR WiFi 1010. To do so, we first need to go to the **"Sketch"** tab.
126
-
127
-

128
-
129
-
The sketch we are going to create is very simple. As most of the code is already generated through the configurations we made, we only need to make a few additions: configuring the relay pins as output, and creating two conditionals.
130
-
131
-
You can find the full sketch below, which we need to upload to our board.
97
+
After your device & Thing is configured, you can program your board. Navigate to the **"Sketch"** tab inside your Thing, where you can compile & upload your programs. You will find the sketch for this application in the code snippet below:
132
98
133
99
```arduino
134
-
#include "thingProperties.h"
135
-
136
-
void setup() {
137
-
// Initialize serial and wait for port to open:
138
-
Serial.begin(9600);
139
-
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
The following function allows you to obtain more information
153
-
related to the state of network and IoT Cloud connection and errors
154
-
the higher number the more granular information you’ll get.
155
-
The default is 0 (only errors).
156
-
Maximum is 4
157
-
*/
158
-
setDebugMessageLevel(2);
159
-
ArduinoCloud.printDebugInfo();
160
-
}
161
-
162
-
void loop() {
163
-
ArduinoCloud.update();
164
-
// Your code here
165
-
166
-
}
167
-
168
-
void onRelay1Change() {
169
-
// Do something
170
-
if(relay_1){
171
-
digitalWrite(1, LOW);
172
-
}
173
-
else{
174
-
digitalWrite(1, HIGH);
175
-
}
176
-
}
177
-
178
-
void onRelay2Change() {
179
-
// Do something
180
-
if(relay_2){
181
-
digitalWrite(2, LOW);
182
-
}
183
-
else{
184
-
digitalWrite(2, HIGH);
185
-
}
186
-
}
187
-
```
188
-
189
-
## Step 2: Creating a dashboard
190
-
191
-
After our code has been successfully uploaded to our board, we we will need to create a dashboard to control our relays!
192
100
193
-
Head over to the **"Dashboards"** tab, and click on **"Build Dashboard"**.
194
-
195
-

196
-
197
-
We can now see an empty dashboard. Let's click on the **"Add"** button, and select a **Switch** widget.
101
+
```
198
102
199
-

103
+
Upload this sketch to your board, and your board will start attempting to connect to the Arduino Cloud and sync its data.
200
104
201
-
Now, we need to link it with our **relay_1** variable, inside our Thing.
105
+
You can verify that your device is connecting properly, by checking the Serial Monitor just after connection. Error codes are printed here.
202
106
203
-

107
+
### Create a Dashboard
204
108
205
-
We also need to rename the widget so we know which one is which. We choose **"RELAY_1"**.
109
+
Once you have your device running a sketch and syncing with the Arduino Cloud, you can create a **dashboard**, a visualization tool for monitoring & interacting with your board.
206
110
207
-

111
+
Navigate to [app.arduino.cc/dashboard](app.arduino.cc/dashboard) and create a dashboard. Add two switches (or any other preferred widgets), and link them to each `relay_x` variable that we created earlier. These switches will be directly linked with your Arduino MKR WiFi 1010's variables, and will turn ON/OFF the relays on your board.
208
112
209
-
Now, repeat the same process, but instead link it to the **relay_2** variable. At the end, we should have two widgets, each linked to a relay.
113
+
You can also access your dashboard via the [Arduino IoT Remote app]().
Now you can simply test it out by turning ON or OFF the switches. You should hear the relays on your **MKR Relay Shield** making clicking noises. That means it is working!
117
+
***For more information on dashboards, available widgets and how to link them to your sketch, visit the [Dashboard & Widgets]() section.***
214
118
215
119
## Step 3: Connecting a component with higher voltage
0 commit comments