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/02.variables/variables.md
+16-2
Original file line number
Diff line number
Diff line change
@@ -44,8 +44,6 @@ Inside a variable configuration, we have several options:
44
44
-**On Change:** variable synchronizes whenever value changes (threshold is `0` by default).
45
45
-**Periodically:** variable synchronizes every `x` seconds.
46
46
47
-
48
-
49
47
### Automatic Sketch Generation
50
48
51
49
Any variables you add will be automatically added to your [thingProperties](/arduino-cloud/cloud-interface/sketches#configuration-header-file) file, which contains any configurations made inside your Thing.
@@ -129,6 +127,22 @@ Whenever one variable updates, any variables added to the synchronisation will a
129
127
130
128
***For more details on this feature, check out the [Device to Device](https://docs.arduino.cc/arduino-cloud/features/device-to-device) tutorial.***
131
129
130
+
## Variable Lifecycle
131
+
132
+
Cloud variables are only synced with the Arduino Cloud during the **Synchronized** status.
133
+
When we are in a different state, any change to the variable is local and will be overridden by the Arduino Cloud value as soon as it gets Synchronized.
134
+
135
+
A variable can be in any of the following stages:
136
+
137
+
-**Disconnected** - The variable has the local value. Any modification to the value will be overridden once Synchronized.
138
+
-**Connecting** - The variable has the local value. Any modification to the value will be overridden once Synchronized.
139
+
-**Connected** - The variable has the local value. Any modification to the value will be overridden once Synchronized.
140
+
-**Synchronized** - The variable is synced with the Cloud.
141
+
- If the value is changed locally, it is populated to the Cloud.
142
+
- If the value is changed in the Cloud via a dashboard or variable sync, the local value is updated (only for **Read Write** variables).
143
+
144
+
***For callbacks & events depending on what status the variable is in, check out the [Events & Callbacks](/arduino-cloud/api/c-library#events--callbacks) section.***
145
+
132
146
## Cloud Variable List
133
147
134
148
Cloud variables are divided into three categories: **basic, specialized** and **complex** types. Below you will find all available variables that you can create.
Copy file name to clipboardExpand all lines: content/arduino-cloud/07.api/03.c-library/c-library.md
+44-2
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,48 @@ The documentation lives in the [ArduinoIoTCloud](https://github.com/arduino-libr
38
38
39
39
Most of its functions are already pre-configured in your sketch files, so for most use cases you will not need to explore the API. Functions for connecting to, and syncing data with the Arduino Cloud is handled automatically, and will be generated into your sketch files in the web environment.
40
40
41
-
## Arduino IDE
41
+
## Arduino IDE (Offline)
42
42
43
-
This library can be used with the offline version of the Arduino IDE (download through the [Arduino Downloads Page](https://www.arduino.cc/en/software/)). You can program your devices offline and monitor them via the cloud, but your Thing configuration is not synchronized if you do so.
43
+
This library can be used with the offline version of the Arduino IDE (download through the [Arduino Downloads Page](https://www.arduino.cc/en/software/)). You can program your devices offline and monitor them via the cloud, but your Thing configuration is not synchronized if you do so.
44
+
45
+
To use it offline, you will manually need to install the following libraries in the Arduino IDE:
Arduino Cloud has support for events and callbacks. This can be used to trigger specific functionalities depending on what state your device is in.
52
+
53
+
You can for example trigger a specific block of code whenever the board is in a **connecting**, **synchronized** or **disconnected** state. In this document, we will explore how to set it up, using an example from the [ArduinoIoTCloud](https://github.com/arduino-libraries/ArduinoIoTCloud/blob/master/examples/ArduinoIoTCloud-Callbacks/ArduinoIoTCloud-Callbacks.ino) library.
54
+
55
+
### Events
56
+
57
+
The `ArduinoIoTCloudEvent` enumeration class has three possible events:
58
+
-`CONNECT` (0) - Board successfully connects to IoT Cloud.
59
+
-`SYNC` (1) - Data is successfully synced between Board and IoT Cloud.
60
+
-`DISCONNECT` (2) - Board has lost connection to IoT Cloud.
61
+
62
+
The `CONNECT` and `DISCONNECT` events can occur even though no variable is created inside the Thing. However, `SYNC` requires a variable to be created, as this triggers whenever data is synchronized between the board and cloud.
63
+
64
+
These events can be subscribed to using the `addCallback()` function, which is documented in the next section.
65
+
66
+
### Callbacks
67
+
68
+
Callbacks can be added for each event, and essentially triggers a custom function whenever the event occurs.
69
+
70
+
Callbacks are added via the `addCallback()` method from the `ArduinoIoTCloud` class, where the **event** and **custom function** are added as parameters.
0 commit comments