Ok guy but now i must resolv a very difficult thing for me, i think that could be interesting for everybody.
If we need to turn on the lights and we have normal home 220 relay i suppose that we must "simulate" a "impulse" switch with our relay. How we can OPEN and CLOSE immediately relay?
Obviously in this mod ON and OFF must be the same command (OPENandshortCLOSE) but :
1) can we have status from a normal relay? can we interact with this 220v relay with our normal 5v 10a relay for arduino?
2)Is it necessary to use an "automation" script that do "turn on lights" and "turn off lights" to simulate an "impulse" ? i've tried without success to duplicate row:
Ok after one day of googling i've realized that for a single relay i must have also a digital input value that give me state of existing relay of my home. I've found this scheme that pheraps is good... but not sure.
cdj wrote: Ok, i suppose that this is correct connection scheme.
this X and Y connection as a digital input in arduino can tell me relay status.
But how to tell to easyiot that my relay is open (light on) or closed (light off) ?
PLEASE UUUUUUUUP ! C'mon guys pheraps it's a simple question for you !
Thanks
Dario
The wiring should work. In program try this:
in declaration:
Esp8266EasyIoTMsg msgRelay(RELAY_1, V_DIGITAL_VALUE);
and then send status of relay based on arduino pin which is connected to relay
esp.send(msgRelay.set((uint8_t)1));
or
esp.send(msgRelay.set((uint8_t)0));
We suppose to put X in arduino pin 4
So code will be :
void incomingMessage(const Esp8266EasyIoTMsg &message) {
// We only expect one type of message from controller. But we better check anyway.
// MOD FOR CHECK EXISTING RELAY STATE
Esp8266EasyIoTMsg msgRelay(RELAY_1, V_DIGITAL_VALUE);
esp.send(msgRelay.set((uint4_t)1)); //or try esp.send(msgRelay.set((uint4_t)0));
//END MOD
Serial.println("New message");
if (message.type==V_DIGITAL_VALUE) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
Is it correct ?
AND FOR SECURITY REASON I'VE DECIDED TO PUT A SIMPLE PHOTORESISTOR WITH SMALL NEONLAMP IN PARALLEL WITH HOUSE LAMP to check if lamp is on or off.
In this way when i open "living room" all the sensors immediately notify me if a node is on or off? tell me yes, this is my goal !
And HOW TO simulate a button? I need not to change state if i TURN ON LIGHTS for ex. but the action must be open/close for 200/300ms .... just time to activate home relays....