Skip to content

Ethernet: examples and readme update #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The `ArduinoIoTCloud` library is the central element of the firmware enabling ce
* **GSM**: [`MKR GSM 1400`](https://store.arduino.cc/arduino-mkr-gsm-1400-1415)
* **5G**: [`MKR NB 1500`](https://store.arduino.cc/arduino-mkr-nb-1500-1413)
* **LoRa**: [`MKR WAN 1300/1310`](https://store.arduino.cc/mkr-wan-1310)
* **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)

### How?
1) Register your Arduino IoT Cloud capable board via [Arduino IoT Cloud](https://create.arduino.cc/iot) (Devices Section).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/*
This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.
This sketch is compatible with:
IMPORTANT:
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option), values from Cloud dashboard are received
only after a value is sent to Cloud.
The full list of compatible boards can be found here:
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

Expand Down
8 changes: 8 additions & 0 deletions examples/ArduinoIoTCloud-Advanced/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@
#define SECRET_LOGIN ""
#define SECRET_PASS ""
#endif

/* Portenta H7 + Ethernet shield */
#if defined(BOARD_HAS_ETHERNET)
#define SECRET_OPTIONAL_IP ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are those secrets called _OPTIONAL_?

#define SECRET_OPTIONAL_DNS ""
#define SECRET_OPTIONAL_GATEWAY ""
#define SECRET_OPTIONAL_NETMASK ""
#endif
6 changes: 6 additions & 0 deletions examples/ArduinoIoTCloud-Advanced/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#elif defined(BOARD_HAS_ETHERNET)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif
Expand Down Expand Up @@ -41,4 +42,9 @@ void initProperties() {
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
#elif defined(BOARD_HAS_NB)
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#elif defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
#endif
6 changes: 3 additions & 3 deletions examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
* When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.

IMPORTANT:
This sketch works with WiFi, GSM, NB and Lora enabled boards supported by Arduino IoT Cloud.
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option), values from Cloud dashboard are received
only after a value is sent to Cloud.

This sketch is compatible with:
The full list of compatible boards can be found here:
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

#include "arduino_secrets.h"
#include "thingProperties.h"

#if defined(ESP32)
#if !defined(LED_BUILTIN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's much better 🤣 I'm afraid I was the author of the original implementation =)

static int const LED_BUILTIN = 2;
#endif

Expand Down
10 changes: 9 additions & 1 deletion examples/ArduinoIoTCloud-Basic/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 */
/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#define SECRET_DEVICE_KEY "my-device-password"
#endif
Expand All @@ -35,3 +35,11 @@
#define SECRET_LOGIN ""
#define SECRET_PASS ""
#endif

/* Portenta H7 + Ethernet shield */
#if defined(BOARD_HAS_ETHERNET)
#define SECRET_OPTIONAL_IP ""
#define SECRET_OPTIONAL_DNS ""
#define SECRET_OPTIONAL_GATEWAY ""
#define SECRET_OPTIONAL_NETMASK ""
#endif
10 changes: 8 additions & 2 deletions examples/ArduinoIoTCloud-Basic/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#elif defined(BOARD_HAS_ETHERNET)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif
Expand All @@ -21,7 +22,7 @@ void initProperties() {
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET)
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);
Expand All @@ -32,7 +33,12 @@ void initProperties() {
#endif
}

#if defined(BOARD_HAS_WIFI)
#if defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
#elif defined(BOARD_HAS_WIFI)
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_SSID, SECRET_PASS);
#elif defined(BOARD_HAS_GSM)
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
One function per event can be assigned.

IMPORTANT:
This sketch works with WiFi, GSM, NB and Lora enabled boards supported by Arduino IoT Cloud.
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option), values from Cloud dashboard are received
only after a value is sent to Cloud.

This sketch is compatible with:
The full list of compatible boards can be found here:
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

Expand Down
8 changes: 8 additions & 0 deletions examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@
#define SECRET_LOGIN ""
#define SECRET_PASS ""
#endif

/* Portenta H7 + Ethernet shield */
#if defined(BOARD_HAS_ETHERNET)
#define SECRET_OPTIONAL_IP ""
#define SECRET_OPTIONAL_DNS ""
#define SECRET_OPTIONAL_GATEWAY ""
#define SECRET_OPTIONAL_NETMASK ""
#endif
6 changes: 6 additions & 0 deletions examples/ArduinoIoTCloud-Callbacks/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#elif defined(BOARD_HAS_ETHERNET)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif
Expand All @@ -25,4 +26,9 @@ void initProperties() {
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
#elif defined(BOARD_HAS_NB)
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#elif defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
* always_allow callback will immediately apply the OTA update
* ask_user_via_serial callback will read user input from serial to apply or postpone OTA update

This sketch is compatible with:
IMPORTANT:
This sketch works with WiFi and Ethernet enabled boards supported by Arduino IoT Cloud.

The full list of compatible boards can be found here:
- https://github.com/arduino-libraries/ArduinoIoTCloud/#ota
*/

Expand Down
8 changes: 8 additions & 0 deletions examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@
#define SECRET_LOGIN ""
#define SECRET_PASS ""
#endif

/* Portenta H7 + Ethernet shield */
#if defined(BOARD_HAS_ETHERNET)
#define SECRET_OPTIONAL_IP ""
#define SECRET_OPTIONAL_DNS ""
#define SECRET_OPTIONAL_GATEWAY ""
#define SECRET_OPTIONAL_NETMASK ""
#endif
8 changes: 7 additions & 1 deletion examples/ArduinoIoTCloud-DeferredOTA/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#elif defined(BOARD_HAS_ETHERNET)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif
Expand All @@ -19,7 +20,7 @@ void initProperties() {
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET)
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
#elif defined(BOARD_HAS_LORA)
ArduinoCloud.addProperty(led, 1, READWRITE, ON_CHANGE, onLedChange);
Expand All @@ -34,4 +35,9 @@ void initProperties() {
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
#elif defined(BOARD_HAS_NB)
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#elif defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, the parameter is optional when using DHCP. But maybe a better naming would be SECRET_MANUAL_IP. Also its not really a secret, just a configuration item. Maybe ETHERNET_MANUAL_CONFIG_IP?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your clarification. I thought so. In this case there's not much you do I suppose 🤷.

EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
#endif
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
This sketch demonstrates how to use the cloud schedule variable type.

This sketch is compatible with the following boards:
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
IMPORTANT:
This sketch works with WiFi, GSM, NB and Ethernet enabled boards supported by Arduino IoT Cloud.

*/

#include "arduino_secrets.h"
Expand Down
8 changes: 8 additions & 0 deletions examples/ArduinoIoTCloud-Schedule/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@
#define SECRET_LOGIN ""
#define SECRET_PASS ""
#endif

/* Portenta H7 + Ethernet shield */
#if defined(BOARD_HAS_ETHERNET)
#define SECRET_OPTIONAL_IP ""
#define SECRET_OPTIONAL_DNS ""
#define SECRET_OPTIONAL_GATEWAY ""
#define SECRET_OPTIONAL_NETMASK ""
#endif
8 changes: 7 additions & 1 deletion examples/ArduinoIoTCloud-Schedule/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#elif defined(BOARD_HAS_ETHERNET)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif
Expand All @@ -26,7 +27,7 @@ void initProperties() {
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET)
ArduinoCloud.addProperty(switchButton, WRITE, ON_CHANGE);
ArduinoCloud.addProperty(oneShot, READWRITE, ON_CHANGE);
ArduinoCloud.addProperty(minute, READWRITE, ON_CHANGE);
Expand All @@ -48,4 +49,9 @@ void initProperties() {
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, NULL, _lora_class::CLASS_A);
#elif defined(BOARD_HAS_NB)
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#elif defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
unintentional breaking changes are made to the user facing
Arduino IoT Cloud API.

This sketch is compatible with:
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
IMPORTANT:
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option), values from Cloud dashboard are received
only after a value is sent to Cloud.

The full list of compatible boards can be found here:
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

#include "arduino_secrets.h"
Expand Down
8 changes: 8 additions & 0 deletions examples/utility/ArduinoIoTCloud_Travis_CI/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@
#define SECRET_LOGIN ""
#define SECRET_PASS ""
#endif

/* Portenta H7 + Ethernet shield */
#if defined(BOARD_HAS_ETHERNET)
#define SECRET_OPTIONAL_IP ""
#define SECRET_OPTIONAL_DNS ""
#define SECRET_OPTIONAL_GATEWAY ""
#define SECRET_OPTIONAL_NETMASK ""
#endif
6 changes: 6 additions & 0 deletions examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#elif defined(BOARD_HAS_ETHERNET)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif
Expand Down Expand Up @@ -57,6 +58,11 @@ String str_property_8;
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, EU868);
#elif defined(BOARD_HAS_NB)
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
#elif defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
EthernetConnectionHandler ArduinoIoTPreferredConnection(SECRET_OPTIONAL_IP, SECRET_OPTIONAL_DNS, SECRET_OPTIONAL_GATEWAY, SECRET_OPTIONAL_NETMASK);
#endif

/******************************************************************************
Expand Down