Comments (10)
Seems, your baudrate is wrong. (I cant see this in screenshot). Please check for correct settings!
"only need state of relay" ... Can you tell more about this? What do you want to achieve, and why do you use a garagedoor device for this?
from esp8266-esp32-sdk.
I just tried a round... it's a unfortunate screenshot sorry. To my aim: I switched a relay in parallel to a load (roomlight) which I want monitore. With the contacts of the relay, I want send a HIGH or a LOW signal to SinricPro, so that it knows if it's on or off. Futuremore I will realize something like a cross-switch-relay with two other relays so that I can expand the existing toggle circuit with an additional switch position over my voice. For this, Alexa must know the current state
from esp8266-esp32-sdk.
from esp8266-esp32-sdk.
What's about serial monitor issue? Is this solved? (Even this is not related to SinricPro)
I think you will agree that using a garagedoor device is the the wrong way here ;)
Please take a look at Light example. I think a SinricProLight is what you're looking for.
Since you only want to turn it on and off, you only need to implement onPowerState callback for this.
Remove the print
statement, and exchange it with the code, needed to control your cicruit.
from esp8266-esp32-sdk.
Yeah, the point was/is that usually I had to know what's the current light state, else if I only toggle my "cross-switch-relay", once I switch one of the two other just existing switches, I had to switch the light inverted (if I want switch on light, I had to tell: "Alexa turn of the roomlight").
For this I would know how to read it, or rather to realize when it changes his state (read the input periodically with a timer or only once when state changed over an interrupt function).
The main problem is that until now I not able to sinchronize any input signal with sinricPro.
from esp8266-esp32-sdk.
So, i guess Serial Monitor is not a problem anymore?
To update state on SinricPro Server, use sendPowerStateEvent
function (see here)
But please make sure, only send Events when state changed!
To check the current state of the relay, use a simple digitalRead.
You can do this within the loop, or via interrupt.
Are you familar with programming interrupts? This will request to set a flag and handles all other things outside the interrupt function!
If you have to say "turn off" to turn on your device, you have to invert your digitalWrite.
from esp8266-esp32-sdk.
In reality I dont need to know usually the current state and when it changed. (thinking) I must know it only when I ask Alexa. So an interrupt would be unnecessary. Always I switch the roomlight manually it doesn
t interest Alexa, but when I command her to switch it she have to know it. So, as you told me, idea one (put it within the loop) sould work in practice
from esp8266-esp32-sdk.
If you don't update the current state to SinricPro server, the state will shown incorrect in Alexa App. If you have the possibillity to check the current state, you should update (only if there was a change), using the corresponding event function.
Anyways, your sketch have to know the current state (not Alexa) to control the relais correctly.
Btw, the screenshot showing german words: I live near Hamburg ;)
from esp8266-esp32-sdk.
Hallo silvar2311,
jetzt melde ich mich doch noch mal. Es geht um das Einlesen eines Eingangs (Pin D4) mittels Interrupt Routine. Wollte eigentlich den benötigen Wert bei Statusänderung auslesen und in eine Variable schreiben. Es scheint jedoch als ob die Interrupt-Routine kontinuierlich abgearbeitet wird. Der Serielle Monitor gibt jedenfalls nur "Mist" aus.
Die Idee dahinter war, dass Func_Roomlight über den Interrupt Pin D4 aufgerufen und dort die Variable RoomlightState überschrieben wird.
`#define Out_Roomlight 0 // GPIO WemosPin D3 für Raumlicht schalten (schalte Relais 1K01+1K02)
#define In_Roomlight 2 // GPIO WemosPin D4 für Raumlicht Status (Relais 1K09)
#define TestPin 5 //GPIO WemosPin D1 für Testzwecke
volatile byte RoomlightState = LOW; //Raumlichtstatus
bool myPowerState = false;
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;
digitalWrite(Out_Roomlight, myPowerState);
return true;
}
void setupWiFi() {
Serial.printf("\r\n[Wifi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
Serial.printf(".");
delay(250);
}
Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str());
}
void setupSinricPro() {
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
mySwitch.onPowerState(onPowerState);
SinricPro.onConnected( {
Serial.printf("Connected to SinricPro\r\n");
});
SinricPro.onDisconnected( {
Serial.printf("Disconnected from SinricPro\r\n");
});
SinricPro.begin(APP_KEY, APP_SECRET);
}
void setup() {
pinMode(TestPin, OUTPUT);
pinMode(Out_Roomlight, OUTPUT);
pinMode(In_Roomlight, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(In_Roomlight), Func_RoomlightState, CHANGE);
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
setupWiFi();
setupSinricPro();
}
void loop() {
SinricPro.handle();
}
void Func_RoomlightState() {
RoomlightState = digitalRead(In_Roomlight);
if (RoomlightState == HIGH) {
digitalWrite(TestPin, HIGH);
}
if (RoomlightState == LOW) {
digitalWrite(TestPin, LOW);
}
}
//Func_Roomlight wird immer aufgerufen wenn In_Roomlight mit Masse verbunden wird oder von Masse getrennt wird
//Func_Roomlight liest lediglich den aktuellen Raumlichtstatus aus
//RoomlightState == HIGH wenn In_Roomlight NICHT mit Masse verbunden ist (Raumlicht = aus)
//RoomlightState == LOW wenn In_Roomlight mit Masse verbunden ist (Raumlicht = ein)
`
from esp8266-esp32-sdk.
Hi! Kannst du mich mal per E-Mail kontaktieren ([email protected]).
Dann können wir mal Daten zu WhatsApp oder Telegramm austauschen und direkt schreiben.
Was hältst Du davon?
from esp8266-esp32-sdk.
Related Issues (20)
- Emulating a momentary switch with Sinric Pro HOT 2
- I'm stuck coding for multiple devices. (ESP8266) HOT 10
- missing capability on AC Unit HOT 3
- Manual Push switch not working when disconnected from internet. HOT 8
- Connection rest by peer HOT 12
- Compilation error: invalid user-defined conversion from 'SINRICPRO_3_0_1::SinricProClass::Proxy' to 'SinricProDoorbell&&' {aka 'SINRICPRO_3_0_1::SinricProDoorbell&&'} [-fpermissive] HOT 5
- Error compiling code - probably upon recent update to ArduinoJSON HOT 2
- sinric app somtimes unresponsive app and serial different values HOT 27
- Sinric Pro With ESP8266 and OLED SSD1306 Display HOT 5
- Enable and Disable A4988 stepper driver with ESP8266 digital pin HOT 3
- Issues with Sending Sensor Data to Sinric Pro from ESP32 HOT 3
- Error compiling code - vtable undefined HOT 14
- OTA with non-local network HOT 4
- Temperature Sensor Type and Alexa HOT 3
- Arduino uno r4 wifi HOT 4
- Adding device through the app HOT 3
- Button to turn on a RGB strip light HOT 2
- AC Unit HOT 7
- help dear HOT 2
- Switch state change time out. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp8266-esp32-sdk.