question about repeater node
-
hi guys
i have one question
if i want all of my nodes be also a repeater node , so i just add this line to all of sensors?
#define MY_REPEATER_FEATUREor also add this : ( for example motion sensor)
sendSketchInfo("Motion Sensor", "1.0");
sendSketchInfo("Repeater Node", "1.0");
???
-
@Reza the sketch info is just a human-friendly name. It does not affect the functionality. So you can put anything you like there.
-
@Reza said:
#define MY_REPEATER_FEATURE
hi my friend you speak about this line ?
sendSketchInfo("Repeater Node", "1.0");
can I delete it from sketch ?
so for convert each sensors and each relay actor to repeater +sensor just enough add this line ?
#define MY_REPEATER_FEATURE
???
-
I don't know.
-
yes add the line but only on non battery powered nodes.
If battery powered this will kill battery life.
I have a couple repeater nodes at home to extend the range.
-
@tlpeter
hi my friend .thank you
all of my node are non battery powered and no problem. but just my question about codes.
just i add this line ? (#define MY_REPEATER_FEATURE) and dont need any change in sketch?for example delete this line :
sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); ???
-
@Reza - it depends on what you want to do, and in which sketch.
Maybe you should post your sketch and explain what you are planning to do.Generally you just add
#define MY_REPEATER_FEATURE
to make it a repeater node and as you said, remove thesleep()
function.
-
@sundberg84 said:
it depends on what you want to do, and in which sketch.
Maybe you should post your sketch and explain what you are planning to do.Generally you just add #define MY_REPEATER_FEATURE to make it a repeater node and as you said, remove the sleep() function.
for example: #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Motion Sensor", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_MOTION); } void loop() { // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. ** sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);** }
-
@Reza - I added ``` so your code is easier to read.
Remove:
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
Remove:** sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);**
Add:#define MY_REPEATER_FEATURE
below #define MY_RADIO_NRF24You also might want to add send() with a If statement so it doesnt sent all the time. The example code is build on a interupt.
For example:
void loop() { //Read digital motion value tripped = digitalRead(DIGITAL_INPUT_SENSOR); if (tripped != oldTripped){ Serial.println("Motion"); send(msg.set(tripped?"1":"0")); // Send tripped value to gw oldTripped = tripped; }}
I have one example at github: https://github.com/sundberg84/MySensors-2.0/blob/master/MotionRep/MotionRepAS.ino
-
@sundberg84
thank you my friend