Skip to content

Commit e050652

Browse files
committed
Fixed example
Fixed Arduino Switch example (SWITCH_ID was missing) Fixed standard baud rate for Arduino examples Added easy way to enable serial debug on Arduino examples (ENABLE_DEBUG) Added more details about IDs Added info about where you can get help
1 parent a539e30 commit e050652

File tree

4 files changed

+56
-18
lines changed

4 files changed

+56
-18
lines changed

examples/Switch/Switch.ino

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
* - setup a switch device
44
* - handle request using callback (turn on/off builtin led indicating device power state)
55
* - send event to sinricPro server (flash button is used to turn on/off device manually)
6-
*/
6+
*
7+
* If you encounter any issues:
8+
* - enable serial debug (see section below)
9+
* - open serial monitor and check whats happening
10+
* - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one
11+
*/
12+
13+
// Uncomment the following line to enable serial debug output
14+
//#define ENABLE_DEBUG
15+
16+
#ifdef ENABLE_DEBUG
17+
#define DEBUG_ESP_PORT Serial
18+
#define NODEBUG_WEBSOCKETS
19+
#define NDEBUG
20+
#endif
721

822
#include <Arduino.h>
923
#ifdef ESP8266
@@ -16,10 +30,12 @@
1630
#include "SinricPro.h"
1731
#include "SinricProSwitch.h"
1832

19-
#define WIFI_SSID "YOUR-WIFI-SSID"
33+
#define WIFI_SSID "YOUR-WIFI-SSID"
2034
#define WIFI_PASS "YOUR-WIFI-PASSWORD"
21-
#define APP_KEY "YOUR-APP-KEY"
22-
#define APP_SECRET "YOUR-APP-SECRET"
35+
#define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
36+
#define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
37+
#define SWITCH_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
38+
#define BAUD_RATE 9600 // Change baudrate to your need
2339

2440
#define BTN_FLASH 0
2541

@@ -97,7 +113,7 @@ void setup() {
97113
pinMode(LED_BUILTIN, OUTPUT); // define LED GPIO as output
98114
digitalWrite(LED_BUILTIN, HIGH); // turn off LED on bootup
99115

100-
Serial.begin(115200);
116+
Serial.begin(BAUD_RATE);
101117
setupWiFi();
102118
setupSinricPro();
103119
}

examples/doorbell/doorbell.ino

+20-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@
22
* Example for how to use SinricPro Doorbell device:
33
* - setup a doorbell device
44
* - send event to sinricPro server if button is pressed
5-
*/
5+
*
6+
* If you encounter any issues:
7+
* - enable serial debug (see section below)
8+
* - open serial monitor and check whats happening
9+
* - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one
10+
*/
11+
12+
// Uncomment the following line to enable serial debug output
13+
//#define ENABLE_DEBUG
14+
15+
#ifdef ENABLE_DEBUG
16+
#define DEBUG_ESP_PORT Serial
17+
#define NODEBUG_WEBSOCKETS
18+
#define NDEBUG
19+
#endif
620

721
#include <Arduino.h>
822
#ifdef ESP8266
@@ -17,10 +31,11 @@
1731

1832
#define WIFI_SSID "YOUR-WIFI-SSID"
1933
#define WIFI_PASS "YOUR-WIFI-PASSWORD"
20-
#define APP_KEY "YOUR-APP-KEY"
21-
#define APP_SECRET "YOUR-APP-SECRET"
34+
#define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
35+
#define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
36+
#define DOORBELL_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
37+
#define BAUD_RATE 9600 // Change baudrate to your need
2238

23-
#define DOORBELL_ID "YOUR-DEVICE-ID"
2439

2540
// change this to your button PIN
2641
// on NodeMCU D3 / GPIO-0 is flash button PIN so you can use the builtin flash button
@@ -71,7 +86,7 @@ void setupSinricPro() {
7186
void setup() {
7287
pinMode(BUTTON_PIN, INPUT_PULLUP); // BUTTIN_PIN as INPUT
7388

74-
Serial.begin(115200);
89+
Serial.begin(9600);
7590
setupWiFi();
7691
setupSinricPro();
7792
}

pio-examples/doorbell/src/doorbell.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* Example for how to use SinricPro Doorbell device:
33
* - setup a doorbell device
44
* - send event to sinricPro server if button is pressed
5+
*
6+
* If you encounter any issues:
7+
* - open serial monitor and check whats happening
8+
* - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one
59
*/
610

711
#include <Arduino.h>
@@ -17,10 +21,9 @@
1721

1822
#define WIFI_SSID "YOUR-WIFI-SSID"
1923
#define WIFI_PASS "YOUR-WIFI-PASSWORD"
20-
#define APP_KEY "YOUR-APP-KEY"
21-
#define APP_SECRET "YOUR-APP-SECRET"
22-
23-
#define DOORBELL_ID "YOUR-DEVICE-ID"
24+
#define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
25+
#define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
26+
#define DOORBELL_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
2427

2528
// change this to your button PIN
2629
// on NodeMCU D3 / GPIO-0 is flash button PIN so you can use the builtin flash button

pio-examples/switch/src/switch.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
* - setup a switch device
44
* - handle request using callback (turn on/off builtin led indicating device power state)
55
* - send event to sinricPro server (flash button is used to turn on/off device manually)
6+
*
7+
* If you encounter any issues:
8+
* - open serial monitor and check whats happening
9+
* - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one
610
*/
711

812
#include <Arduino.h>
@@ -16,11 +20,11 @@
1620
#include "SinricPro.h"
1721
#include "SinricProSwitch.h"
1822

19-
#define WIFI_SSID "YOUR-WIFI-SSID"
23+
#define WIFI_SSID "YOUR-WIFI-SSID"
2024
#define WIFI_PASS "YOUR-WIFI-PASSWORD"
21-
#define APP_KEY "YOUR-APP-KEY"
22-
#define APP_SECRET "YOUR-APP-SECRET"
23-
#define SWITCH_ID "YOUR-DEVICE-ID"
25+
#define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
26+
#define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
27+
#define SWITCH_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
2428

2529
#define BTN_FLASH 0
2630

0 commit comments

Comments
 (0)