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

0 commit comments

Comments
 (0)