11/*
22 This sketch demonstrates how to exchange data between your board and the Arduino IoT Cloud.
33
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.
77
88 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.
1010 On a LoRa board, if it is configuered as a class A device (default and preferred option), values from Cloud dashboard are received
1111 only after a value is sent to Cloud.
1212
1313 This sketch is compatible with:
1414 - MKR 1000
1515 - MKR WIFI 1010
1616 - MKR GSM 1400
17+ - MKR NB 1500
1718 - MKR WAN 1300/1310
19+ - ESP 8266
1820*/
21+
1922#include " arduino_secrets.h"
2023#include " thingProperties.h"
2124
2225void setup () {
23-
24- // Initialize serial and wait for port to open:
26+ /* Initialize serial and wait up to 5 seconds for port to open */
2527 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 ); ) { }
2929
30- Serial.println (" Starting Arduino IoT Cloud Example" );
30+ /* Configure LED pin as an output */
31+ pinMode (LED_BUILTIN, OUTPUT);
3132
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 */
3334 initProperties ();
34- // tell ArduinoIoTCloud to use right connection handler
35- ArduinoCloud.begin (ArduinoIoTPreferredConnection);
3635
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);
4338
44- setDebugMessageLevel(3);
45- */
39+ setDebugMessageLevel (DBG_INFO);
4640 ArduinoCloud.printDebugInfo ();
4741}
4842
@@ -52,8 +46,8 @@ void loop() {
5246}
5347
5448/*
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+ */
5751void onLedChange () {
5852 Serial.print (" LED set to " );
5953 Serial.println (led);
0 commit comments