Skip to content

Commit f91baa9

Browse files
committed
Proofreading
1 parent 8de9d03 commit f91baa9

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

content/arduino-cloud/01.getting-started/06.cloud-variables/cloud-variables.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ difficulty: beginner
88

99
## Overview
1010

11-
An essential component of the [Arduino Cloud](https://create.arduino.cc/iot/) is a **cloud variable**. A cloud variable is the same as a regular variable that you use in an Arduino sketch, but with some additional functionality.
11+
An essential component of the [Arduino Cloud](https://create.arduino.cc/iot/) is a **cloud variable**.
1212

13-
A cloud variable is synced between your Arduino board and the Arduino Cloud. So if a variable is updated on your board (like a sensor reading), the Arduino Cloud will also receive this value. Similarly, if you update a variable from the cloud, it also updates on your board.
13+
A cloud variable is synced between your Arduino board and the Arduino IoT Cloud. If a variable is updated on your board (like reading a sensor), the Arduino Cloud will also receive this value. Similarly, if you update a variable from the cloud, it also updates on your board.
1414

15-
This means that at any given time, you are able to read and send data to and from your board, as long as your board is connected to the Arduino IoT Cloud.
15+
As long as your board maintains connection to the Arduino IoT Cloud, variables can be updated.
1616

1717
**In this article, we will cover:**
1818
- How to sync variables between your board and the Arduino IoT Cloud.
19-
- What variables are available to use.
19+
- Types of variables and list of available ones.
2020
- How to structure a sketch for optimal variable synchronization.
2121
- How to synchronize variables between devices.
2222

2323
## Create and Configure Variables
2424

25-
Creating and configuring variables are done inside **Thing**, starting with the **"Add Variable"** button.
25+
Creating and configuring variables are done inside a **Thing**, starting with the **"Add Variable"** button.
2626

2727
![Click on "Add Variable"](assets/add-vars.png)
2828

@@ -50,19 +50,19 @@ Whenever you add, change or remove a variable, a file called `thingProperties.h`
5050

5151
Since it is defined in `thingProperties.h`, you do not need to declare it in your `.ino` file.
5252

53-
Let's say we create a integer variable called `sensor_value`. To use this in a sketch, to for example read a sensor, we can use:
53+
Let's say we create an integer variable called `sensor_value`. To use this in a sketch, we simply use:
5454

5555
```arduino
5656
sensor_value = analogRead(A0);
5757
```
5858

59-
Note that we do not need to define the variable anywhere, as it has already been configured in `thingProperties.h`.
59+
We do not need to define the variable anywhere, as it has already been configured in `thingProperties.h`.
6060

6161
***Note that if you change a variable, you will need to upload the code to your board for the effects to come in change.***
6262

6363
### Generated Functions
6464

65-
When creating a variable with a **Read & Write** permission, a function is also generated in your sketch.
65+
When creating a variable with a **Read & Write** permission, a function is generated at the bottom of your sketch.
6666

6767
For example, a boolean variable named `button_switch` will generate a function called `void onButtonSwitch(){}`. This function executes every time the variable is changed from the cloud (through a dashboard).
6868

@@ -85,9 +85,7 @@ Data between a board and the cloud synchronizes whenever the `ArduinoCloud.updat
8585

8686
It is a good practice to **not** use the `delay()` function in a cloud sketch. Please refer to the [millis()](https://www.arduino.cc/reference/en/language/functions/time/millis/) function that can be used to create non-blocking delays.
8787

88-
A variable's sync between a board and the cloud is limited to **two message per second (500ms)**.
89-
90-
Below is an example on how to use the `millis()` function.
88+
Below is an example on how to use the `millis()` function:
9189

9290
```arduino
9391
unsigned long previousMillis = 0;
@@ -104,23 +102,29 @@ void loop(){
104102
previousMillis = currentMillis;
105103
106104
//code here will update every 1 second
107-
//without blocking the program (and cloud update)
105+
//without blocking the program and the cloud update
108106
}
109107
110108
```
111109

112-
## Sync Variables Between Things
110+
***Note that a variable's sync between a board and the cloud is limited to two message per second (500ms)***
111+
112+
### Sync Variables Between Things
113113

114114
It is possible to sync one or many variables with each other, between Things. This is the easiest method available to connect two Arduino board devices, wirelessly.
115115

116116
This is done in the configuration of a variable, in the **Sync With Other Things** option.
117117

118-
***To learn how to use this feature, read the [Device to Device]() tutorial.***
118+
***To learn how to use this feature, read the [Device to Device](https://docscontent-karlsoderbyvariablesarticle.gtsb.io/arduino-cloud/features/device-to-device) tutorial.***
119119

120120
## List of Variables
121121

122+
Cloud variables are divided into three categories: **basic, specialized** and **complex** types.
123+
122124
### Basic Types
123125

126+
All available basic variables are listed below:
127+
124128
| Type | Declaration |
125129
| --------------------- | ---------------------- |
126130
| Boolean | `bool variableName;` |
@@ -131,7 +135,7 @@ This is done in the configuration of a variable, in the **Sync With Other Things
131135

132136
### Specialized Types
133137

134-
For your convenience, IoT Cloud provides specialized types which are just wrappers around basic types but declare the variable semantics more explicitly. This enables smarter integrations with third-party services (such as Alexa) and better visualization of widgets in dashboards.
138+
Specialized types are wrappers around basic types but declare the variable semantics more explicitly. This enables smarter integrations with third-party services (such as Alexa) and better visualization of widgets in dashboards.
135139

136140
You can use them just like a normal variable of the wrapped type, since they support assignment and comparison operators.
137141

@@ -485,4 +489,12 @@ void onTvChange() {
485489
}
486490
}
487491
488-
```
492+
```
493+
494+
## Summary
495+
496+
In this article, we have covered how to use variables in the Arduino IoT Cloud, and what variables are available.
497+
498+
We have also shown some code examples and good practices to keep variable synchronization optimal, such as using the `millis()` function.
499+
500+
The use of cloud variables is almost identical to how you use variables in a regular sketch, with the exception that they are synchronized with the Arduino IoT Cloud.

0 commit comments

Comments
 (0)