Skip to content

Commit bea9db5

Browse files
committed
feat: ArduinoIoTCloudNotecard
1 parent 12e9def commit bea9db5

25 files changed

+884
-56
lines changed

.github/workflows/compile-examples.yml

Lines changed: 2 additions & 0 deletions
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

Lines changed: 20 additions & 3 deletions
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/thingProperties.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
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+
1418
void onSwitchButtonChange();
1519
void onColorChange();
1620

@@ -23,6 +27,9 @@ void initProperties() {
2327
ArduinoCloud.setBoardId(BOARD_ID);
2428
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2529
#endif
30+
#if defined(BOARD_HAS_LORA)
31+
ArduinoCloud.setThingId(THING_ID);
32+
#endif
2633
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
2734
ArduinoCloud.addProperty(switchButton, Permission::Write).onUpdate(onSwitchButtonChange);
2835
ArduinoCloud.addProperty(location, Permission::Read).publishOnChange(0.0f);

examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/thingProperties.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
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+
1418
void onLedChange();
1519

1620
bool led;
@@ -22,6 +26,9 @@ void initProperties() {
2226
ArduinoCloud.setBoardId(BOARD_ID);
2327
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2428
#endif
29+
#if defined(BOARD_HAS_LORA)
30+
ArduinoCloud.setThingId(THING_ID);
31+
#endif
2532
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
2633
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
2734
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);

examples/ArduinoIoTCloud-Callbacks/ArduinoIoTCloud-Callbacks.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/thingProperties.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +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+
1418
void initProperties() {
1519
#if defined(BOARD_HAS_SECRET_KEY)
1620
ArduinoCloud.setBoardId(BOARD_ID);
1721
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
1822
#endif
23+
#if defined(BOARD_HAS_LORA)
24+
ArduinoCloud.setThingId(THING_ID);
25+
#endif
1926
}
2027

2128
#if defined(BOARD_HAS_WIFI)

examples/ArduinoIoTCloud-DeferredOTA/ArduinoIoTCloud-DeferredOTA.ino

Lines changed: 3 additions & 1 deletion
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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
This sketch demonstrates how to exchange data between your board and the
3+
Arduino IoT Cloud, while using the Notecard for wireless communication.
4+
5+
* Connect a potentiometer (or other analog sensor) to A0.
6+
* When the potentiometer (or sensor) value changes the data is sent to the Cloud.
7+
* When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.
8+
9+
IMPORTANT:
10+
This sketch works with any Wi-Fi, Cellular, LoRa or Satellite enabled Notecard.
11+
12+
The full list of compatible boards can be found here:
13+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
14+
*/
15+
16+
#include <Notecard.h>
17+
#include "thingProperties.h"
18+
19+
#if !defined(LED_BUILTIN) && !defined(ARDUINO_NANO_ESP32)
20+
static int const LED_BUILTIN = 2;
21+
#endif
22+
23+
/*
24+
* Choose an interrupt capable pin to reduce polling and improve
25+
* the overall responsiveness of the ArduinoIoTCloud library
26+
*/
27+
// #define ATTN_PIN 9
28+
29+
void setup() {
30+
/* Initialize serial and wait up to 5 seconds for port to open */
31+
Serial.begin(9600);
32+
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }
33+
34+
/* Specify the level of detail for debug messages */
35+
setDebugMessageLevel(DBG_INFO);
36+
37+
/* Configure LED pin as an output */
38+
pinMode(LED_BUILTIN, OUTPUT);
39+
40+
/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
41+
initProperties();
42+
43+
/* Initialize Arduino IoT Cloud library */
44+
#ifndef ATTN_PIN
45+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
46+
ArduinoCloud.setNotecardPollingInterval(3000); // default: 1000ms, min: 250ms
47+
#else
48+
ArduinoCloud.begin(ArduinoIoTPreferredConnection, ATTN_PIN);
49+
#endif
50+
51+
ArduinoCloud.printDebugInfo();
52+
}
53+
54+
void loop() {
55+
ArduinoCloud.update();
56+
potentiometer = analogRead(A0);
57+
seconds = millis() / 1000;
58+
}
59+
60+
/*
61+
* 'onLedChange' is called when the "led" property of your Thing changes
62+
*/
63+
void onLedChange() {
64+
Serial.print("LED set to ");
65+
Serial.println(led);
66+
digitalWrite(LED_BUILTIN, led);
67+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <Arduino_ConnectionHandler.h>
2+
3+
/* A complete list of supported boards with WiFi is available here:
4+
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
5+
*/
6+
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
7+
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <ArduinoIoTCloud.h>
2+
#include <Arduino_ConnectionHandler.h>
3+
#include "arduino_secrets.h"
4+
5+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
6+
* or UART. An empty string (or the default value provided below) will not
7+
* override the Notecard's existing configuration.
8+
* Learn more at: https://dev.blues.io */
9+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
10+
11+
/* Uncomment the following line to use the Notecard over UART */
12+
// #define UART_INTERFACE Serial1
13+
14+
void onLedChange();
15+
16+
bool led;
17+
int potentiometer;
18+
int seconds;
19+
20+
void initProperties() {
21+
ArduinoCloud.addProperty(led, 1, Permission::ReadWrite).onUpdate(onLedChange);
22+
ArduinoCloud.addProperty(potentiometer, 2, Permission::Read).publishOnChange(10);
23+
ArduinoCloud.addProperty(seconds, 3, Permission::Read).publishEvery(5 * MINUTES);
24+
25+
if (strncmp(SECRET_WIFI_SSID, "YOUR_WIFI_NETWORK_NAME", sizeof(SECRET_WIFI_SSID))) {
26+
ArduinoIoTPreferredConnection.setWiFiCredentials(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
27+
}
28+
}
29+
30+
#ifndef UART_INTERFACE
31+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
32+
#else
33+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID, UART_INTERFACE);
34+
#endif
35+

examples/ArduinoIoTCloud-Schedule/ArduinoIoTCloud-Schedule.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ 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
/* Configure LED pin as an output */
2124
pinMode(LED_BUILTIN, OUTPUT);
2225

@@ -26,7 +29,6 @@ void setup() {
2629
/* Initialize Arduino IoT Cloud library */
2730
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
2831

29-
setDebugMessageLevel(DBG_INFO);
3032
ArduinoCloud.printDebugInfo();
3133

3234
/* Setup one shot schedule example */

examples/ArduinoIoTCloud-Schedule/thingProperties.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
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+
1418
void onSwitchButtonChange();
1519

1620
bool switchButton;
@@ -27,6 +31,9 @@ void initProperties() {
2731
ArduinoCloud.setBoardId(BOARD_ID);
2832
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2933
#endif
34+
#if defined(BOARD_HAS_LORA)
35+
ArduinoCloud.setThingId(THING_ID);
36+
#endif
3037
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
3138
ArduinoCloud.addProperty(switchButton, Permission::Write);
3239
ArduinoCloud.addProperty(oneShot, Permission::ReadWrite);

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ sentence=This library allows connecting to the Arduino IoT Cloud service.
66
paragraph=It provides a ConnectionManager to handle connection/disconnection, property-change updates and events callbacks. The supported boards are MKR GSM, MKR1000 and WiFi101.
77
category=Communication
88
url=https://github.com/arduino-libraries/ArduinoIoTCloud
9-
architectures=mbed,samd,esp8266,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_opta,mbed_giga,renesas_portenta,renesas_uno,mbed_edge
9+
architectures=mbed,samd,esp8266,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_opta,mbed_giga,renesas_portenta,renesas_uno,mbed_edge,stm32
1010
includes=ArduinoIoTCloud.h
1111
depends=Arduino_ConnectionHandler,Arduino_DebugUtils,Arduino_SecureElement,ArduinoMqttClient,ArduinoECCX08,RTCZero,Adafruit SleepyDog Library,ArduinoHttpClient

0 commit comments

Comments
 (0)