[SOLVED] Node not uisng it´s ID!?
-
I have a problem with one of my nodes. I assigned Node ID 10 to it, but it seems like it´s requesting an ID from the gateway!? This is my gateway output when I power on the Node:
0;255;3;0;9;3513128927 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;3513128933 TSF:MSG:BC 0;255;3;0;9;3513128936 TSF:MSG:FPAR REQ,ID=255 0;255;3;0;9;3513128941 TSF:PNG:SEND,TO=0 0;255;3;0;9;3513128944 TSF:CKU:OK 0;255;3;0;9;3513128947 TSF:MSG:GWL OK 0;255;3;0;9;3513130002 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0 0;255;3;0;9;3513130893 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 0;255;3;0;9;3513130900 Sending message on topic: mygateway1-out/255/255/3/0/3 0;255;3;0;9;3513132862 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 0;255;3;0;9;3513132869 Sending message on topic: mygateway1-out/255/255/3/0/3 0;255;3;0;9;3513134829 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 0;255;3;0;9;3513134836 Sending message on topic: mygateway1-out/255/255/3/0/3 0;255;3;0;9;3513136797 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 0;255;3;0;9;3513136804 Sending message on topic: mygateway1-out/255/255/3/0/3 0;255;3;0;9;3513148605 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;3513148612 TSF:MSG:BC 0;255;3;0;9;3513148615 TSF:MSG:FPAR REQ,ID=255 0;255;3;0;9;3513148619 TSF:PNG:SEND,TO=0 0;255;3;0;9;3513148623 TSF:CKU:OK
and this is my Node´s sketch:
#define MY_RADIO_NRF24 #include <MySensors.h> #include <SPI.h> // Define Node ID #define MY_NODE_ID 10 #define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC //Batterysensor int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point int oldBatteryPcnt = 0; #define CHILD_ID_BATT 7 //Kontaktschalter #define CHILD_ID 1 #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch //MySensor gw; // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(CHILD_ID,V_TRIPPED); MyMessage msgbatt(CHILD_ID_BATT,V_VOLTAGE); void setup() { int buzzer = 7; //Buzzer Anschlusspin pinMode(buzzer, OUTPUT); pinMode(13,OUTPUT); digitalWrite(13,HIGH); digitalWrite(buzzer, HIGH); wait(50); digitalWrite(buzzer, LOW); wait(50); digitalWrite(buzzer, HIGH); wait(50); digitalWrite(buzzer, LOW); wait(50); digitalWrite(buzzer, HIGH); wait(50); digitalWrite(buzzer, LOW); //gw.begin(NULL, MY_NODE_ID, true); // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); //Batterysensor // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif // Send the sketch version information to the gateway and Controller } // Register binary input sensor to gw (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. void presentation() { sendSketchInfo("Wohunungstuer Alarm", "1.0"); wait(500); present(CHILD_ID, S_DOOR); wait(500); } // Check if digital input has changed and send in new value void loop() { //Türkontakt prüfen: uint8_t value; static uint8_t sentValue = 2; value = digitalRead(BUTTON_PIN); if (value==HIGH){ //Buzzer wird ausgelöst int buzzer = 7; //Buzzer Anschlusspin pinMode(buzzer, OUTPUT); digitalWrite(buzzer, HIGH); wait(500); digitalWrite(buzzer, LOW); wait(500); digitalWrite(buzzer, HIGH); wait(500); digitalWrite(buzzer, LOW); wait(500); digitalWrite(buzzer, HIGH); wait(500); digitalWrite(buzzer, LOW); wait(2000); digitalWrite(buzzer, HIGH); wait(500); digitalWrite(buzzer, LOW); wait(500); digitalWrite(buzzer, HIGH); wait(500); digitalWrite(buzzer, LOW); wait(500); digitalWrite(buzzer, HIGH); wait(500); digitalWrite(buzzer, LOW); } // Short wait to allow buttons to properly settle wait(5); //Batterysensor // get the battery Voltage int sensorValue = analogRead(BATTERY_SENSE_PIN); #ifdef DEBUG Serial.println(sensorValue); #endif // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 float batteryV = sensorValue * 0.003363075; int batteryPcnt = sensorValue / 10; #ifdef DEBUG Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); #endif if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep sendBatteryLevel(batteryPcnt); wait(500); send(msgbatt.set(batteryPcnt),true); wait(500); oldBatteryPcnt = batteryPcnt; } if (value != sentValue) { // Value has changed from last transmission, send the updated value send(msg.set(value == HIGH ? 1 : 0),true); wait(500); sentValue = value; } // Sleep until something happens with the sensor digitalWrite(13,LOW); Serial.println("Sleep"); sleep(BUTTON_PIN - 2, CHANGE);// changing Secondary button to correct pin (-3) does not work. So keep it on (-2) }
What is wrong here?
-
Move the MySensors include below your defines...
-
damn it, that did the trick!! Just haven´t noticed...
Thx for your superfast support!!