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
Copy file name to clipboardExpand all lines: content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,15 @@ A sketch is a file where we write programs to run on our Arduino boards. Sketche
9
9
10
10
The Arduino Cloud has two categories of sketches:
11
11
-**Regular sketch** - a single `.ino` file where you write a program. These sketches can be used for **any** Arduino board.
12
-
-**IoT Sketch** - a set of files that are automatically generated when creating a [Thing](/arduino-cloud/cloud-interface/things). This includes a`.ino` file, and two header (`.h`) files that contains your Thing configuration + credentials. Only available for boards with IoT support.
12
+
-**IoT Sketch** - a set of files that are automatically generated when creating a [Thing](/arduino-cloud/cloud-interface/things). This includes an`.ino` file and two header (`.h`) files that contain your Thing configuration + credentials. Only available for boards with IoT support.
13
13
14
14
In this document we will take a look at how to use sketches in the Arduino Cloud environment.
15
15
16
-
***If you need help getting started with programming your Arduino in the online environment, check out the [Cloud Editor](/arduino-cloud/guides/cloud-editor) tutorial.
16
+
***If you need help getting started with programming your Arduino in the online environment, check out the [Cloud Editor](/arduino-cloud/guides/cloud-editor) tutorial.***
17
17
18
18
## Access Your Sketches
19
19
20
-
You can access all your sketches at [app.arduino.cc/sketches](app.arduino.cc/sketches), where you can easily select between your regular sketches, and IoT sketches.
20
+
You can access all your sketches at [app.arduino.cc/sketches](https://app.arduino.cc/sketches), where you can easily select between your regular sketches and IoT sketches.
21
21
22
22

23
23
@@ -27,7 +27,7 @@ Clicking on each sketch will direct you to the [Cloud Editor](https://create.ard
27
27
28
28
## Regular Sketches
29
29
30
-
A regular sketch in the Arduino Cloud are exactly like sketches used in the [Arduino IDE](/software/ide-v2), with no difference whatsoever. You can take a sketch from the online IDE and compile it in the offline IDE.
30
+
A regular sketch in the Arduino Cloud is exactly like a sketch used in the [Arduino IDE](/software/ide-v2), with no difference whatsoever. You can take a sketch from the online IDE and compile it in the offline IDE.
31
31
32
32
A regular sketch only has two minimum requirements: the inclusion of the `void loop()` and `void setup()` functions, which are required for any Arduino sketch.
33
33
@@ -47,18 +47,18 @@ For specific features of a board, make sure to check out the [hardware documenta
47
47
48
48
## IoT Sketches
49
49
50
-
IoT sketches are more complex, and are generated automatically when you create a Thing and variables.
50
+
IoT sketches are more complex and are generated automatically when you create a Thing and variables.
51
51
52
52
***Read more about this in the [Automatic Sketch Generation](/arduino-cloud/cloud-interface/sketches) documentation.***
53
53
54
54
### Sketch File
55
55
56
-
This sketch file is generated with a set of additional cloudspecific methods included, the essentials being:
56
+
The sketch file is generated with a set of additional cloud-specific methods included, the essentials being:
57
57
-`initProperties()` - initializes properties/variables from your Thing.
58
58
-`ArduinoCloud.begin()` starts the library with the preferred connection (e.g. Wi-Fi® or LoRaWAN®).
59
-
-`ArduinoCloud.update()` - synchronizing all data between board and Arduino Cloud
59
+
-`ArduinoCloud.update()` - synchronizes all data between the board and the Arduino Cloud.
60
60
61
-
In addition, any variables created with a read/write permission will also generate a callback function that executes whenever the variable's value changes.
61
+
In addition, any variable created with a read/write permission will also generate a callback function that executes whenever the variable's value changes.
62
62
- If you create a variable called `test`, the function will render as `void onTestChange(){}`
63
63
64
64
Below is an example of how a default sketch looks like:
@@ -96,17 +96,17 @@ void onTestChange(){
96
96
The `thingProperties.h` file is a non-editable file that updates based on changes made in your Thing. For example:
97
97
98
98
- Creating a variable will add it to this file, along with parameters such as permission, update policy, variable type etc.
99
-
- Changing from a Wi-Fi® device to LoRa® device will update the **connection method** stored in this file,
99
+
- Changing from a Wi-Fi® device to a LoRa® device will update the **connection method** stored in this file,
100
100
101
101
The file cannot be edited in the Arduino Cloud as it is in sync with the platform and changes frequently.
102
102
103
103
### Secret File
104
104
105
105
The "Secret" File contains your secret credentials, such as Wi-Fi® network SSID/PASS or device secret key.
106
106
107
-
This file will be visible as a "Secret" tab in the Cloud Editor, and is named `arduino_secrets.h`, which is not visible in the cloud platform.
107
+
This file will be visible as a "Secret" tab in the Cloud Editor and is named `arduino_secrets.h`, which is not visible on the cloud platform.
108
108
109
-
Note that if you are using the offline IDE / Arduino CLI instead, you will manually need to create this file. More information in the **Offline Sketches section** just below.
109
+
Note that if you are using the offline IDE / Arduino CLI, you will need to manually create this file. More information is in the **Offline Sketches section** just below.
The `loop()` function includes the `ArduinoCloud.update();` call, which sends data to the cloud and receives updates. In order to get the best responsiveness in your cloud-connected projects, the `loop()` function should run as fast as possible. This means that no blocking commands should be used inside, and you should prefer a non-blocking programming approach whenever possible.
147
+
The `loop()` function includes the `ArduinoCloud.update();` call, which sends data to the cloud and receives updates. To get the best responsiveness in your cloud-connected projects, the `loop()` function should run as fast as possible. This means that no blocking commands should be used inside, and you should prefer a non-blocking programming approach whenever possible.
148
148
149
149
A common **blocking pattern** is the use of the `delay()` function which stops the execution of the function for the given time. We strongly advise to **get rid of this function** and achieve the same behavior in a non-blocking way with the `millis()` function as described below.
150
150
151
-
Let's see how to blink a LED. The traditional way involves the `delay()` function:
151
+
Let's see how to blink an LED. The traditional way involves the `delay()` function:
152
152
153
153
```arduino
154
154
void loop() {
@@ -179,7 +179,7 @@ For a more complex and commented example, you can have a look at the [BlinkWitho
179
179
180
180
### I2C Usage
181
181
182
-
Components connected via I²C (including the sensors onboard the [MKR IoT Carrier](https://store.arduino.cc/products/arduino-mkr-iot-carrier)) uses the same bus as the **ECCX08**cryptochip. As the crypto chip is an essential part of establishing a connection to the IoT Cloud (it contains the credentials), it is important that other I²C peripherals are initialized after the connection has been made.
182
+
Components connected via I²C (including the sensors onboard the [MKR IoT Carrier](https://store.arduino.cc/products/arduino-mkr-iot-carrier)) uses the same bus as the **ECCX08**crypto chip. As the crypto chip is an essential part of establishing a connection to the IoT Cloud (it contains the credentials), it is important that other I²C peripherals are initialized after the connection has been made.
183
183
184
184
For example, if you are initializing a library such as [Arduino_MKRENV](https://www.arduino.cc/reference/en/libraries/arduino_mkrenv), your `setup()` should be implemented as:
185
185
@@ -199,19 +199,20 @@ void setup() {
199
199
Serial.println("Failed to initialize MKR ENV shield!");
200
200
while (1);
201
201
}
202
+
}
202
203
```
203
204
204
205
205
206
### Avoid Blocking Serial Communication
206
207
207
208
`while(!Serial) {}` loops endlessly until the Serial Monitor is opened. This is a useful practice in cases where you want to see all debug output from the start of the sketch execution. However, when building IoT systems using **`while(!Serial){}` can hinder our project from running autonomously**, stopping the board from connecting to the network and IoT Cloud before manually opening the Serial Monitor. Therefore, it is recommended to consider removing the `while(!Serial){}` loop if it's not necessary.
208
209
209
-
A common trick is to add a **`delay(1500);` command after `Serial.begin(9600);`**. This will slightly slow down the initialization of your device, but will give you some time to open the serial monitor when you're interested in seeing its output within losing the very first lines.
210
+
A common trick is to add a **`delay(1500);` command after `Serial.begin(9600);`**. This will slightly slow down the initialization of your device but will give you some time to open the serial monitor when you're interested in seeing its output without losing the very first lines.
210
211
211
212
## Create Agent
212
213
213
214
The [Arduino Create Agent](https://github.com/arduino/arduino-create-agent) is a single binary that will appear on the menu bar and work in the background. It allows you to use the Arduino IoT Cloud and the Arduino Web Editor to seamlessly upload code to any board directly from the browser.
214
215
215
-
Downloading and installing the Arduino Create Agent plugin can be simply done following [this quick and easy process](https://create.arduino.cc/getting-started/plugin/welcome).
216
+
Downloading and installing the Arduino Create Agent plugin can be done following [this quick and easy process](https://create.arduino.cc/getting-started/plugin/welcome).
216
217
217
218
The full documentation of the [Arduino Create Agent is available here](https://github.com/arduino/arduino-create-agent#readme) for more advanced usage.
Copy file name to clipboardExpand all lines: content/arduino-cloud/03.cloud-interface/01.things/things.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,12 +12,12 @@ In the Thing interface you can:
12
12
- select the main device you want to associate with,
13
13
- enter network credentials (such as Wi-Fi network/password),
14
14
- edit & upload sketches to your board,
15
-
- set webhooks that trigger whenever data changes.
15
+
- set webhooks that trigger whenever data changes,
16
16
- edit the timezone.
17
17
18
18
## Thing Interface
19
19
20
-
The Thing interface is designed for ease-of-use, and only has a few sections, which we will now go through.
20
+
The Thing interface is designed for ease-of-use and only has a few sections, which we will now go through.
21
21
22
22

23
23
@@ -32,7 +32,7 @@ Below you will find more details on each of the sections.
32
32
33
33
## Variables
34
34
35
-
The variables section is where you create **"Cloud Variables"**, a variable that exist in the Arduino Cloud as well as on your board/setup, and are synchronised continuously. You can configure a variable to be:
35
+
The variables section is where you create **"Cloud Variables"**, a variable that exist in the Arduino Cloud as well as on your board/setup, and is synchronized continuously. You can configure a variable to be:
36
36
-**Read/Write** - you can interact with the variable from a dashboard,
37
37
-**Read Only** - you can only read data from the board.
38
38
@@ -48,18 +48,18 @@ temperature = sensor.readTemperature();
48
48
49
49
There are a large number of variables available, including basic types such as `int`, `boolean` & `String`, but also complex types that hold multiple values, such as the `ColoredLight` variable.
50
50
51
-
Variables of the same type can also be synchronised across all devices. This is done when creating a new variable, where you check the variables you want to sync with.
51
+
Variables of the same type can also be synchronized across all devices. This is done when creating a new variable, where you check the variables you want to sync with.
52
52
53
-
***All variables are listed out in the [Variables](/arduino-cloud/cloud-interface/variables) section. See [Variable Synchronization](/arduino-cloud/cloud-interface/variables#variable-synchronisation) for linking together your devices' variables.***
53
+
***All variables are listed in the [Variables](/arduino-cloud/cloud-interface/variables) section. See [Variable Synchronization](/arduino-cloud/cloud-interface/variables#variable-synchronisation) for linking together your devices' variables.***
54
54
55
55
## Device
56
56
57
-
In the device section you can select either a previously configured device, or configure a new one. Associating a device means your device and Thing are now linked indefinitely, until you decide to detach them.
57
+
In the device section, you can select either a previously configured device, or configure a new one. Associating a device means your device and Thing are now linked indefinitely until you decide to detach them.
58
58
59
59
You can connect one of the following devices:
60
60
-[Arduino Wi-Fi® devices](/arduino-cloud/hardware/wifi) - official Arduino devices with a Wi-Fi® enabled module.
61
61
-[Arduino LoRaWAN® devices](/arduino-cloud/hardware/lora) - official Arduino devices with a LoRaWAN® module.
62
-
-[Thirdparty ESP32/ESP8266 devices](/arduino-cloud/hardware/wifi) - third party devices with an ESP32/ESP8266 SoC.
62
+
-[Third-party ESP32/ESP8266 devices](/arduino-cloud/hardware/wifi) - third party devices with an ESP32/ESP8266 SoC.
63
63
-[Manual devices](/arduino-cloud/hardware/devices#manual-devices) - a virtual device using MicroPython, Python or JavaScript. These devices do not have a sketch associated.
64
64
65
65
The status of your device is also displayed in this section (online/offline).
@@ -68,11 +68,11 @@ The status of your device is also displayed in this section (online/offline).
68
68
69
69
## Network
70
70
71
-
In the network section, you configure the credentials for your network, such as your Wi-Fi® network, secret key (for ESP32 boards) and other credentials for e.g. LoRaWAN® & cellular. The network details are securely stored.
71
+
In the network section, you configure the credentials for your network, such as your Wi-Fi® network, secret key (for ESP32 boards) and other credentials e.g. LoRaWAN® & cellular. The network details are securely stored.
The credentials entered are automatically included in your sketch (see automatic sketch generation just below).
75
+
The credentials entered are automatically included in your sketch (see [automatic sketch generation](#automatic-sketch-generation)).
76
76
77
77
## Sketch
78
78
@@ -95,7 +95,7 @@ The editor includes all cores for official Arduino boards, and over 6000+ librar
95
95
96
96
## Metadata
97
97
98
-
In the metadata tab you will find your **Thing ID**, **Timezone** configuration, timestamp data (creation/last modified). Here you can also create tags
98
+
In the metadata tab, you will find your **Thing ID**, **Timezone** configuration, timestamp data (creation/last modified). Here you can also create tags.
99
99
100
100
### Thing ID
101
101
@@ -109,7 +109,7 @@ This ID is used when connecting with the [REST API](/arduino-cloud/api/arduino-i
109
109
110
110
### Timezone
111
111
112
-
You can choose your timezone through a dropdown menu in the metadata tab, which includes many cities from the Americas, Europe, Asia, Africa, Oceania, Atlantic, Pacific and even Antarctica.
112
+
You can choose your timezone through a dropdown menu in the metadata tab, which includes many cities in America, Europe, Asia, Africa, Oceania, Atlantic, Pacific and even Antarctica.
113
113
114
114
This is particularly important when using the [scheduler](/arduino-cloud/features/cloud-scheduler) feature to trigger events at specific times.
115
115
@@ -121,14 +121,14 @@ Tags are used to organize and filter your Things. In a setup with many devices a
121
121
122
122
## Automatic Sketch Generation
123
123
124
-
Things based on Arduino / C++ (the default way) benefits from **automatic sketch generation**. Whenever any configuration is done in your Thing, the changes are reflected in your sketch files.
124
+
Things based on Arduino / C++ (the default way) benefit from **automatic sketch generation**. Whenever the configuration is done in your Thing, the changes are reflected in your sketch files.
125
125
126
126
For example:
127
-
- Associating a Wi-Fi board will automatically update the connection method,
128
-
-creating a variable will add it to your `thingProperties.h` file,
129
-
-creating a variable with **read/write** permission will also add a callback function at the bottom of your sketch. This will trigger anytime the value changes.
130
-
-changing your network credentials will update the `arduino_secrets.h` file.
127
+
- Associating a Wi-Fi board will automatically update the connection method.
128
+
-Creating a variable will add it to your `thingProperties.h` file.
129
+
-Creating a variable with **read/write** permission will also add a callback function at the bottom of your sketch. This will trigger any time the value changes.
130
+
-Changing your network credentials will update the `arduino_secrets.h` file.
131
131
132
-
This is implemented so that the connection and synchronisation between the board and cloud is handled automatically, meaning you do not need to do any networking code when using the Arduino / C++ language.
132
+
This is implemented so that the connection and synchronization between the board and cloud is handled automatically, meaning you do not need to do any networking code when using the Arduino / C++ language.
133
133
134
134
***Please note that if you are using an offline environment, [Arduino IDE](/software/ide-v2), changes will only be made in the cloud environment and will manually need to be adjusted. If you plan on using the offline IDE, you make use of the [sketch synchronisation](/software/ide-v2/tutorials/ide-v2-cloud-sketch-sync) feature that allows you to push/pull your cloud sketches from the offline IDE.***
0 commit comments