Skip to content

Commit ee24a1b

Browse files
committed
feat: ArduinoIoTCloudNotecard
1 parent 6ef7ad8 commit ee24a1b

33 files changed

+1045
-81
lines changed

.github/workflows/compile-examples.yml

+2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ jobs:
192192
- name: arduino:mbed_opta
193193
libraries: |
194194
- name: ArduinoECCX08
195+
- name: Blues Wireless Notecard
195196
sketch-paths: |
196197
- examples/ArduinoIoTCloud-DeferredOTA
198+
- examples/ArduinoIoTCloud-Notecard
197199
- examples/utility/Provisioning
198200
# GIGA
199201
- board:

README.md

+20-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,28 @@
1010
### What?
1111
The `ArduinoIoTCloud` library is the central element of the firmware enabling certain Arduino boards to connect to the [Arduino IoT Cloud](https://www.arduino.cc/en/IoT/HomePage). The following boards are supported:
1212

13-
* **WiFi**: [`MKR 1000`](https://store.arduino.cc/arduino-mkr1000-wifi), [`MKR WiFi 1010`](https://store.arduino.cc/arduino-mkr-wifi-1010), [`Nano 33 IoT`](https://store.arduino.cc/arduino-nano-33-iot), [`Portenta H7`](https://store.arduino.cc/portenta-h7), [`Nano RP2040 Connect`](https://store.arduino.cc/products/arduino-nano-rp2040-connect), [`Nicla Vision`](https://store.arduino.cc/products/nicla-vision), [`OPTA WiFi`](https://store.arduino.cc/products/opta-wifi), [`GIGA R1 WiFi`](https://store.arduino.cc/products/giga-r1-wifi), [`Portenta C33`](https://store.arduino.cc/products/portenta-c33), [`UNO R4 WiFi`](https://store.arduino.cc/products/uno-r4-wifi), [`Nano ESP32`](https://store.arduino.cc/products/nano-esp32), [`ESP8266`](https://github.com/esp8266/Arduino/releases/tag/2.5.0), [`ESP32`](https://github.com/espressif/arduino-esp32/releases/tag/2.0.5)
14-
* **GSM**: [`MKR GSM 1400`](https://store.arduino.cc/arduino-mkr-gsm-1400-1415)
13+
* **Wi-Fi**: [`MKR 1000`](https://store.arduino.cc/arduino-mkr1000-wifi), [`MKR WiFi 1010`](https://store.arduino.cc/arduino-mkr-wifi-1010), [`Nano 33 IoT`](https://store.arduino.cc/arduino-nano-33-iot), [`Portenta H7`](https://store.arduino.cc/portenta-h7), [`Nano RP2040 Connect`](https://store.arduino.cc/products/arduino-nano-rp2040-connect), [`Nicla Vision`](https://store.arduino.cc/products/nicla-vision), [`OPTA WiFi`](https://store.arduino.cc/products/opta-wifi), [`GIGA R1 WiFi`](https://store.arduino.cc/products/giga-r1-wifi), [`Portenta C33`](https://store.arduino.cc/products/portenta-c33), [`UNO R4 WiFi`](https://store.arduino.cc/products/uno-r4-wifi), [`Nano ESP32`](https://store.arduino.cc/products/nano-esp32), [`ESP8266`](https://github.com/esp8266/Arduino/releases/tag/2.5.0), [`ESP32`](https://github.com/espressif/arduino-esp32/releases/tag/2.0.5), [`Notecard`](https://shop.blues.com/collections/notecard)
14+
* **GSM**: [`MKR GSM 1400`](https://store.arduino.cc/arduino-mkr-gsm-1400-1415), [`Notecard`](https://shop.blues.com/collections/notecard)
15+
* **LTE**: [`Notecard`](https://shop.blues.com/collections/notecard)
1516
* **5G**: [`MKR NB 1500`](https://store.arduino.cc/arduino-mkr-nb-1500-1413)
16-
* **LoRa**: [`MKR WAN 1300/1310`](https://store.arduino.cc/mkr-wan-1310)
17+
* **LoRa**: [`MKR WAN 1300/1310`](https://store.arduino.cc/mkr-wan-1310), [`Notecard`](https://shop.blues.com/collections/notecard)
1718
* **Ethernet**: [`Portenta H7`](https://store.arduino.cc/products/portenta-h7) + [`Vision Shield Ethernet`](https://store.arduino.cc/products/arduino-portenta-vision-shield-ethernet), [`Max Carrier`](https://store.arduino.cc/products/portenta-max-carrier), [`Breakout`](https://store.arduino.cc/products/arduino-portenta-breakout), [`Portenta Machine Control`](https://store.arduino.cc/products/arduino-portenta-machine-control), [`OPTA WiFi`](https://store.arduino.cc/products/opta-wifi), [`OPTA RS485`](https://store.arduino.cc/products/opta-rs485), [`OPTA Lite`](https://store.arduino.cc/products/opta-lite), [`Portenta C33`](https://store.arduino.cc/products/portenta-c33) + [`Vision Shield Ethernet`](https://store.arduino.cc/products/arduino-portenta-vision-shield-ethernet)
19+
* **Satellite**: [`Notecard`](https://shop.blues.com/collections/notecard)
20+
21+
#### More About Notecard Connectivity
22+
23+
The Notecard is a wireless, secure abstraction for device connectivity, that can
24+
be used to enable _ANY*_ device with I2C, or UART, to connect to the Arduino IoT
25+
Cloud via cellular, LoRa, satellite or Wi-Fi (including the devices listed
26+
above)!
27+
28+
As a result, the STM32 architecture has now been added to this library. If you
29+
have an STM32 device, you are now able to connect it to the Arduino IoT Cloud by
30+
using a Notecard to provide a secure communication channel.
31+
32+
> \*_Unfortunately, the AVR architecture is not supported by the Arduino IoT
33+
> Cloud library. Therefore, those devices are ineligible for use with the
34+
> Notecard._
1835
1936
### How?
2037
1) Register your Arduino IoT Cloud capable board via [Arduino IoT Cloud](https://create.arduino.cc/iot) (Devices Section).

examples/ArduinoIoTCloud-Advanced/ArduinoIoTCloud-Advanced.ino

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.
33
44
IMPORTANT:
5-
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
5+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
66
On a LoRa board, if it is configured as a class A device (default and preferred option),
77
values from Cloud dashboard are received only after a value is sent to Cloud.
88
@@ -17,13 +17,15 @@ void setup() {
1717
Serial.begin(9600);
1818
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }
1919

20+
/* Specify the level of detail for debug messages */
21+
setDebugMessageLevel(DBG_INFO);
22+
2023
/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
2124
initProperties();
2225

2326
/* Initialize Arduino IoT Cloud library */
2427
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
2528

26-
setDebugMessageLevel(DBG_INFO);
2729
ArduinoCloud.printDebugInfo();
2830
}
2931

examples/ArduinoIoTCloud-Advanced/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

examples/ArduinoIoTCloud-Advanced/thingProperties.h

+20-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -11,6 +11,18 @@
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

14+
#if defined(BOARD_HAS_LORA)
15+
#define THING_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
16+
#endif
17+
18+
#if defined(USE_NOTECARD)
19+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
20+
* or UART. An empty string (or the default value provided below) will not
21+
* override the Notecard's existing configuration.
22+
* Learn more at: https://dev.blues.io */
23+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
24+
#endif
25+
1426
void onSwitchButtonChange();
1527
void onColorChange();
1628

@@ -23,7 +35,10 @@ void initProperties() {
2335
ArduinoCloud.setBoardId(BOARD_ID);
2436
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2537
#endif
26-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
38+
#if defined(BOARD_HAS_LORA)
39+
ArduinoCloud.setThingId(THING_ID);
40+
#endif
41+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
2742
ArduinoCloud.addProperty(switchButton, Permission::Write).onUpdate(onSwitchButtonChange);
2843
ArduinoCloud.addProperty(location, Permission::Read).publishOnChange(0.0f);
2944
ArduinoCloud.addProperty(color, Permission::ReadWrite).onUpdate(onColorChange);
@@ -34,7 +49,9 @@ void initProperties() {
3449
#endif
3550
}
3651

37-
#if defined(BOARD_HAS_WIFI)
52+
#if defined(USE_NOTECARD)
53+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
54+
#elif defined(BOARD_HAS_WIFI)
3855
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
3956
#elif defined(BOARD_HAS_GSM)
4057
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);

examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.
77
88
IMPORTANT:
9-
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
9+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
1010
On a LoRa board, if it is configured as a class A device (default and preferred option),
1111
values from Cloud dashboard are received only after a value is sent to Cloud.
1212
@@ -25,6 +25,9 @@ void setup() {
2525
Serial.begin(9600);
2626
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }
2727

28+
/* Specify the level of detail for debug messages */
29+
setDebugMessageLevel(DBG_INFO);
30+
2831
/* Configure LED pin as an output */
2932
pinMode(LED_BUILTIN, OUTPUT);
3033

@@ -34,7 +37,6 @@ void setup() {
3437
/* Initialize Arduino IoT Cloud library */
3538
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
3639

37-
setDebugMessageLevel(DBG_INFO);
3840
ArduinoCloud.printDebugInfo();
3941
}
4042

examples/ArduinoIoTCloud-Basic/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

examples/ArduinoIoTCloud-Basic/thingProperties.h

+20-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -11,6 +11,18 @@
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

14+
#if defined(BOARD_HAS_LORA)
15+
#define THING_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
16+
#endif
17+
18+
#if defined(USE_NOTECARD)
19+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
20+
* or UART. An empty string (or the default value provided below) will not
21+
* override the Notecard's existing configuration.
22+
* Learn more at: https://dev.blues.io */
23+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
24+
#endif
25+
1426
void onLedChange();
1527

1628
bool led;
@@ -22,18 +34,23 @@ void initProperties() {
2234
ArduinoCloud.setBoardId(BOARD_ID);
2335
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2436
#endif
37+
#if defined(BOARD_HAS_LORA)
38+
ArduinoCloud.setThingId(THING_ID);
39+
#endif
2540
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
2641
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
2742
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
2843
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);
29-
#elif defined(BOARD_HAS_LORA)
44+
#elif defined(USE_NOTECARD) || defined(BOARD_HAS_LORA)
3045
ArduinoCloud.addProperty(led, 1, Permission::ReadWrite).onUpdate(onLedChange);
3146
ArduinoCloud.addProperty(potentiometer, 2, Permission::Read).publishOnChange(10);
3247
ArduinoCloud.addProperty(seconds, 3, Permission::Read).publishEvery(5 * MINUTES);
3348
#endif
3449
}
3550

36-
#if defined(BOARD_HAS_ETHERNET)
51+
#if defined(USE_NOTECARD)
52+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
53+
#elif defined(BOARD_HAS_ETHERNET)
3754
/* DHCP mode */
3855
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
3956
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */

examples/ArduinoIoTCloud-Callbacks/ArduinoIoTCloud-Callbacks.ino

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
One function per event can be assigned.
1919
2020
IMPORTANT:
21-
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
21+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
2222
On a LoRa board, if it is configured as a class A device (default and preferred option),
2323
values from Cloud dashboard are received only after a value is sent to Cloud.
2424
@@ -33,6 +33,9 @@ void setup() {
3333
Serial.begin(9600);
3434
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }
3535

36+
/* Specify the level of detail for debug messages */
37+
setDebugMessageLevel(DBG_INFO);
38+
3639
/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
3740
initProperties();
3841

@@ -51,7 +54,6 @@ void setup() {
5154
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::SYNC, doThisOnSync);
5255
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::DISCONNECT, doThisOnDisconnect);
5356

54-
setDebugMessageLevel(DBG_INFO);
5557
ArduinoCloud.printDebugInfo();
5658
}
5759

examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

examples/ArduinoIoTCloud-Callbacks/thingProperties.h

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -11,14 +11,31 @@
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

14+
#if defined(BOARD_HAS_LORA)
15+
#define THING_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
16+
#endif
17+
18+
#if defined(USE_NOTECARD)
19+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
20+
* or UART. An empty string (or the default value provided below) will not
21+
* override the Notecard's existing configuration.
22+
* Learn more at: https://dev.blues.io */
23+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
24+
#endif
25+
1426
void initProperties() {
1527
#if defined(BOARD_HAS_SECRET_KEY)
1628
ArduinoCloud.setBoardId(BOARD_ID);
1729
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
1830
#endif
31+
#if defined(BOARD_HAS_LORA)
32+
ArduinoCloud.setThingId(THING_ID);
33+
#endif
1934
}
2035

21-
#if defined(BOARD_HAS_WIFI)
36+
#if defined(USE_NOTECARD)
37+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
38+
#elif defined(BOARD_HAS_WIFI)
2239
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
2340
#elif defined(BOARD_HAS_GSM)
2441
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);

examples/ArduinoIoTCloud-DeferredOTA/ArduinoIoTCloud-DeferredOTA.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ void setup() {
5858
Serial.begin(9600);
5959
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }
6060

61+
/* Specify the level of detail for debug messages */
62+
setDebugMessageLevel(DBG_INFO);
63+
6164
/* Configure LED pin as an output */
6265
pinMode(LED_BUILTIN, OUTPUT);
6366

@@ -70,7 +73,6 @@ void setup() {
7073
/* Setup OTA callback */
7174
ArduinoCloud.onOTARequestCb(onOTARequestCallback);
7275

73-
setDebugMessageLevel(DBG_INFO);
7476
ArduinoCloud.printDebugInfo();
7577
}
7678

examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
This sketch demonstrates how to exchange data between your board and the Arduino IoT Cloud.
3+
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+
8+
IMPORTANT:
9+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
10+
On a LoRa board, if it is configured as a class A device (default and preferred option),
11+
values from Cloud dashboard are received only after a value is sent to Cloud.
12+
13+
The full list of compatible boards can be found here:
14+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
15+
*/
16+
17+
#include <Notecard.h>
18+
#include "thingProperties.h"
19+
20+
#if !defined(LED_BUILTIN) && !defined(ARDUINO_NANO_ESP32)
21+
static int const LED_BUILTIN = 2;
22+
#endif
23+
24+
/*
25+
* Choose an interrupt capable pin to reduce polling and improve
26+
* the overall responsiveness of the ArduinoIoTCloud library
27+
*/
28+
// #define ATTN_PIN 9
29+
30+
void setup() {
31+
/* Initialize serial and wait up to 5 seconds for port to open */
32+
Serial.begin(9600);
33+
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }
34+
35+
/* Specify the level of detail for debug messages */
36+
setDebugMessageLevel(DBG_INFO);
37+
38+
/* Configure LED pin as an output */
39+
pinMode(LED_BUILTIN, OUTPUT);
40+
41+
/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
42+
initProperties();
43+
44+
/* Initialize Arduino IoT Cloud library */
45+
#ifndef ATTN_PIN
46+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
47+
ArduinoCloud.setNotecardPollingInterval(3000); // default: 1000ms, min: 250ms
48+
#else
49+
ArduinoCloud.begin(ArduinoIoTPreferredConnection, ATTN_PIN);
50+
#endif
51+
52+
ArduinoCloud.printDebugInfo();
53+
}
54+
55+
void loop() {
56+
ArduinoCloud.update();
57+
potentiometer = analogRead(A0);
58+
seconds = millis() / 1000;
59+
}
60+
61+
/*
62+
* 'onLedChange' is called when the "led" property of your Thing changes
63+
*/
64+
void onLedChange() {
65+
Serial.print("LED set to ");
66+
Serial.println(led);
67+
digitalWrite(LED_BUILTIN, led);
68+
}

0 commit comments

Comments
 (0)