Skip to content

Commit b63b821

Browse files
committed
Extend example ArduinoIoTCloud_LED_switch for be also compilable for ESP8266
1 parent 4039dad commit b63b821

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ script:
107107
- |
108108
if [ "$BOARD" == "esp8266:esp8266:huzzah" ]; then
109109
buildSketch \
110+
"ArduinoIoTCloud_LED_switch" \
110111
"ArduinoIoTCloud_ESP8266" \
111112
"utility/WiFi_Cloud_Blink_with_security_credentials"
112113
fi

examples/ArduinoIoTCloud_LED_switch/arduino_secrets.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
77
#endif
88

9+
/* ESP8266 */
10+
#if defined(BOARD_ESP8266)
11+
#define SECRET_DEVICE_KEY "my-device-password"
12+
#endif
13+
914
/* MKR GSM 1400 */
1015
#if defined(BOARD_HAS_GSM)
1116
#define SECRET_PIN ""

examples/ArduinoIoTCloud_LED_switch/thingProperties.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@
99
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
1010
#endif
1111

12-
13-
// Your THING_ID
14-
#define THING_ID "ARDUINO_IOT_CLOUD_THING_ID"
12+
#define THING_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
13+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1514

1615
void onLedChange();
1716

1817
bool led;
1918
int potentiometer;
2019

2120
void initProperties() {
21+
#if defined(BOARD_ESP8266)
22+
ArduinoCloud.setBoardId(BOARD_ID);
23+
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
24+
#endif
2225
ArduinoCloud.setThingId(THING_ID);
23-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM)
26+
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM)
2427
ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, onLedChange);
2528
ArduinoCloud.addProperty(potentiometer, READ, ON_CHANGE);
26-
#elif defined(BOARD_HAS_LORA)
29+
#elif defined(BOARD_HAS_LORA)
2730
ArduinoCloud.addProperty(led, 1, READWRITE, ON_CHANGE, onLedChange);
2831
ArduinoCloud.addProperty(potentiometer, 2, READ, ON_CHANGE);
29-
#endif
30-
32+
#endif
3133
}
3234

3335
#if defined(BOARD_HAS_WIFI)

0 commit comments

Comments
 (0)