ESP EasyRelay little mod

9 years 2 months ago #260 by EasyIoT
Replied by EasyIoT on topic ESP EasyRelay little mod

cdj wrote: Oh yes, but i can write in this area ?


ups, now I've created category under Community project.

Please Log in or Create an account to join the conversation.

9 years 2 months ago #273 by cdj
Replied by cdj on topic ESP EasyRelay little mod
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:
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
...but i REALLY don't understand syntax.
#define RELAY_ON 1  // GPIO value to write to turn on attached relay
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
how to use it? how it works message.getBool()?RELAY_ON:RELAY_OFF)/code] ? help ! :) D.[code]message.getBool()?RELAY_ON:RELAY_OFF)/code] ?

help ! :)
D.

Please Log in or Create an account to join the conversation.

9 years 2 months ago #279 by cdj
Replied by cdj on topic ESP EasyRelay little mod
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. :(

Attachments:

Please Log in or Create an account to join the conversation.

9 years 2 months ago - 9 years 2 months ago #280 by cdj
Replied by cdj on topic ESP EasyRelay little mod
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
Attachments:

Please Log in or Create an account to join the conversation.

9 years 2 months ago #282 by EasyIoT
Replied by EasyIoT on topic ESP EasyRelay little mod

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));

Please Log in or Create an account to join the conversation.

9 years 2 months ago - 9 years 2 months ago #283 by cdj
Replied by cdj on topic ESP EasyRelay little mod
Thanks for prompt reply !

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....

UPUPUP !

Thanks
Dario

Please Log in or Create an account to join the conversation.

Time to create page: 0.489 seconds

Forum latest

  • No posts to display.