From 7bac731aaae50bd9fa526352c08d61384cfe9fb9 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 09:49:30 +0700 Subject: [PATCH 01/17] feat: remove power on/off from sensors. --- .../AirQualitySensor/AirQualitySensor.ino | 1 - .../AirQualitySensor_gp2y1014au0f.ino | 5 ---- examples/ContactSensor/ContactSensor.ino | 27 ++++--------------- examples/MotionSensor/MotionSensor.ino | 22 --------------- examples/PowerSensor/PowerSensor.ino | 13 --------- examples/temperaturesensor/AHT10/AHT10.ino | 25 +---------------- examples/temperaturesensor/DHT22/DHT22.ino | 23 ---------------- examples/temperaturesensor/HTU21D/HTU21D.ino | 23 ---------------- 8 files changed, 6 insertions(+), 133 deletions(-) diff --git a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino index 8c48dea..7d821de 100644 --- a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino +++ b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino @@ -61,7 +61,6 @@ void setupSinricPro() { // set callback function to device - // setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); diff --git a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino index 1c3369f..af043b4 100644 --- a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino +++ b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino @@ -67,9 +67,6 @@ void setupSinricPro() { // add device to SinricPro SinricProAirQualitySensor& mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; - // set callback function to device - - // setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); @@ -82,7 +79,6 @@ void setupDustSensor() { dustSensor.begin(); } - void setup() { Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n"); setupWiFi(); @@ -90,7 +86,6 @@ void setup() { setupDustSensor(); } - void loop() { SinricPro.handle(); diff --git a/examples/ContactSensor/ContactSensor.ino b/examples/ContactSensor/ContactSensor.ino index 61e397f..41574c6 100644 --- a/examples/ContactSensor/ContactSensor.ino +++ b/examples/ContactSensor/ContactSensor.ino @@ -44,7 +44,6 @@ // LOW = contact is open // HIGH = contact is closed -bool myPowerState = true; // assume device is turned on bool lastContactState = false; unsigned long lastChange = 0; @@ -57,8 +56,11 @@ unsigned long lastChange = 0; * LOW = contactsensor is open */ void handleContactsensor() { - if (!myPowerState) return; // if device switched off...do nothing - + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + unsigned long actualMillis = millis(); if (actualMillis - lastChange < 250) return; // debounce contact state transitions (same as debouncing a pushbutton) @@ -73,22 +75,6 @@ void handleContactsensor() { } } -/** - * @brief Callback for setPowerState request - * - * @param deviceId String containing deviceId (useful if this callback used by multiple devices) - * @param[in] state bool true=turn on device / false=turn off device - * @param[out] state bool true=device turned on / false=device turned off - * @return true request handled properly - * @return false request can't be handled because some kind of error happened - */ -bool onPowerState(const String &deviceId, bool &state) { - Serial.printf("Device %s turned %s (via SinricPro) \r\n", deviceId.c_str(), state?"on":"off"); - myPowerState = state; - return true; // request handled properly -} - - // setup function for WiFi connection void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting"); @@ -107,9 +93,6 @@ void setupSinricPro() { // add device to SinricPro SinricProContactsensor& myContact = SinricPro[CONTACT_ID]; - // set callback function to device - myContact.onPowerState(onPowerState); - // setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); diff --git a/examples/MotionSensor/MotionSensor.ino b/examples/MotionSensor/MotionSensor.ino index c907a5a..25fe17d 100644 --- a/examples/MotionSensor/MotionSensor.ino +++ b/examples/MotionSensor/MotionSensor.ino @@ -45,7 +45,6 @@ // HIGH = motion is detected -bool myPowerState = true; // assume device is turned on bool lastMotionState = false; unsigned long lastChange = 0; @@ -58,8 +57,6 @@ unsigned long lastChange = 0; * LOW = motion not detected */ void handleMotionsensor() { - if (!myPowerState) return; // if device switched off...do nothing - unsigned long actualMillis = millis(); if (actualMillis - lastChange < 250) return; // debounce motionsensor state transitions (same as debouncing a pushbutton) @@ -74,22 +71,6 @@ void handleMotionsensor() { } } -/** - * @brief Callback for setPowerState request - * - * @param deviceId String containing deviceId (useful if this callback used by multiple devices) - * @param[in] state bool true=turn on device / false=turn off device - * @param[out] state bool true=device turned on / false=device turned off - * @return true request handled properly - * @return false request can't be handled because some kind of error happened - */ -bool onPowerState(const String &deviceId, bool &state) { - Serial.printf("Device %s turned %s (via SinricPro) \r\n", deviceId.c_str(), state?"on":"off"); - myPowerState = state; - return true; // request handled properly -} - - // setup function for WiFi connection void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting"); @@ -108,9 +89,6 @@ void setupSinricPro() { // add device to SinricPro SinricProMotionsensor& myMotionsensor = SinricPro[MOTIONSENSOR_ID]; - // set callback function to device - myMotionsensor.onPowerState(onPowerState); - // setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); diff --git a/examples/PowerSensor/PowerSensor.ino b/examples/PowerSensor/PowerSensor.ino index 59c5230..a069de9 100644 --- a/examples/PowerSensor/PowerSensor.ino +++ b/examples/PowerSensor/PowerSensor.ino @@ -62,17 +62,7 @@ void doPowerMeasure() { powerMeasure.apparentPower = powerMeasure.power + (random(10,20)/10.0f); } -bool onPowerState(const String &deviceId, bool &state) { - Serial.printf("Device %s power turned %s \r\n", deviceId.c_str(), state?"on":"off"); - powerState = state; - if (powerState) doPowerMeasure(); // start a measurement when device is turned on - return true; // request handled properly -} - bool sendPowerSensorData() { - // dont send data if device is turned off - if (!powerState) return false; - // limit data rate to SAMPLE_EVERY_SEC static unsigned long lastEvent = 0; unsigned long actualMillis = millis(); @@ -102,9 +92,6 @@ void setupWiFi() { void setupSinricPro() { SinricProPowerSensor &myPowerSensor = SinricPro[POWERSENSOR_ID]; - // set callback function to device - myPowerSensor.onPowerState(onPowerState); - // setup SinricPro //SinricPro.restoreDeviceStates(true); // Uncomment to restore the last known state from the server. SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); diff --git a/examples/temperaturesensor/AHT10/AHT10.ino b/examples/temperaturesensor/AHT10/AHT10.ino index bcd05ed..2c34bdb 100644 --- a/examples/temperaturesensor/AHT10/AHT10.ino +++ b/examples/temperaturesensor/AHT10/AHT10.ino @@ -50,32 +50,12 @@ Adafruit_AHTX0 aht; #define BAUD_RATE 9600 // Change baudrate to your need (used for serial monitor) #define EVENT_WAIT_TIME 60000 // send event every 60 seconds -bool deviceIsOn; // Temeprature sensor on/off state float humidity; // actual humidity float temperature; // actual temperature float lastTemperature; // last known temperature (for compare) float lastHumidity; // last known humidity (for compare) unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent -/* bool onPowerState(String deviceId, bool &state) - * - * Callback for setPowerState request - * parameters - * String deviceId (r) - * contains deviceId (useful if this callback used by multiple devices) - * bool &state (r/w) - * contains the requested state (true:on / false:off) - * must return the new state - * - * return - * true if request should be marked as handled correctly / false if not - */ -bool onPowerState(const String &deviceId, bool &state) { - Serial.printf("Temperaturesensor turned %s (via SinricPro) \r\n", state?"on":"off"); - deviceIsOn = state; // turn on / off temperature sensor - return true; // request handled properly -} - /* handleTemperatatureSensor() * - Checks if Temperaturesensor is turned on * - Checks if time since last event > EVENT_WAIT_TIME to prevent sending too much events @@ -84,8 +64,6 @@ bool onPowerState(const String &deviceId, bool &state) { * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { - if (deviceIsOn == false) return; // device is off...do nothing - unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds if (!aht.begin()) { @@ -136,8 +114,7 @@ void setupWiFi() { void setupSinricPro() { // add device to SinricPro SinricProTemperaturesensor &mySensor = SinricPro[TEMP_SENSOR_ID]; - mySensor.onPowerState(onPowerState); - + // setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); diff --git a/examples/temperaturesensor/DHT22/DHT22.ino b/examples/temperaturesensor/DHT22/DHT22.ino index aa875bb..e740207 100644 --- a/examples/temperaturesensor/DHT22/DHT22.ino +++ b/examples/temperaturesensor/DHT22/DHT22.ino @@ -53,32 +53,12 @@ DHT dht; // DHT sensor -bool deviceIsOn; // Temeprature sensor on/off state float temperature; // actual temperature float humidity; // actual humidity float lastTemperature; // last known temperature (for compare) float lastHumidity; // last known humidity (for compare) unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent -/* bool onPowerState(String deviceId, bool &state) - * - * Callback for setPowerState request - * parameters - * String deviceId (r) - * contains deviceId (useful if this callback used by multiple devices) - * bool &state (r/w) - * contains the requested state (true:on / false:off) - * must return the new state - * - * return - * true if request should be marked as handled correctly / false if not - */ -bool onPowerState(const String &deviceId, bool &state) { - Serial.printf("Temperaturesensor turned %s (via SinricPro) \r\n", state?"on":"off"); - deviceIsOn = state; // turn on / off temperature sensor - return true; // request handled properly -} - /* handleTemperatatureSensor() * - Checks if Temperaturesensor is turned on * - Checks if time since last event > EVENT_WAIT_TIME to prevent sending too much events @@ -87,8 +67,6 @@ bool onPowerState(const String &deviceId, bool &state) { * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { - if (deviceIsOn == false) return; // device is off...do nothing - unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds @@ -134,7 +112,6 @@ void setupWiFi() { void setupSinricPro() { // add device to SinricPro SinricProTemperaturesensor &mySensor = SinricPro[TEMP_SENSOR_ID]; - mySensor.onPowerState(onPowerState); // setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); diff --git a/examples/temperaturesensor/HTU21D/HTU21D.ino b/examples/temperaturesensor/HTU21D/HTU21D.ino index 19e339b..5645b22 100644 --- a/examples/temperaturesensor/HTU21D/HTU21D.ino +++ b/examples/temperaturesensor/HTU21D/HTU21D.ino @@ -56,32 +56,12 @@ Adafruit_HTU21DF htu = Adafruit_HTU21DF(); #define I2C_SDA 19 #endif -bool deviceIsOn; // Temeprature sensor on/off state float temperature; // actual temperature float humidity; // actual humidity float lastTemperature; // last known temperature (for compare) float lastHumidity; // last known humidity (for compare) unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent -/* bool onPowerState(String deviceId, bool &state) - * - * Callback for setPowerState request - * parameters - * String deviceId (r) - * contains deviceId (useful if this callback used by multiple devices) - * bool &state (r/w) - * contains the requested state (true:on / false:off) - * must return the new state - * - * return - * true if request should be marked as handled correctly / false if not - */ -bool onPowerState(const String &deviceId, bool &state) { - Serial.printf("Temperaturesensor turned %s (via SinricPro) \r\n", state?"on":"off"); - deviceIsOn = state; // turn on / off temperature sensor - return true; // request handled properly -} - /* handleTemperatatureSensor() * - Checks if Temperaturesensor is turned on * - Checks if time since last event > EVENT_WAIT_TIME to prevent sending too much events @@ -90,8 +70,6 @@ bool onPowerState(const String &deviceId, bool &state) { * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { - if (deviceIsOn == false) return; // device is off...do nothing - unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds if (!htu.begin()) { @@ -140,7 +118,6 @@ void setupWiFi() { void setupSinricPro() { // add device to SinricPro SinricProTemperaturesensor &mySensor = SinricPro[TEMP_SENSOR_ID]; - mySensor.onPowerState(onPowerState); // setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); From a13162b7a5e15a37247d8f7aff5ed8430bf58fb6 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 09:57:49 +0700 Subject: [PATCH 02/17] fix: SinricPro.isConnected() added --- .../AirQualitySensor/AirQualitySensor/AirQualitySensor.ino | 5 +++++ .../AirQualitySensor_gp2y1014au0f.ino | 5 +++++ examples/MotionSensor/MotionSensor.ino | 5 +++++ examples/PowerSensor/PowerSensor.ino | 5 +++++ examples/temperaturesensor/AHT10/AHT10.ino | 5 +++++ examples/temperaturesensor/DHT22/DHT22.ino | 5 +++++ examples/temperaturesensor/HTU21D/HTU21D.ino | 5 +++++ 7 files changed, 35 insertions(+) diff --git a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino index 69a2094..eefcbce 100644 --- a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino +++ b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino @@ -86,6 +86,11 @@ void loop() { SinricPro.handle(); if((long)(millis() - dispatchTime) >= 0) { + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get sensor device int pm1 =0; diff --git a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino index 9724b2e..26a2e5e 100644 --- a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino +++ b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino @@ -104,6 +104,11 @@ void loop() { Serial.print(" ug/m3; Running average: "); Serial.print(dustSensor.getRunningAverage()); Serial.println(" ug/m3"); + + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get air q sensor device diff --git a/examples/MotionSensor/MotionSensor.ino b/examples/MotionSensor/MotionSensor.ino index de8afb2..e1817d3 100644 --- a/examples/MotionSensor/MotionSensor.ino +++ b/examples/MotionSensor/MotionSensor.ino @@ -57,6 +57,11 @@ unsigned long lastChange = 0; * LOW = motion not detected */ void handleMotionsensor() { + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + unsigned long actualMillis = millis(); if (actualMillis - lastChange < 250) return; // debounce motionsensor state transitions (same as debouncing a pushbutton) diff --git a/examples/PowerSensor/PowerSensor.ino b/examples/PowerSensor/PowerSensor.ino index 23d31ca..2c1eed7 100644 --- a/examples/PowerSensor/PowerSensor.ino +++ b/examples/PowerSensor/PowerSensor.ino @@ -63,6 +63,11 @@ void doPowerMeasure() { } bool sendPowerSensorData() { + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + // limit data rate to SAMPLE_EVERY_SEC static unsigned long lastEvent = 0; unsigned long actualMillis = millis(); diff --git a/examples/temperaturesensor/AHT10/AHT10.ino b/examples/temperaturesensor/AHT10/AHT10.ino index 0b7df98..74a5161 100644 --- a/examples/temperaturesensor/AHT10/AHT10.ino +++ b/examples/temperaturesensor/AHT10/AHT10.ino @@ -64,6 +64,11 @@ unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds if (!aht.begin()) { diff --git a/examples/temperaturesensor/DHT22/DHT22.ino b/examples/temperaturesensor/DHT22/DHT22.ino index 29cf8f1..7a9e0bc 100644 --- a/examples/temperaturesensor/DHT22/DHT22.ino +++ b/examples/temperaturesensor/DHT22/DHT22.ino @@ -67,6 +67,11 @@ unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds diff --git a/examples/temperaturesensor/HTU21D/HTU21D.ino b/examples/temperaturesensor/HTU21D/HTU21D.ino index 901c638..cf8b7c5 100644 --- a/examples/temperaturesensor/HTU21D/HTU21D.ino +++ b/examples/temperaturesensor/HTU21D/HTU21D.ino @@ -70,6 +70,11 @@ unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds if (!htu.begin()) { From 0f43a081af322fa33988e57beb37bb7efc6c5e31 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 10:16:12 +0700 Subject: [PATCH 03/17] fix: remove SinricPro.isConnected() on examples since sendEvent already has it --- .../AirQualitySensor/AirQualitySensor.ino | 5 ----- .../AirQualitySensor_gp2y1014au0f.ino | 5 ----- examples/ContactSensor/ContactSensor.ino | 6 +++--- examples/MotionSensor/MotionSensor.ino | 5 ----- examples/PowerSensor/PowerSensor.ino | 13 ++++--------- examples/temperaturesensor/AHT10/AHT10.ino | 10 +++++----- examples/temperaturesensor/DHT22/DHT22.ino | 5 ----- examples/temperaturesensor/HTU21D/HTU21D.ino | 9 +++++---- 8 files changed, 17 insertions(+), 41 deletions(-) diff --git a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino index eefcbce..69a2094 100644 --- a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino +++ b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino @@ -86,11 +86,6 @@ void loop() { SinricPro.handle(); if((long)(millis() - dispatchTime) >= 0) { - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get sensor device int pm1 =0; diff --git a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino index 26a2e5e..af76126 100644 --- a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino +++ b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino @@ -105,11 +105,6 @@ void loop() { Serial.print(dustSensor.getRunningAverage()); Serial.println(" ug/m3"); - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get air q sensor device int pm1=0; diff --git a/examples/ContactSensor/ContactSensor.ino b/examples/ContactSensor/ContactSensor.ino index 96fb23c..fe3c7d7 100644 --- a/examples/ContactSensor/ContactSensor.ino +++ b/examples/ContactSensor/ContactSensor.ino @@ -56,13 +56,13 @@ unsigned long lastChange = 0; * LOW = contactsensor is open */ void handleContactsensor() { + unsigned long actualMillis = millis(); + if (actualMillis - lastChange < 250) return; // debounce contact state transitions (same as debouncing a pushbutton) + if (SinricPro.isConnected() == false) { Serial.printf("Not connected to Sinric Pro...!\r\n"); return; } - - unsigned long actualMillis = millis(); - if (actualMillis - lastChange < 250) return; // debounce contact state transitions (same as debouncing a pushbutton) bool actualContactState = digitalRead(CONTACT_PIN); // read actual state of contactsensor diff --git a/examples/MotionSensor/MotionSensor.ino b/examples/MotionSensor/MotionSensor.ino index e1817d3..de8afb2 100644 --- a/examples/MotionSensor/MotionSensor.ino +++ b/examples/MotionSensor/MotionSensor.ino @@ -57,11 +57,6 @@ unsigned long lastChange = 0; * LOW = motion not detected */ void handleMotionsensor() { - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - unsigned long actualMillis = millis(); if (actualMillis - lastChange < 250) return; // debounce motionsensor state transitions (same as debouncing a pushbutton) diff --git a/examples/PowerSensor/PowerSensor.ino b/examples/PowerSensor/PowerSensor.ino index 2c1eed7..f0e1dca 100644 --- a/examples/PowerSensor/PowerSensor.ino +++ b/examples/PowerSensor/PowerSensor.ino @@ -62,24 +62,19 @@ void doPowerMeasure() { powerMeasure.apparentPower = powerMeasure.power + (random(10,20)/10.0f); } -bool sendPowerSensorData() { - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - +void sendPowerSensorData() { // limit data rate to SAMPLE_EVERY_SEC static unsigned long lastEvent = 0; unsigned long actualMillis = millis(); if (actualMillis - lastEvent < (SAMPLE_EVERY_SEC * 1000)) return false; lastEvent = actualMillis; + doPowerMeasure(); + // send measured data SinricProPowerSensor &myPowerSensor = SinricPro[POWERSENSOR_ID]; bool success = myPowerSensor.sendPowerSensorEvent(powerMeasure.voltage, powerMeasure.current, powerMeasure.power, powerMeasure.apparentPower); - // if measured data was sent do a new measure - if (success) doPowerMeasure(); - return success; + return; } void setupWiFi() { diff --git a/examples/temperaturesensor/AHT10/AHT10.ino b/examples/temperaturesensor/AHT10/AHT10.ino index 74a5161..5bb8798 100644 --- a/examples/temperaturesensor/AHT10/AHT10.ino +++ b/examples/temperaturesensor/AHT10/AHT10.ino @@ -64,11 +64,6 @@ unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds if (!aht.begin()) { @@ -76,6 +71,11 @@ void handleTemperaturesensor() { return; } + if (SinricPro.isConnected() == false) { + Serial.printf("Not connected to Sinric Pro...!\r\n"); + return; + } + sensors_event_t hum, temp; aht.getEvent(&hum, &temp); float humidity = hum.relative_humidity; diff --git a/examples/temperaturesensor/DHT22/DHT22.ino b/examples/temperaturesensor/DHT22/DHT22.ino index 7a9e0bc..29cf8f1 100644 --- a/examples/temperaturesensor/DHT22/DHT22.ino +++ b/examples/temperaturesensor/DHT22/DHT22.ino @@ -67,11 +67,6 @@ unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds diff --git a/examples/temperaturesensor/HTU21D/HTU21D.ino b/examples/temperaturesensor/HTU21D/HTU21D.ino index cf8b7c5..218b15a 100644 --- a/examples/temperaturesensor/HTU21D/HTU21D.ino +++ b/examples/temperaturesensor/HTU21D/HTU21D.ino @@ -70,13 +70,14 @@ unsigned long lastEvent = (-EVENT_WAIT_TIME); // last time event has been sent * - Send event to SinricPro Server if temperature or humidity changed */ void handleTemperaturesensor() { - if (SinricPro.isConnected() == false) { + unsigned long actualMillis = millis(); + if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds + + if (!SinricPro.isConnected()) { Serial.printf("Not connected to Sinric Pro...!\r\n"); return; } - - unsigned long actualMillis = millis(); - if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds + if (!htu.begin()) { Serial.printf("Sensor not initialized\r\n"); return; From 8ab9e18b0149356decf0bc073f39119730fa5360 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 10:17:27 +0700 Subject: [PATCH 04/17] fix: remove SinricPro.isConnected() on examples since sendEvent already has it --- examples/ContactSensor/ContactSensor.ino | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/ContactSensor/ContactSensor.ino b/examples/ContactSensor/ContactSensor.ino index fe3c7d7..9ece72e 100644 --- a/examples/ContactSensor/ContactSensor.ino +++ b/examples/ContactSensor/ContactSensor.ino @@ -59,11 +59,6 @@ void handleContactsensor() { unsigned long actualMillis = millis(); if (actualMillis - lastChange < 250) return; // debounce contact state transitions (same as debouncing a pushbutton) - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - bool actualContactState = digitalRead(CONTACT_PIN); // read actual state of contactsensor if (actualContactState != lastContactState) { // if state has changed From 52f6988877919a7a2f58203c6a25232df39d009e Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 10:18:22 +0700 Subject: [PATCH 05/17] fix: remove SinricPro.isConnected() on examples since sendEvent already has i --- examples/temperaturesensor/AHT10/AHT10.ino | 5 ----- examples/temperaturesensor/HTU21D/HTU21D.ino | 5 ----- 2 files changed, 10 deletions(-) diff --git a/examples/temperaturesensor/AHT10/AHT10.ino b/examples/temperaturesensor/AHT10/AHT10.ino index 5bb8798..0b7df98 100644 --- a/examples/temperaturesensor/AHT10/AHT10.ino +++ b/examples/temperaturesensor/AHT10/AHT10.ino @@ -71,11 +71,6 @@ void handleTemperaturesensor() { return; } - if (SinricPro.isConnected() == false) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - sensors_event_t hum, temp; aht.getEvent(&hum, &temp); float humidity = hum.relative_humidity; diff --git a/examples/temperaturesensor/HTU21D/HTU21D.ino b/examples/temperaturesensor/HTU21D/HTU21D.ino index 218b15a..50cad29 100644 --- a/examples/temperaturesensor/HTU21D/HTU21D.ino +++ b/examples/temperaturesensor/HTU21D/HTU21D.ino @@ -73,11 +73,6 @@ void handleTemperaturesensor() { unsigned long actualMillis = millis(); if (actualMillis - lastEvent < EVENT_WAIT_TIME) return; //only check every EVENT_WAIT_TIME milliseconds - if (!SinricPro.isConnected()) { - Serial.printf("Not connected to Sinric Pro...!\r\n"); - return; - } - if (!htu.begin()) { Serial.printf("Sensor not initialized\r\n"); return; From 18902073ea1bcb26d029d1270d1a3e8db1003560 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 10:40:22 +0700 Subject: [PATCH 06/17] fix: return void --- examples/PowerSensor/PowerSensor.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/PowerSensor/PowerSensor.ino b/examples/PowerSensor/PowerSensor.ino index f0e1dca..0e6c077 100644 --- a/examples/PowerSensor/PowerSensor.ino +++ b/examples/PowerSensor/PowerSensor.ino @@ -66,7 +66,7 @@ void sendPowerSensorData() { // limit data rate to SAMPLE_EVERY_SEC static unsigned long lastEvent = 0; unsigned long actualMillis = millis(); - if (actualMillis - lastEvent < (SAMPLE_EVERY_SEC * 1000)) return false; + if (actualMillis - lastEvent < (SAMPLE_EVERY_SEC * 1000)) return; lastEvent = actualMillis; doPowerMeasure(); From b9ae595be638aa5b1b442a81f7a53bd3a4c772ce Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 10:59:36 +0700 Subject: [PATCH 07/17] feat: remove PowerStateController from sensors --- src/SinricProAirQualitySensor.h | 3 --- src/SinricProContactsensor.h | 3 --- src/SinricProMotionsensor.h | 3 --- src/SinricProPowerSensor.h | 3 --- src/SinricProTemperaturesensor.h | 3 --- 5 files changed, 15 deletions(-) diff --git a/src/SinricProAirQualitySensor.h b/src/SinricProAirQualitySensor.h index 2af5f99..5a7e85f 100644 --- a/src/SinricProAirQualitySensor.h +++ b/src/SinricProAirQualitySensor.h @@ -9,7 +9,6 @@ #include "SinricProDevice.h" #include "Capabilities/SettingController.h" #include "Capabilities/PushNotification.h" -#include "Capabilities/PowerStateController.h" #include "Capabilities/AirQualitySensor.h" #include "SinricProNamespace.h" @@ -23,11 +22,9 @@ namespace SINRICPRO_NAMESPACE { class SinricProAirQualitySensor : public SinricProDevice, public SettingController, public PushNotification, - public PowerStateController, public AirQualitySensor { friend class SettingController; friend class PushNotification; - friend class PowerStateController; friend class AirQualitySensor; public: SinricProAirQualitySensor(const String &deviceId) : SinricProDevice(deviceId, "AIR_QUALITY_SENSOR"){}; diff --git a/src/SinricProContactsensor.h b/src/SinricProContactsensor.h index 1d09004..d2108db 100644 --- a/src/SinricProContactsensor.h +++ b/src/SinricProContactsensor.h @@ -9,7 +9,6 @@ #include "SinricProDevice.h" #include "Capabilities/SettingController.h" #include "Capabilities/PushNotification.h" -#include "Capabilities/PowerStateController.h" #include "Capabilities/ContactSensor.h" #include "SinricProNamespace.h" @@ -23,11 +22,9 @@ namespace SINRICPRO_NAMESPACE { class SinricProContactsensor : public SinricProDevice, public SettingController, public PushNotification, - public PowerStateController, public ContactSensor { friend class SettingController; friend class PushNotification; - friend class PowerStateController; friend class ContactSensor; public: SinricProContactsensor(const String &deviceId) : SinricProDevice(deviceId, "CONTACT_SENSOR") {} diff --git a/src/SinricProMotionsensor.h b/src/SinricProMotionsensor.h index eca6e4d..1f0a9ca 100644 --- a/src/SinricProMotionsensor.h +++ b/src/SinricProMotionsensor.h @@ -10,7 +10,6 @@ #include "SinricProDevice.h" #include "Capabilities/SettingController.h" #include "Capabilities/PushNotification.h" -#include "Capabilities/PowerStateController.h" #include "Capabilities/MotionSensor.h" #include "SinricProNamespace.h" @@ -24,11 +23,9 @@ namespace SINRICPRO_NAMESPACE { class SinricProMotionsensor : public SinricProDevice, public SettingController, public PushNotification, - public PowerStateController, public MotionSensor { friend class SettingController; friend class PushNotification; - friend class PowerStateController; friend class MotionSensor; public: SinricProMotionsensor(const String &deviceId) : SinricProDevice(deviceId, "MOTION_SENSOR") {} diff --git a/src/SinricProPowerSensor.h b/src/SinricProPowerSensor.h index c02b71a..1108177 100644 --- a/src/SinricProPowerSensor.h +++ b/src/SinricProPowerSensor.h @@ -11,7 +11,6 @@ #include "Capabilities/SettingController.h" #include "Capabilities/PushNotification.h" #include "Capabilities/PowerSensor.h" -#include "Capabilities/PowerStateController.h" #include "SinricProNamespace.h" namespace SINRICPRO_NAMESPACE { @@ -25,11 +24,9 @@ class SinricProPowerSensor : public SinricProDevice, public SettingController, public PushNotification, public PowerSensor, - public PowerStateController { friend class SettingController; friend class PushNotification; friend class PowerSensor; - friend class PowerStateController; public: SinricProPowerSensor(const String &deviceId) : SinricProDevice(deviceId, "POWER_SENSOR") {} }; diff --git a/src/SinricProTemperaturesensor.h b/src/SinricProTemperaturesensor.h index 8ea42d2..cb6eafe 100644 --- a/src/SinricProTemperaturesensor.h +++ b/src/SinricProTemperaturesensor.h @@ -10,7 +10,6 @@ #include "SinricProDevice.h" #include "Capabilities/SettingController.h" #include "Capabilities/PushNotification.h" -#include "Capabilities/PowerStateController.h" #include "Capabilities/TemperatureSensor.h" #include "SinricProNamespace.h" @@ -24,11 +23,9 @@ namespace SINRICPRO_NAMESPACE { class SinricProTemperaturesensor : public SinricProDevice, public SettingController, public PushNotification, - public PowerStateController, public TemperatureSensor { friend class SettingController; friend class PushNotification; - friend class PowerStateController; friend class TemperatureSensor; public: SinricProTemperaturesensor(const String &deviceId) : SinricProDevice(deviceId, "TEMPERATURESENSOR") {} From d6a69290afadcf88f6e2ddb84f06217bbb7dabc8 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 11:00:00 +0700 Subject: [PATCH 08/17] feat: update version to 2.11.2 --- changelog.md | 3 +++ library.json | 2 +- library.properties | 2 +- src/SinricProVersion.h | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 3957eb5..a171e8c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # Changelog +## Version 2.11.2 +- Remove PowerStateController from Air Quality, Contact, Motion and Temperature sensor. + ## Version 2.11.1 - Support Raspberry Pi Pico W diff --git a/library.json b/library.json index 7ed0d06..7a86fd3 100644 --- a/library.json +++ b/library.json @@ -13,7 +13,7 @@ "maintainer": true } ], - "version": "2.11.1", + "version": "2.11.2", "frameworks": "arduino", "platforms": [ "espressif8266", diff --git a/library.properties b/library.properties index 369abcd..cd2b587 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SinricPro -version=2.11.1 +version=2.11.2 author=Boris Jaeger maintainer=Boris Jaeger sentence=Library for https://sinric.pro - simple way to connect your device to alexa diff --git a/src/SinricProVersion.h b/src/SinricProVersion.h index 5f39fad..542ccd2 100644 --- a/src/SinricProVersion.h +++ b/src/SinricProVersion.h @@ -6,7 +6,7 @@ // Version Configuration #define SINRICPRO_VERSION_MAJOR 2 #define SINRICPRO_VERSION_MINOR 11 -#define SINRICPRO_VERSION_REVISION 1 +#define SINRICPRO_VERSION_REVISION 2 #define SINRICPRO_VERSION STR(SINRICPRO_VERSION_MAJOR) "." STR(SINRICPRO_VERSION_MINOR) "." STR(SINRICPRO_VERSION_REVISION) #define SINRICPRO_VERSION_STR "SinricPro (v" SINRICPRO_VERSION ")" #define SINRICPRO_VERISON_INT SINRICPRO_VERSION_MAJOR * 1000000 + SINRICPRO_VERSION_MINOR * 1000 + SINRICPRO_VERSION_REVISION \ No newline at end of file From 41b0b1eb5a43e1f4ce0db48f0ea4c1c06e50bb2a Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 11:33:35 +0700 Subject: [PATCH 09/17] feat: change baudrate to 115200 and make example consistant. --- examples/ACUnit/ACUnit.ino | 2 +- .../AirQualitySensor/AirQualitySensor/AirQualitySensor.ino | 2 +- .../AirQualitySensor_gp2y1014au0f.ino | 2 +- examples/Blinds/Blinds.ino | 2 +- examples/Camera/mjpeg-camera/mjpeg-camera.ino | 3 ++- examples/Camera/rtsp-camera/rtsp-camera.ino | 4 ++-- examples/ContactSensor/ContactSensor.ino | 2 +- examples/DimSwitch/DimSwitch.ino | 2 +- examples/Fan/Fan.ino | 2 +- examples/GarageDoor/GarageDoor.ino | 2 +- examples/Light/Light/Light.ino | 2 +- examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino | 2 +- examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino | 2 +- examples/Lock/Lock/Lock.ino | 2 +- examples/Lock/Lock_with_feedback/Lock_with_feedback.ino | 2 +- examples/MotionSensor/MotionSensor.ino | 2 +- examples/PowerSensor/PowerSensor.ino | 2 +- examples/Relay/MultiRelays_advance/MultiRelays_advance.ino | 2 +- examples/Relay/Relay/Relay.ino | 2 +- examples/Speaker/Speaker.ino | 2 +- examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino | 2 +- examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino | 2 +- .../MultiSwitch_intermediate/MultiSwitch_intermediate.ino | 2 +- examples/Switch/Switch/Switch.ino | 2 +- examples/TV/TV.ino | 2 +- examples/Thermostat/Thermostat.ino | 2 +- examples/doorbell/doorbell.ino | 2 +- examples/platformio/platformio.ini | 2 +- examples/temperaturesensor/AHT10/AHT10.ino | 2 +- examples/temperaturesensor/DHT22/DHT22.ino | 2 +- examples/temperaturesensor/HTU21D/HTU21D.ino | 2 +- 31 files changed, 33 insertions(+), 32 deletions(-) diff --git a/examples/ACUnit/ACUnit.ino b/examples/ACUnit/ACUnit.ino index 51c378d..726b1c4 100644 --- a/examples/ACUnit/ACUnit.ino +++ b/examples/ACUnit/ACUnit.ino @@ -35,7 +35,7 @@ #define APP_KEY "YOUR_APP_KEY_HERE" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR_APP_SECRET_HERE" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define ACUNIT_ID "YOUR_DEVICE_ID_HERE" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need float globalTemperature; bool globalPowerState; diff --git a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino index 69a2094..7a53317 100644 --- a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino +++ b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino @@ -36,7 +36,7 @@ #define APP_KEY "" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define DEVICE_ID "" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need // Air quality sensor event dispatch time. Min is every 1 min. #define MIN (1000UL * 60 * 1) diff --git a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino index af76126..bf00450 100644 --- a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino +++ b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino @@ -39,7 +39,7 @@ #define APP_KEY "" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define DEVICE_ID "" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need // Air quality sensor event dispatch time. Min is every 1 min. #define MIN (1000UL * 60 * 1) diff --git a/examples/Blinds/Blinds.ino b/examples/Blinds/Blinds.ino index 93aeb67..e7ba585 100644 --- a/examples/Blinds/Blinds.ino +++ b/examples/Blinds/Blinds.ino @@ -35,7 +35,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define BLINDS_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need int blindsPosition = 0; bool powerState = false; diff --git a/examples/Camera/mjpeg-camera/mjpeg-camera.ino b/examples/Camera/mjpeg-camera/mjpeg-camera.ino index 8d5b090..488152d 100644 --- a/examples/Camera/mjpeg-camera/mjpeg-camera.ino +++ b/examples/Camera/mjpeg-camera/mjpeg-camera.ino @@ -27,6 +27,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx". Get it from https://portal.sinric.pro/ -> Credentials #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" . Get it from https://portal.sinric.pro/ -> Credentials #define CAMERA_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx". Get it from https://portal.sinric.pro/ -> Devices +#define BAUD_RATE 115200 // Change baudrate to your need void cameraInit(void); void startCameraServer(); @@ -71,7 +72,7 @@ void setupSinricPro() { void setup() { - Serial.begin(115200); + Serial.begin(BAUD_RATE); Serial.setDebugOutput(true); Serial.println(); diff --git a/examples/Camera/rtsp-camera/rtsp-camera.ino b/examples/Camera/rtsp-camera/rtsp-camera.ino index 56f4b13..df79bac 100644 --- a/examples/Camera/rtsp-camera/rtsp-camera.ino +++ b/examples/Camera/rtsp-camera/rtsp-camera.ino @@ -95,7 +95,7 @@ compiler.warning_flags.all=-Wall -Wextra #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx". Get it from https://portal.sinric.pro/ -> Credentials #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" . Get it from https://portal.sinric.pro/ -> Credentials #define CAMERA_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx". Get it from https://portal.sinric.pro/ -> Devices - +#define BAUD_RATE 115200 // Change baudrate to your need OV2640 cam; CStreamer *streamer; @@ -246,7 +246,7 @@ void handleStreaming() { void setup() { - Serial.begin(115200); + Serial.begin(BAUD_RATE); while (!Serial); //wait for serial connection. setupCamera(); diff --git a/examples/ContactSensor/ContactSensor.ino b/examples/ContactSensor/ContactSensor.ino index 9ece72e..425374e 100644 --- a/examples/ContactSensor/ContactSensor.ino +++ b/examples/ContactSensor/ContactSensor.ino @@ -38,7 +38,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define CONTACT_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need #define CONTACT_PIN 5 // PIN where contactsensor is connected to // LOW = contact is open diff --git a/examples/DimSwitch/DimSwitch.ino b/examples/DimSwitch/DimSwitch.ino index ef99c97..a9e2e3a 100644 --- a/examples/DimSwitch/DimSwitch.ino +++ b/examples/DimSwitch/DimSwitch.ino @@ -33,7 +33,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define DIMSWITCH_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need // we use a struct to store all states and values for our dimmable switch struct { diff --git a/examples/Fan/Fan.ino b/examples/Fan/Fan.ino index f3c88e5..ea32f25 100644 --- a/examples/Fan/Fan.ino +++ b/examples/Fan/Fan.ino @@ -33,7 +33,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define FAN_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need // we use a struct to store all states and values for our fan // fanSpeed (1..3) diff --git a/examples/GarageDoor/GarageDoor.ino b/examples/GarageDoor/GarageDoor.ino index 62628f3..ec1596d 100644 --- a/examples/GarageDoor/GarageDoor.ino +++ b/examples/GarageDoor/GarageDoor.ino @@ -35,7 +35,7 @@ #define APP_KEY "YOUR_APP_KEY_HERE" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR_APP_SECRET_HERE" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define GARAGEDOOR_ID "YOUR_DEVICE_ID_HERE" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need bool onDoorState(const String& deviceId, bool &doorState) { diff --git a/examples/Light/Light/Light.ino b/examples/Light/Light/Light.ino index 3f973e7..8637d7f 100644 --- a/examples/Light/Light/Light.ino +++ b/examples/Light/Light/Light.ino @@ -33,7 +33,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define LIGHT_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need // define array of supported color temperatures int colorTemperatureArray[] = {2200, 2700, 4000, 5500, 7000}; diff --git a/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino b/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino index a0078bc..e688952 100644 --- a/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino +++ b/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino @@ -37,7 +37,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define LIGHT_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need #define NUM_LEDS 1 // how much LEDs are on the stripe #define LED_PIN 3 // LED stripe is connected to PIN 3 diff --git a/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino b/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino index 275c285..a8ad4ef 100644 --- a/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino +++ b/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino @@ -30,7 +30,7 @@ #define APP_KEY "YOUR-APPKEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APPSECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define LIGHT_ID "YOUR-DEVICEID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need for serial log +#define BAUD_RATE 115200 // Change baudrate to your need for serial log #define BLUE_PIN D5 // PIN for BLUE Mosfet - change this to your need (D5 = GPIO14 on ESP8266) #define RED_PIN D6 // PIN for RED Mosfet - change this to your need (D6 = GPIO12 on ESP8266) diff --git a/examples/Lock/Lock/Lock.ino b/examples/Lock/Lock/Lock.ino index 957253d..289f4eb 100644 --- a/examples/Lock/Lock/Lock.ino +++ b/examples/Lock/Lock/Lock.ino @@ -35,7 +35,7 @@ #define APP_KEY "YOUR_APP_KEY_HERE" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR_APP_SECRET_HERE" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define LOCK_ID "YOUR_DEVICE_ID_HERE" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need bool onLockState(String deviceId, bool &lockState) { diff --git a/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino b/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino index 1df195d..2e03334 100644 --- a/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino +++ b/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino @@ -40,7 +40,7 @@ #define APP_KEY "YOUR_APP_KEY_HERE" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR_APP_SECRET_HERE" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define LOCK_ID "YOUR_DEVICE_ID_HERE" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need #if defined(ESP8266) #define LOCK_PIN D1 // PIN where the lock is connected to: HIGH = locked, LOW = unlocked diff --git a/examples/MotionSensor/MotionSensor.ino b/examples/MotionSensor/MotionSensor.ino index de8afb2..064cd0f 100644 --- a/examples/MotionSensor/MotionSensor.ino +++ b/examples/MotionSensor/MotionSensor.ino @@ -38,7 +38,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define MOTIONSENSOR_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need #define MOTIONSENSOR_PIN 5 // PIN where motionsensor is connected to // LOW = motion is not detected diff --git a/examples/PowerSensor/PowerSensor.ino b/examples/PowerSensor/PowerSensor.ino index 0e6c077..ee0226f 100644 --- a/examples/PowerSensor/PowerSensor.ino +++ b/examples/PowerSensor/PowerSensor.ino @@ -37,7 +37,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define POWERSENSOR_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need (used for serial monitor) +#define BAUD_RATE 115200 // Change baudrate to your need (used for serial monitor) #define SAMPLE_EVERY_SEC 60 // Send every 60 seconds new data to server diff --git a/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino b/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino index e3e04ad..da1594e 100644 --- a/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino +++ b/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino @@ -90,7 +90,7 @@ std::vector relays = { #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need bool onPowerState(const String &deviceId, bool &state) { for (auto &relay : relays) { // for each relay configuration diff --git a/examples/Relay/Relay/Relay.ino b/examples/Relay/Relay/Relay.ino index 88f3333..ce7b152 100644 --- a/examples/Relay/Relay/Relay.ino +++ b/examples/Relay/Relay/Relay.ino @@ -33,7 +33,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define SWITCH_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need #if defined(ESP8266) #define RELAY_PIN D5 // Pin where the relay is connected (D5 = GPIO 14 on ESP8266) diff --git a/examples/Speaker/Speaker.ino b/examples/Speaker/Speaker.ino index 9eed870..2c1e422 100644 --- a/examples/Speaker/Speaker.ino +++ b/examples/Speaker/Speaker.ino @@ -35,7 +35,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define SPEAKER_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 +#define BAUD_RATE 115200 #define BANDS_INDEX_BASS 0 #define BANDS_INDEX_MIDRANGE 1 diff --git a/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino b/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino index 3294201..2639aeb 100644 --- a/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino +++ b/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino @@ -50,7 +50,7 @@ // comment the following line if you use a toggle switches instead of tactile buttons #define TACTILE_BUTTON 1 -#define BAUD_RATE 9600 +#define BAUD_RATE 115200 #define DEBOUNCE_TIME 250 diff --git a/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino b/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino index c2dcfdf..0a0aff8 100644 --- a/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino +++ b/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino @@ -42,7 +42,7 @@ #define SWITCH_ID_3 "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" #define SWITCH_ID_4 "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need bool onPowerState1(const String &deviceId, bool &state) { Serial.printf("Device 1 turned %s\r\n", state?"on":"off"); diff --git a/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino b/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino index 94fdc63..92d171e 100644 --- a/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino +++ b/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino @@ -36,7 +36,7 @@ #define WIFI_PASS "YOUR-WIFI-PASSWORD" #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need #define DEVICES 4 // define how much devices are in SWITCH_IDs array String SWITCH_IDs[DEVICES] = { // define deviceIds in an array diff --git a/examples/Switch/Switch/Switch.ino b/examples/Switch/Switch/Switch.ino index 8327105..427feb6 100644 --- a/examples/Switch/Switch/Switch.ino +++ b/examples/Switch/Switch/Switch.ino @@ -38,7 +38,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define SWITCH_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need #define BUTTON_PIN 0 // GPIO for BUTTON (inverted: LOW = pressed, HIGH = released) #define LED_PIN 2 // GPIO for LED (inverted) diff --git a/examples/TV/TV.ino b/examples/TV/TV.ino index cd70561..2ab1a4e 100644 --- a/examples/TV/TV.ino +++ b/examples/TV/TV.ino @@ -37,7 +37,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define TV_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 +#define BAUD_RATE 115200 bool tvPowerState; unsigned int tvVolume; diff --git a/examples/Thermostat/Thermostat.ino b/examples/Thermostat/Thermostat.ino index 5ed615c..22adda1 100644 --- a/examples/Thermostat/Thermostat.ino +++ b/examples/Thermostat/Thermostat.ino @@ -35,7 +35,7 @@ #define APP_KEY "YOUR_APP_KEY_HERE" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR_APP_SECRET_HERE" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define THERMOSTAT_ID "YOUR_DEVICE_ID_HERE" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need float globalTemperature; bool globalPowerState; diff --git a/examples/doorbell/doorbell.ino b/examples/doorbell/doorbell.ino index f1d8c01..5e3d211 100644 --- a/examples/doorbell/doorbell.ino +++ b/examples/doorbell/doorbell.ino @@ -37,7 +37,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define DOORBELL_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need +#define BAUD_RATE 115200 // Change baudrate to your need // change this to your button PIN diff --git a/examples/platformio/platformio.ini b/examples/platformio/platformio.ini index 328bbfa..683d0e2 100644 --- a/examples/platformio/platformio.ini +++ b/examples/platformio/platformio.ini @@ -24,7 +24,7 @@ default_envs = ESP8266 ; ============================================================ upload_speed = 921600 ;upload_port = COM11 -monitor_speed = 9600 +monitor_speed = 115200 ;monitor_port = COM11 lib_deps = diff --git a/examples/temperaturesensor/AHT10/AHT10.ino b/examples/temperaturesensor/AHT10/AHT10.ino index 0b7df98..8994db5 100644 --- a/examples/temperaturesensor/AHT10/AHT10.ino +++ b/examples/temperaturesensor/AHT10/AHT10.ino @@ -47,7 +47,7 @@ Adafruit_AHTX0 aht; #define APP_KEY "" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define TEMP_SENSOR_ID "" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need (used for serial monitor) +#define BAUD_RATE 115200 // Change baudrate to your need (used for serial monitor) #define EVENT_WAIT_TIME 60000 // send event every 60 seconds float humidity; // actual humidity diff --git a/examples/temperaturesensor/DHT22/DHT22.ino b/examples/temperaturesensor/DHT22/DHT22.ino index 29cf8f1..1cbc68c 100644 --- a/examples/temperaturesensor/DHT22/DHT22.ino +++ b/examples/temperaturesensor/DHT22/DHT22.ino @@ -42,7 +42,7 @@ #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define TEMP_SENSOR_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need (used for serial monitor) +#define BAUD_RATE 115200 // Change baudrate to your need (used for serial monitor) #define EVENT_WAIT_TIME 60000 // send event every 60 seconds #if defined(ESP8266) diff --git a/examples/temperaturesensor/HTU21D/HTU21D.ino b/examples/temperaturesensor/HTU21D/HTU21D.ino index 50cad29..1033158 100644 --- a/examples/temperaturesensor/HTU21D/HTU21D.ino +++ b/examples/temperaturesensor/HTU21D/HTU21D.ino @@ -45,7 +45,7 @@ Adafruit_HTU21DF htu = Adafruit_HTU21DF(); #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx" #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx" #define TEMP_SENSOR_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" -#define BAUD_RATE 9600 // Change baudrate to your need (used for serial monitor) +#define BAUD_RATE 115200 // Change baudrate to your need (used for serial monitor) #define EVENT_WAIT_TIME 60000 #if defined(ESP8266) From 8e6fd5752df7581d9d825cc0d95cabd51cc74ed0 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 11:41:50 +0700 Subject: [PATCH 10/17] fix: missing { --- src/SinricProPowerSensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SinricProPowerSensor.h b/src/SinricProPowerSensor.h index 1108177..60bc3bc 100644 --- a/src/SinricProPowerSensor.h +++ b/src/SinricProPowerSensor.h @@ -23,7 +23,7 @@ namespace SINRICPRO_NAMESPACE { class SinricProPowerSensor : public SinricProDevice, public SettingController, public PushNotification, - public PowerSensor, + public PowerSensor { friend class SettingController; friend class PushNotification; friend class PowerSensor; From 4f01261d0d28e53eb92ad20026b2351ab76692e7 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 11:52:14 +0700 Subject: [PATCH 11/17] fix: send event response check added. --- .../AirQualitySensor/AirQualitySensor.ino | 9 ++++- .../AirQualitySensor_gp2y1014au0f.ino | 38 +++++++++++-------- examples/ContactSensor/ContactSensor.ino | 5 ++- .../Lock_with_feedback/Lock_with_feedback.ino | 5 ++- examples/MotionSensor/MotionSensor.ino | 5 ++- examples/PowerSensor/PowerSensor.ino | 4 +- .../MultiSwitch_advance.ino | 6 ++- examples/Switch/Switch/Switch.ino | 6 ++- examples/doorbell/doorbell.ino | 5 ++- 9 files changed, 58 insertions(+), 25 deletions(-) diff --git a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino index 7a53317..8cd943f 100644 --- a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino +++ b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino @@ -92,8 +92,13 @@ void loop() { int pm2_5 = 0; int pm10=0; - mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); + bool success = mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); + if(success) { + Serial.println("Air Quality event sent! .."); + } else { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } + dispatchTime += MIN; - Serial.println("Sending Air Quality event .."); } } \ No newline at end of file diff --git a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino index bf00450..ef700a0 100644 --- a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino +++ b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino @@ -99,21 +99,27 @@ void loop() { SinricPro.handle(); if((long)(millis() - dispatchTime) >= 0) { - Serial.print("Dust density: "); - Serial.print(dustSensor.getDustDensity()); - Serial.print(" ug/m3; Running average: "); - Serial.print(dustSensor.getRunningAverage()); - Serial.println(" ug/m3"); - - SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get air q sensor device - - int pm1=0; - int pm2_5 = dustSensor.getRunningAverage(); - int pm10=0; - - mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); - dispatchTime += MIN; - - Serial.println("Sending Air Quality event .."); + Serial.print("Dust density: "); + Serial.print(dustSensor.getDustDensity()); + Serial.print(" ug/m3; Running average: "); + Serial.print(dustSensor.getRunningAverage()); + Serial.println(" ug/m3"); + + SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get air q sensor device + + int pm1=0; + int pm2_5 = dustSensor.getRunningAverage(); + int pm10=0; + + bool success = mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); + if(success) { + Serial.println("Air Quality event sent! .."); + } else { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } + + dispatchTime += MIN; + + Serial.println("Sending Air Quality event .."); } } \ No newline at end of file diff --git a/examples/ContactSensor/ContactSensor.ino b/examples/ContactSensor/ContactSensor.ino index 425374e..ec2a9bd 100644 --- a/examples/ContactSensor/ContactSensor.ino +++ b/examples/ContactSensor/ContactSensor.ino @@ -66,7 +66,10 @@ void handleContactsensor() { lastContactState = actualContactState; // update last known state lastChange = actualMillis; // update debounce time SinricProContactsensor &myContact = SinricPro[CONTACT_ID]; // get contact sensor device - myContact.sendContactEvent(actualContactState); // send event with actual state + bool success = myContact.sendContactEvent(actualContactState); // send event with actual state + if(!success) { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } } } diff --git a/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino b/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino index 2e03334..4008e75 100644 --- a/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino +++ b/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino @@ -64,7 +64,10 @@ void checkLockState() { Serial.printf("Lock has been %s manually\r\n", currentLockState?"locked":"unlocked"); // print current lock state to serial lastLockState = currentLockState; // update last known lock state SinricProLock &myLock = SinricPro[LOCK_ID]; // get the LockDevice - myLock.sendLockStateEvent(currentLockState); // update LockState on Server + bool success = myLock.sendLockStateEvent(currentLockState); // update LockState on Server + if(!success) { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } } void setupWiFi() { diff --git a/examples/MotionSensor/MotionSensor.ino b/examples/MotionSensor/MotionSensor.ino index 064cd0f..d8786b8 100644 --- a/examples/MotionSensor/MotionSensor.ino +++ b/examples/MotionSensor/MotionSensor.ino @@ -67,7 +67,10 @@ void handleMotionsensor() { lastMotionState = actualMotionState; // update last known state lastChange = actualMillis; // update debounce time SinricProMotionsensor &myMotionsensor = SinricPro[MOTIONSENSOR_ID]; // get motion sensor device - myMotionsensor.sendMotionEvent(actualMotionState); + bool success = myMotionsensor.sendMotionEvent(actualMotionState); + if(!success) { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } } } diff --git a/examples/PowerSensor/PowerSensor.ino b/examples/PowerSensor/PowerSensor.ino index ee0226f..6701439 100644 --- a/examples/PowerSensor/PowerSensor.ino +++ b/examples/PowerSensor/PowerSensor.ino @@ -74,7 +74,9 @@ void sendPowerSensorData() { // send measured data SinricProPowerSensor &myPowerSensor = SinricPro[POWERSENSOR_ID]; bool success = myPowerSensor.sendPowerSensorEvent(powerMeasure.voltage, powerMeasure.current, powerMeasure.power, powerMeasure.apparentPower); - return; + if(!success) { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } } void setupWiFi() { diff --git a/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino b/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino index 2639aeb..01f4936 100644 --- a/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino +++ b/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino @@ -154,7 +154,11 @@ void handleFlipSwitches() { digitalWrite(relayPIN, newRelayState); // set the trelay to the new state SinricProSwitch &mySwitch = SinricPro[deviceId]; // get Switch device from SinricPro - mySwitch.sendPowerStateEvent(newRelayState); // send the event + bool success = mySwitch.sendPowerStateEvent(newRelayState); // send the event + if(!success) { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } + #ifdef TACTILE_BUTTON } #endif diff --git a/examples/Switch/Switch/Switch.ino b/examples/Switch/Switch/Switch.ino index 427feb6..6e89d27 100644 --- a/examples/Switch/Switch/Switch.ino +++ b/examples/Switch/Switch/Switch.ino @@ -79,7 +79,11 @@ void handleButtonPress() { // get Switch device back SinricProSwitch& mySwitch = SinricPro[SWITCH_ID]; // send powerstate event - mySwitch.sendPowerStateEvent(myPowerState); // send the new powerState to SinricPro server + bool success = mySwitch.sendPowerStateEvent(myPowerState); // send the new powerState to SinricPro server + if(!success) { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } + Serial.printf("Device %s turned %s (manually via flashbutton)\r\n", mySwitch.getDeviceId().c_str(), myPowerState?"on":"off"); lastBtnPress = actualMillis; // update last button press variable diff --git a/examples/doorbell/doorbell.ino b/examples/doorbell/doorbell.ino index 5e3d211..497f2dc 100644 --- a/examples/doorbell/doorbell.ino +++ b/examples/doorbell/doorbell.ino @@ -60,7 +60,10 @@ void checkButtonPress() { SinricProDoorbell& myDoorbell = SinricPro[DOORBELL_ID]; // send doorbell event - myDoorbell.sendDoorbellEvent(); + bool success = myDoorbell.sendDoorbellEvent(); + if(!success) { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } } } } From a8a9deda58faace3aa3c08f0a0d7f98c45549cc2 Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 13:23:23 +0700 Subject: [PATCH 12/17] fix: version changed to 2.12.1 --- changelog.md | 2 +- library.json | 2 +- library.properties | 2 +- src/SinricProVersion.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index a171e8c..abf7226 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,5 @@ # Changelog -## Version 2.11.2 +## Version 2.12.1 - Remove PowerStateController from Air Quality, Contact, Motion and Temperature sensor. ## Version 2.11.1 diff --git a/library.json b/library.json index 7a86fd3..9a4d201 100644 --- a/library.json +++ b/library.json @@ -13,7 +13,7 @@ "maintainer": true } ], - "version": "2.11.2", + "version": "2.12.1", "frameworks": "arduino", "platforms": [ "espressif8266", diff --git a/library.properties b/library.properties index cd2b587..cdbe34c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SinricPro -version=2.11.2 +version=2.12.1 author=Boris Jaeger maintainer=Boris Jaeger sentence=Library for https://sinric.pro - simple way to connect your device to alexa diff --git a/src/SinricProVersion.h b/src/SinricProVersion.h index 542ccd2..b536644 100644 --- a/src/SinricProVersion.h +++ b/src/SinricProVersion.h @@ -5,8 +5,8 @@ // Version Configuration #define SINRICPRO_VERSION_MAJOR 2 -#define SINRICPRO_VERSION_MINOR 11 -#define SINRICPRO_VERSION_REVISION 2 +#define SINRICPRO_VERSION_MINOR 12 +#define SINRICPRO_VERSION_REVISION 1 #define SINRICPRO_VERSION STR(SINRICPRO_VERSION_MAJOR) "." STR(SINRICPRO_VERSION_MINOR) "." STR(SINRICPRO_VERSION_REVISION) #define SINRICPRO_VERSION_STR "SinricPro (v" SINRICPRO_VERSION ")" #define SINRICPRO_VERISON_INT SINRICPRO_VERSION_MAJOR * 1000000 + SINRICPRO_VERSION_MINOR * 1000 + SINRICPRO_VERSION_REVISION \ No newline at end of file From 6160467c227f4b892b7b651d75f74e03d4ffcbac Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 13:50:42 +0700 Subject: [PATCH 13/17] fix: change version to 3.1.1 --- changelog.md | 4 ++-- library.json | 2 +- library.properties | 2 +- src/SinricProVersion.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index abf7226..f7a5e96 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # Changelog -## Version 2.12.1 -- Remove PowerStateController from Air Quality, Contact, Motion and Temperature sensor. +## Version 3.1.1 +- BREAKING CHANGE: Remove PowerStateController from Air Quality, Contact, Motion and Temperature sensor. ## Version 2.11.1 - Support Raspberry Pi Pico W diff --git a/library.json b/library.json index 9a4d201..42a21ed 100644 --- a/library.json +++ b/library.json @@ -13,7 +13,7 @@ "maintainer": true } ], - "version": "2.12.1", + "version": "3.1.1", "frameworks": "arduino", "platforms": [ "espressif8266", diff --git a/library.properties b/library.properties index cdbe34c..08a8f95 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SinricPro -version=2.12.1 +version=3.1.1 author=Boris Jaeger maintainer=Boris Jaeger sentence=Library for https://sinric.pro - simple way to connect your device to alexa diff --git a/src/SinricProVersion.h b/src/SinricProVersion.h index b536644..54567e5 100644 --- a/src/SinricProVersion.h +++ b/src/SinricProVersion.h @@ -4,8 +4,8 @@ #define STR(x) STR_HELPER(x) // Version Configuration -#define SINRICPRO_VERSION_MAJOR 2 -#define SINRICPRO_VERSION_MINOR 12 +#define SINRICPRO_VERSION_MAJOR 3 +#define SINRICPRO_VERSION_MINOR 1 #define SINRICPRO_VERSION_REVISION 1 #define SINRICPRO_VERSION STR(SINRICPRO_VERSION_MAJOR) "." STR(SINRICPRO_VERSION_MINOR) "." STR(SINRICPRO_VERSION_REVISION) #define SINRICPRO_VERSION_STR "SinricPro (v" SINRICPRO_VERSION ")" From 580b31959d2439dda5faffd92f7104bebe2b30de Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 15:28:15 +0700 Subject: [PATCH 14/17] fix: support esp32. --- examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino b/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino index a8ad4ef..a130ad3 100644 --- a/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino +++ b/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino @@ -19,7 +19,11 @@ #endif #include -#include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include +#endif #include #include From 288b06c70d8fc4a235767c2041a66a9a57dbb03e Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Mon, 2 Oct 2023 18:22:30 +0700 Subject: [PATCH 15/17] Update changelog.md --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index f7a5e96..881e8f2 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,8 @@ # Changelog ## Version 3.1.1 - BREAKING CHANGE: Remove PowerStateController from Air Quality, Contact, Motion and Temperature sensor. +- Fix examples +- Default Arduino Serial baudrate changed to 115200 ## Version 2.11.1 - Support Raspberry Pi Pico W From f4cdf518114946cf7115a790c027fa6f9053061c Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Tue, 3 Oct 2023 12:42:35 +0700 Subject: [PATCH 16/17] fix: change the version to 3.0.0 --- changelog.md | 2 +- library.json | 2 +- library.properties | 2 +- src/SinricProVersion.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index f7a5e96..70b776f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,5 @@ # Changelog -## Version 3.1.1 +## Version 3.0.0 - BREAKING CHANGE: Remove PowerStateController from Air Quality, Contact, Motion and Temperature sensor. ## Version 2.11.1 diff --git a/library.json b/library.json index 42a21ed..b59a205 100644 --- a/library.json +++ b/library.json @@ -13,7 +13,7 @@ "maintainer": true } ], - "version": "3.1.1", + "version": "3.0.0", "frameworks": "arduino", "platforms": [ "espressif8266", diff --git a/library.properties b/library.properties index 08a8f95..905d997 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SinricPro -version=3.1.1 +version=3.0.0 author=Boris Jaeger maintainer=Boris Jaeger sentence=Library for https://sinric.pro - simple way to connect your device to alexa diff --git a/src/SinricProVersion.h b/src/SinricProVersion.h index 54567e5..1d977ed 100644 --- a/src/SinricProVersion.h +++ b/src/SinricProVersion.h @@ -5,8 +5,8 @@ // Version Configuration #define SINRICPRO_VERSION_MAJOR 3 -#define SINRICPRO_VERSION_MINOR 1 -#define SINRICPRO_VERSION_REVISION 1 +#define SINRICPRO_VERSION_MINOR 0 +#define SINRICPRO_VERSION_REVISION 0 #define SINRICPRO_VERSION STR(SINRICPRO_VERSION_MAJOR) "." STR(SINRICPRO_VERSION_MINOR) "." STR(SINRICPRO_VERSION_REVISION) #define SINRICPRO_VERSION_STR "SinricPro (v" SINRICPRO_VERSION ")" #define SINRICPRO_VERISON_INT SINRICPRO_VERSION_MAJOR * 1000000 + SINRICPRO_VERSION_MINOR * 1000 + SINRICPRO_VERSION_REVISION \ No newline at end of file From ee5b5bb06b0f6ad5609010c42a93660de2b2578b Mon Sep 17 00:00:00 2001 From: Aruna Tennakoon Date: Tue, 3 Oct 2023 16:52:40 +0700 Subject: [PATCH 17/17] fix: indent --- .../AirQualitySensor/AirQualitySensor.ino | 30 ++++++------ .../AirQualitySensor_gp2y1014au0f.ino | 48 +++++++++---------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino index 8cd943f..45f7dc7 100644 --- a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino +++ b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino @@ -85,20 +85,20 @@ void setup() { void loop() { SinricPro.handle(); - if((long)(millis() - dispatchTime) >= 0) { - SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get sensor device - - int pm1 =0; - int pm2_5 = 0; - int pm10=0; - - bool success = mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); - if(success) { - Serial.println("Air Quality event sent! .."); - } else { - Serial.printf("Something went wrong...could not send Event to server!\r\n"); - } + if((long)(millis() - dispatchTime) >= 0) { + SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get sensor device + + int pm1 =0; + int pm2_5 = 0; + int pm10=0; + + bool success = mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); + if(success) { + Serial.println("Air Quality event sent! .."); + } else { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } - dispatchTime += MIN; - } + dispatchTime += MIN; + } } \ No newline at end of file diff --git a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino index ef700a0..70fc120 100644 --- a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino +++ b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino @@ -98,28 +98,28 @@ void setup() { void loop() { SinricPro.handle(); - if((long)(millis() - dispatchTime) >= 0) { - Serial.print("Dust density: "); - Serial.print(dustSensor.getDustDensity()); - Serial.print(" ug/m3; Running average: "); - Serial.print(dustSensor.getRunningAverage()); - Serial.println(" ug/m3"); - - SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get air q sensor device - - int pm1=0; - int pm2_5 = dustSensor.getRunningAverage(); - int pm10=0; - - bool success = mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); - if(success) { - Serial.println("Air Quality event sent! .."); - } else { - Serial.printf("Something went wrong...could not send Event to server!\r\n"); - } - - dispatchTime += MIN; - - Serial.println("Sending Air Quality event .."); - } + if((long)(millis() - dispatchTime) >= 0) { + Serial.print("Dust density: "); + Serial.print(dustSensor.getDustDensity()); + Serial.print(" ug/m3; Running average: "); + Serial.print(dustSensor.getRunningAverage()); + Serial.println(" ug/m3"); + + SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_ID]; // get air q sensor device + + int pm1=0; + int pm2_5 = dustSensor.getRunningAverage(); + int pm10=0; + + bool success = mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10, "PERIODIC_POLL"); + if(success) { + Serial.println("Air Quality event sent! .."); + } else { + Serial.printf("Something went wrong...could not send Event to server!\r\n"); + } + + dispatchTime += MIN; + + Serial.println("Sending Air Quality event .."); + } } \ No newline at end of file