How to get relay state?
-
repeater started, id 100
send: 100-100-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
send: 100-100-0-0 s=255,c=3,t=11,pt=0,l=5,st=ok:Relay
send: 100-100-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 100-100-0-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=3,c=0,t=3,pt=0,l=5,st=ok:1.4.1I have 3 relays and i want to make a logic something like this; if 3.relay is on than 1. relay is off
How can i get relay status in orginal sketch?
"
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
gw.saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
"
-
On http://www.mysensors.org/build/relay you will find apart from the Relay also a RelayWithButtonActuator Example.
Do you have some kind of feedback from the relay indicating it's status? If so, connect that to the button input and done!
-
@daulagari Thank you. i am trying to learn "message.xxxxx" but it is hard for me.
How can i get 1-2-3 variables from "message.xxxxx"? So i can find which relay get a command.
send: 100-100-0-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=3,c=0,t=3,pt=0,l=5,st=ok:1.4.1http://www.mysensors.org/build/sensor_api#the-full-api this link is very useful but very hard for me...
+++ i have some trouble with your link ; http://forum.mysensors.org/topic/738/relaywithbuttonactuator-example-with-touch-sensor/7
-
-
@BulldogLowell That's it! Thank you
if (message.sensor==1 && message.getBool()==true)
{....
Suggested Topics
-
Day 1 - Status report
Announcements ā¢ 23 Mar 2014, 22:45 ā¢ hek 24 Mar 2014, 20:12 -
Raspberry Pi 5: invalid GPIO 9
Troubleshooting ā¢ 27 Aug 2024, 13:20 ā¢ igo 27 Aug 2024, 13:20 -
Echo request is not set
Troubleshooting ā¢ 12 Aug 2024, 15:36 ā¢ kamilb85 3 Sept 2024, 08:58 -
Getting system time from the controller
Troubleshooting ā¢ 27 Feb 2025, 01:39 ā¢ dpcons 29 days ago -
Compiling Sensor code using BME280 and ESP8266
Troubleshooting ā¢ 26 Feb 2025, 00:32 ā¢ dpcons 26 Feb 2025, 06:22 -
Can not compile MySensors on esp8266
Troubleshooting ā¢ 24 Aug 2024, 15:35 ā¢ TheoL 29 Aug 2024, 20:47