1
1
/*
2
2
This sketch demonstrates how to exchange data between your board and the Arduino IoT Cloud.
3
3
4
- Connect a potentiometer (or other analog sensor) to A1 and an LED to Digital Pin 5 .
5
- When the potentiometer (or sensor) value changes the data is sent to the Cloud.
6
- When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.
4
+ * Connect a potentiometer (or other analog sensor) to A0 .
5
+ * When the potentiometer (or sensor) value changes the data is sent to the Cloud.
6
+ * When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.
7
7
8
8
IMPORTANT:
9
- This sketch will work with WiFi, GSM and Lora enabled boards supported by Arduino IoT Cloud.
9
+ This sketch works with WiFi, GSM, NB and Lora enabled boards supported by Arduino IoT Cloud.
10
10
On a LoRa board, if it is configuered as a class A device (default and preferred option), values from Cloud dashboard are received
11
11
only after a value is sent to Cloud.
12
12
13
13
This sketch is compatible with:
14
14
- MKR 1000
15
15
- MKR WIFI 1010
16
16
- MKR GSM 1400
17
+ - MKR NB 1500
17
18
- MKR WAN 1300/1310
19
+ - ESP 8266
18
20
*/
21
+
19
22
#include " arduino_secrets.h"
20
23
#include " thingProperties.h"
21
24
22
25
void setup () {
23
-
24
- // Initialize serial and wait for port to open:
26
+ /* Initialize serial and wait up to 5 seconds for port to open */
25
27
Serial.begin (9600 );
26
- // wait up to 5 seconds for user to open Serial port
27
- unsigned long serialBeginTime = millis ();
28
- while (!Serial && (millis () - serialBeginTime > 5000 ));
28
+ for (unsigned long const serialBeginTime = millis (); !Serial && (millis () - serialBeginTime > 5000 ); ) { }
29
29
30
- Serial.println (" Starting Arduino IoT Cloud Example" );
30
+ /* Configure LED pin as an output */
31
+ pinMode (LED_BUILTIN, OUTPUT);
31
32
32
- // initProperties takes care of connecting your sketch variables to the ArduinoIoTCloud object
33
+ /* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
33
34
initProperties ();
34
- // tell ArduinoIoTCloud to use right connection handler
35
- ArduinoCloud.begin (ArduinoIoTPreferredConnection);
36
35
37
- /*
38
- The following function allows you to obtain more information
39
- related to the state of network and IoT Cloud connection and errors
40
- the higher number the more granular information you'll get.
41
- The default is 0 (only errors).
42
- Maximum is 3
36
+ /* Initialize Arduino IoT Cloud library */
37
+ ArduinoCloud.begin (ArduinoIoTPreferredConnection);
43
38
44
- setDebugMessageLevel(3);
45
- */
39
+ setDebugMessageLevel (DBG_INFO);
46
40
ArduinoCloud.printDebugInfo ();
47
41
}
48
42
@@ -52,8 +46,8 @@ void loop() {
52
46
}
53
47
54
48
/*
55
- this function is called when the "led" property of your Thing changes
56
- */
49
+ * 'onLedChange' is called when the "led" property of your Thing changes
50
+ */
57
51
void onLedChange () {
58
52
Serial.print (" LED set to " );
59
53
Serial.println (led);
0 commit comments