Closed medavid008 closed 3 years ago
Which SinricPro Version do you use?
SinricPro 2.9.0 added to libraries today.
Sorry, i missed another line.... please standby
Okay, now it should compile without any issues.
I should redownload zip unpack and replace the files in arduino IDE libraries folder. NOT try to reinstall the library?
Uninstall via Libraries Manager:
Download ZIP file
Install ZIP-File:
Great, thanks. It works now.
Hello, I have errors compiling ContactSensor.ino, for ESP8266. I'm using even adafruit feather Huzzah ESP8266. For unmodified ContactSensor.ino example I get the following when verifying or compiling:
In file included from ...\Arduino\libraries\SinricPro\examples\ContactSensor\ContactSensor.ino:35:0: ...\Arduino\libraries\SinricPro\src/SinricProContactsensor.h:22:57: error: expected template-name before '<' token public ContactEventSource {
^
...\Arduino\libraries\SinricPro\src/SinricProContactsensor.h:22:57: error: expected '{' before '<' token
...\Arduino\libraries\SinricPro\src/SinricProContactsensor.h:22:57: error: expected unqualified-id before '<' token
exit status 1
I have dependencies libraries installed.
Thanks you very much, any help would be appreciated.
The code of your example is: ////////////////////////////////////////////////////////////////////// /*
// Uncomment the following line to enable serial debug output //#define ENABLE_DEBUG
ifdef ENABLE_DEBUG
endif
include
ifdef ESP8266
endif
ifdef ESP32
endif
include "SinricPro.h"
include "SinricProContactsensor.h"
define WIFI_SSID "YOUR-WIFI-SSID"
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 CONTACT_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
define BAUD_RATE 9600 // Change baudrate to your need
define CONTACT_PIN 5 // PIN where contactsensor is connected to
bool myPowerState = true; // assume device is turned on bool lastContactState = false; unsigned long lastChange = 0;
/**
LOW = contactsensor is open */ void handleContactsensor() { if (!myPowerState) return; // if device switched off...do nothing
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
if (actualContactState != lastContactState) { // if state has changed Serial.printf("Contactsensor is %s now\r\n", actualContactState?"open":"closed"); 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 } }
/**
// setup function for WiFi connection void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting"); WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } IPAddress localIP = WiFi.localIP(); Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]); }
// setup function for SinricPro 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"); }); SinricPro.begin(APP_KEY, APP_SECRET); }
// main setup function void setup() { Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
pinMode(CONTACT_PIN, INPUT);
setupWiFi(); setupSinricPro(); }
void loop() { handleContactsensor(); SinricPro.handle(); }