Comminucation without controller
-
Sometimes i forgot to plug usb serial and my sensors, relays stoped after 2-3 times what they do normaly. Is there any way if these nodes stop working than reboot itself? Or any idea to keep working?
-
How can i get "fail" to a String from serial monitor?
send: 51-51-0-0 s=1,c=1,t=2,pt=2,l=2,st=fail:0
-
You get a fail if no hw-ack is received from the recipient.
-
@hek Thank you but my goal is to keep it working when there is no controller. My light will not be on or off if there is no controller so i want to add a some code like this;
"
re = String(message.sensor);
if (re.indexOf("fail") >=0)
{
asm volatile (" jmp 0"); //reboot
}
"
-
Sorry, I don't understand what your setup looks like or what your´re trying to archive.
-
@hek I am using Relay with Button sketch. When there is no controller-no hw-ack, my lights work 2-3 more times and i got "fail" then i can't change the lights state manually.
When i see "fail" i have to restart the nano.
-
The hw ack is handled by the library/radio itself. Controller is not involved.
So, what is your button sketch communicating with?
-
This Sketch works 1 on and 1 off when there is no controller;
repeater started, id 0
send: 0-0-0-0 s=255,c=0,t=18,pt=0,l=5,st=fail:1.4.1
send: 0-0-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
send: 0-0-0-0 s=255,c=3,t=11,pt=0,l=5,st=fail:Relay
send: 0-0-0-0 s=255,c=3,t=12,pt=0,l=3,st=fail:1.0
send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=5,st=fail:1.4.1
**send: 0-0-0-0 s=1,c=1,t=2,pt=2,l=2,st=fail:0
send: 0-0-0-0 s=1,c=1,t=2,pt=2,l=2,st=fail:0
**
"#include <MySensor.h>
"#include <SPI.h>
"#include <Bounce2.h>"#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
"#define NUMBER_OF_RELAYS 1 // Total number of attached relays
"#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
"#define CHILD_ID 1"#define TRIGGER_PIN 7 // Arduino pin tied to trigger pin on the ultrasonic sensor.
unsigned long SLEEP_TIME = 700; // Sleep time between reads (in milliseconds)MySensor gw;
//int hey =50;int dist;
int kac;
int value;
int oldValue=0;
bool state;
Bounce debouncer = Bounce();
Bounce debouncer2 = Bounce();
MyMessage msg(CHILD_ID, V_LIGHT);void setup()
{
gw.begin(incomingMessage, AUTO, true);
gw.sendSketchInfo("Relay", "1.0");
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
gw.present(sensor, S_LIGHT);
pinMode(pin, OUTPUT);
state = gw.loadState(CHILD_ID);
digitalWrite(pin, state?RELAY_ON:RELAY_OFF);
}
debouncer.attach(TRIGGER_PIN);
debouncer2.attach(RELAY_1);
debouncer.interval(5); debouncer2.interval(5);
}void loop()
{
gw.process();
debouncer.update();
dist = debouncer.read();
debouncer2.update();
kac = debouncer2.read();if (dist == 0) { if(kac==0 ) //MANUAL ON-OFF { digitalWrite(RELAY_1, HIGH ); // gw.send(msg.set(1)); delay(1000); // gw.sleep(SLEEP_TIME); } else //MANUAL ON-OFF { digitalWrite(RELAY_1, LOW ); // gw.send(msg.set(0)); delay(1000);// gw.sleep(SLEEP_TIME); } } //NORMAL PROCESS FOR MYSENSORS.h if (dist != oldValue && dist==0) { gw.send(msg.set(state?false:true), true); // Send new state and request ack back } oldValue = dist; }
void incomingMessage(const MyMessage &message) {
if (message.type==V_LIGHT) {
// digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
gw.saveState(message.sensor, message.getBool());
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}}
-
Wierd. even if the node loses it's parent it should retry finding a new each time you press the "button" and send a new state.
-
There has been a few edge-case bugfixes done recently on github/master.
Could you just download latest and try the again to check if it has been fixed already?
-
repeater started, id 0
You cannot use id=0 for a repeater node.
Id 0 is reserved for gateway.
-
New master file didn't make difference. When i see "fail" i can't change the state with original RelayWithButtonActuator sketch.
Ok id is not "0" now.