Skip to content

Commit 90508ac

Browse files
authored
Merge pull request #342 from pennam/eth-examples-docs
Ethernet: examples and readme update
2 parents 9c6d5d7 + d4b1340 commit 90508ac

19 files changed

+115
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The `ArduinoIoTCloud` library is the central element of the firmware enabling ce
1414
* **GSM**: [`MKR GSM 1400`](https://store.arduino.cc/arduino-mkr-gsm-1400-1415)
1515
* **5G**: [`MKR NB 1500`](https://store.arduino.cc/arduino-mkr-nb-1500-1413)
1616
* **LoRa**: [`MKR WAN 1300/1310`](https://store.arduino.cc/mkr-wan-1310)
17+
* **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)
1718

1819
### How?
1920
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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
/*
22
This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.
33
4-
This sketch is compatible with:
4+
IMPORTANT:
5+
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
6+
On a LoRa board, if it is configured as a class A device (default and preferred option), values from Cloud dashboard are received
7+
only after a value is sent to Cloud.
8+
9+
The full list of compatible boards can be found here:
510
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
611
*/
712

examples/ArduinoIoTCloud-Advanced/arduino_secrets.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@
3535
#define SECRET_LOGIN ""
3636
#define SECRET_PASS ""
3737
#endif
38+
39+
/* Portenta H7 + Ethernet shield */
40+
#if defined(BOARD_HAS_ETHERNET)
41+
#define SECRET_OPTIONAL_IP ""
42+
#define SECRET_OPTIONAL_DNS ""
43+
#define SECRET_OPTIONAL_GATEWAY ""
44+
#define SECRET_OPTIONAL_NETMASK ""
45+
#endif

examples/ArduinoIoTCloud-Advanced/thingProperties.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#elif defined(BOARD_HAS_GSM)
33
#elif defined(BOARD_HAS_LORA)
44
#elif defined(BOARD_HAS_NB)
5+
#elif defined(BOARD_HAS_ETHERNET)
56
#else
67
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
78
#endif
@@ -41,4 +42,9 @@ void initProperties() {
4142
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
4243
#elif defined(BOARD_HAS_NB)
4344
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
45+
#elif defined(BOARD_HAS_ETHERNET)
46+
/* DHCP mode */
47+
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
48+
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
49+
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
4450
#endif

examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
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 and Lora enabled boards supported by Arduino IoT Cloud.
9+
This sketch works with 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), values from Cloud dashboard are received
1111
only after a value is sent to Cloud.
1212
13-
This sketch is compatible with:
13+
The full list of compatible boards can be found here:
1414
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
1515
*/
1616

1717
#include "arduino_secrets.h"
1818
#include "thingProperties.h"
1919

20-
#if defined(ESP32)
20+
#if !defined(LED_BUILTIN)
2121
static int const LED_BUILTIN = 2;
2222
#endif
2323

examples/ArduinoIoTCloud-Basic/arduino_secrets.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
1010
#endif
1111

12-
/* ESP8266 */
12+
/* ESP8266 ESP32*/
1313
#if defined(BOARD_ESP)
1414
#define SECRET_DEVICE_KEY "my-device-password"
1515
#endif
@@ -35,3 +35,11 @@
3535
#define SECRET_LOGIN ""
3636
#define SECRET_PASS ""
3737
#endif
38+
39+
/* Portenta H7 + Ethernet shield */
40+
#if defined(BOARD_HAS_ETHERNET)
41+
#define SECRET_OPTIONAL_IP ""
42+
#define SECRET_OPTIONAL_DNS ""
43+
#define SECRET_OPTIONAL_GATEWAY ""
44+
#define SECRET_OPTIONAL_NETMASK ""
45+
#endif

examples/ArduinoIoTCloud-Basic/thingProperties.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#elif defined(BOARD_HAS_GSM)
33
#elif defined(BOARD_HAS_LORA)
44
#elif defined(BOARD_HAS_NB)
5+
#elif defined(BOARD_HAS_ETHERNET)
56
#else
67
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
78
#endif
@@ -21,7 +22,7 @@ void initProperties() {
2122
ArduinoCloud.setBoardId(BOARD_ID);
2223
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2324
#endif
24-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
25+
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET)
2526
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
2627
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
2728
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);
@@ -32,7 +33,12 @@ void initProperties() {
3233
#endif
3334
}
3435

35-
#if defined(BOARD_HAS_WIFI)
36+
#if defined(BOARD_HAS_ETHERNET)
37+
/* DHCP mode */
38+
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
39+
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
40+
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
41+
#elif defined(BOARD_HAS_WIFI)
3642
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_SSID, SECRET_PASS);
3743
#elif defined(BOARD_HAS_GSM)
3844
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);

examples/ArduinoIoTCloud-Callbacks/ArduinoIoTCloud-Callbacks.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
One function per event can be assigned.
1919
2020
IMPORTANT:
21-
This sketch works with WiFi, GSM, NB and Lora enabled boards supported by Arduino IoT Cloud.
21+
This sketch works with 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), values from Cloud dashboard are received
2323
only after a value is sent to Cloud.
2424
25-
This sketch is compatible with:
25+
The full list of compatible boards can be found here:
2626
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
2727
*/
2828

examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@
3535
#define SECRET_LOGIN ""
3636
#define SECRET_PASS ""
3737
#endif
38+
39+
/* Portenta H7 + Ethernet shield */
40+
#if defined(BOARD_HAS_ETHERNET)
41+
#define SECRET_OPTIONAL_IP ""
42+
#define SECRET_OPTIONAL_DNS ""
43+
#define SECRET_OPTIONAL_GATEWAY ""
44+
#define SECRET_OPTIONAL_NETMASK ""
45+
#endif

examples/ArduinoIoTCloud-Callbacks/thingProperties.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#elif defined(BOARD_HAS_GSM)
33
#elif defined(BOARD_HAS_LORA)
44
#elif defined(BOARD_HAS_NB)
5+
#elif defined(BOARD_HAS_ETHERNET)
56
#else
67
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
78
#endif
@@ -25,4 +26,9 @@ void initProperties() {
2526
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
2627
#elif defined(BOARD_HAS_NB)
2728
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
29+
#elif defined(BOARD_HAS_ETHERNET)
30+
/* DHCP mode */
31+
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
32+
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
33+
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
2834
#endif

examples/ArduinoIoTCloud-DeferredOTA/ArduinoIoTCloud-DeferredOTA.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
* always_allow callback will immediately apply the OTA update
1010
* ask_user_via_serial callback will read user input from serial to apply or postpone OTA update
1111
12-
This sketch is compatible with:
12+
IMPORTANT:
13+
This sketch works with WiFi and Ethernet enabled boards supported by Arduino IoT Cloud.
14+
15+
The full list of compatible boards can be found here:
1316
- https://github.com/arduino-libraries/ArduinoIoTCloud/#ota
1417
*/
1518

examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@
3535
#define SECRET_LOGIN ""
3636
#define SECRET_PASS ""
3737
#endif
38+
39+
/* Portenta H7 + Ethernet shield */
40+
#if defined(BOARD_HAS_ETHERNET)
41+
#define SECRET_OPTIONAL_IP ""
42+
#define SECRET_OPTIONAL_DNS ""
43+
#define SECRET_OPTIONAL_GATEWAY ""
44+
#define SECRET_OPTIONAL_NETMASK ""
45+
#endif

examples/ArduinoIoTCloud-DeferredOTA/thingProperties.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#elif defined(BOARD_HAS_GSM)
33
#elif defined(BOARD_HAS_LORA)
44
#elif defined(BOARD_HAS_NB)
5+
#elif defined(BOARD_HAS_ETHERNET)
56
#else
67
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
78
#endif
@@ -19,7 +20,7 @@ void initProperties() {
1920
ArduinoCloud.setBoardId(BOARD_ID);
2021
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2122
#endif
22-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
23+
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET)
2324
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
2425
#elif defined(BOARD_HAS_LORA)
2526
ArduinoCloud.addProperty(led, 1, READWRITE, ON_CHANGE, onLedChange);
@@ -34,4 +35,9 @@ void initProperties() {
3435
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
3536
#elif defined(BOARD_HAS_NB)
3637
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
38+
#elif defined(BOARD_HAS_ETHERNET)
39+
/* DHCP mode */
40+
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
41+
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
42+
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
3743
#endif

examples/ArduinoIoTCloud-Schedule/ArduinoIoTCloud-Schedule.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/*
22
This sketch demonstrates how to use the cloud schedule variable type.
33
4-
This sketch is compatible with the following boards:
5-
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
4+
IMPORTANT:
5+
This sketch works with WiFi, GSM, NB and Ethernet enabled boards supported by Arduino IoT Cloud.
6+
67
*/
78

89
#include "arduino_secrets.h"

examples/ArduinoIoTCloud-Schedule/arduino_secrets.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@
3535
#define SECRET_LOGIN ""
3636
#define SECRET_PASS ""
3737
#endif
38+
39+
/* Portenta H7 + Ethernet shield */
40+
#if defined(BOARD_HAS_ETHERNET)
41+
#define SECRET_OPTIONAL_IP ""
42+
#define SECRET_OPTIONAL_DNS ""
43+
#define SECRET_OPTIONAL_GATEWAY ""
44+
#define SECRET_OPTIONAL_NETMASK ""
45+
#endif

examples/ArduinoIoTCloud-Schedule/thingProperties.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#elif defined(BOARD_HAS_GSM)
33
#elif defined(BOARD_HAS_LORA)
44
#elif defined(BOARD_HAS_NB)
5+
#elif defined(BOARD_HAS_ETHERNET)
56
#else
67
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
78
#endif
@@ -26,7 +27,7 @@ void initProperties() {
2627
ArduinoCloud.setBoardId(BOARD_ID);
2728
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2829
#endif
29-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
30+
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET)
3031
ArduinoCloud.addProperty(switchButton, WRITE, ON_CHANGE);
3132
ArduinoCloud.addProperty(oneShot, READWRITE, ON_CHANGE);
3233
ArduinoCloud.addProperty(minute, READWRITE, ON_CHANGE);
@@ -48,4 +49,9 @@ void initProperties() {
4849
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
4950
#elif defined(BOARD_HAS_NB)
5051
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
52+
#elif defined(BOARD_HAS_ETHERNET)
53+
/* DHCP mode */
54+
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
55+
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
56+
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
5157
#endif

examples/utility/ArduinoIoTCloud_Travis_CI/ArduinoIoTCloud_Travis_CI.ino

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
unintentional breaking changes are made to the user facing
44
Arduino IoT Cloud API.
55
6-
This sketch is compatible with:
7-
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
6+
IMPORTANT:
7+
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
8+
On a LoRa board, if it is configured as a class A device (default and preferred option), values from Cloud dashboard are received
9+
only after a value is sent to Cloud.
10+
11+
The full list of compatible boards can be found here:
12+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
813
*/
914

1015
#include "arduino_secrets.h"

examples/utility/ArduinoIoTCloud_Travis_CI/arduino_secrets.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@
3535
#define SECRET_LOGIN ""
3636
#define SECRET_PASS ""
3737
#endif
38+
39+
/* Portenta H7 + Ethernet shield */
40+
#if defined(BOARD_HAS_ETHERNET)
41+
#define SECRET_OPTIONAL_IP ""
42+
#define SECRET_OPTIONAL_DNS ""
43+
#define SECRET_OPTIONAL_GATEWAY ""
44+
#define SECRET_OPTIONAL_NETMASK ""
45+
#endif

examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#elif defined(BOARD_HAS_GSM)
33
#elif defined(BOARD_HAS_LORA)
44
#elif defined(BOARD_HAS_NB)
5+
#elif defined(BOARD_HAS_ETHERNET)
56
#else
67
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
78
#endif
@@ -57,6 +58,11 @@ String str_property_8;
5758
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, EU868);
5859
#elif defined(BOARD_HAS_NB)
5960
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
61+
#elif defined(BOARD_HAS_ETHERNET)
62+
/* DHCP mode */
63+
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
64+
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
65+
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
6066
#endif
6167

6268
/******************************************************************************

0 commit comments

Comments
 (0)