Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Node to Node Communication via Gatreway

Node to Node Communication via Gatreway

Scheduled Pinned Locked Moved Development
19 Posts 5 Posters 3.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkandasa
    Plugin Developer
    wrote on last edited by
    #5
    #define NODE_ID (int8_t) 1
    #define N_LEVEL_DISPLAY_ID (int8_t) 3
    #define S_LEVEL_DISPLAY_ID (int8_t) 1
    
    MySensor gw;
     gw.begin(incomingMessage, NODE_ID, true);
    MyMessage levelDisplayBoard(S_LEVEL_DISPLAY_ID, V_DISTANCE);
    levelDisplayBoard.setDestination(N_LEVEL_DISPLAY_ID);
    int dist = getDistance();
    gw.send(levelDisplayBoard.set(dist));
    
    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #6

      I think node 1 has a corrupt routing table (it thinks node 3 is a child).

      Try clearing eeprom and re-upload your sketch. Or disable repeater-mode on it.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jkandasa
        Plugin Developer
        wrote on last edited by
        #7

        How to print routing table in serial console?

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #8

          You have to read it from eeprom.
          It starts at position: EEPROM_ROUTES_ADDRESS (defined in MySensors.h)

          http://www.arduino.cc/en/Tutorial/EEPROMRead

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jkandasa
            Plugin Developer
            wrote on last edited by
            #9

            @hek you are right! There was an entry for Node-2 in Node-1 routing table, As it has direct access to Node-2, was trying to send directly. I removed the entry and now it's going throw gateway. All node works well. Perfect!

            I thing we have to add code to remove routing table entry dynamically if it face some N number of failures. It will make life easier for those who is shifting node from one location to another location often.

            1 Reply Last reply
            1
            • F Offline
              F Offline
              FullMetal
              wrote on last edited by
              #10

              Hello,

              Sorry to resort to an old topic ...
              I am currently using mysensors RS485, and I would like to extend my installation with this protocol.
              and I would like to make the nodes communicate with each other through the gateway.
              But I can't do what I want ... help!
              on my node 4, I have an input and 1 output, the input activates and deactivates the output. (here no worries).
              On my node 5, I have an input to activate the output of node 4, so I can turn it off but not turn it on, and I don't see any frames towards the gateway

              here is the code for my node 5:

              // MySensors 
              #define MY_PARENT_NODE_ID 0                   // define if fixed parent
              #define MY_PARENT_NODE_IS_STATIC
              #undef MY_REGISTRATION_FEATURE                  // sketch moves on if no registration
              #define MY_NODE_ID 5                     // fixed node number
              
              // Enable debug prints to serial monitor
              #define MY_DEBUG
              
              // Enable RS485 transport layer
              #define MY_RS485
              
              // Define this to enables DE-pin management on defined pin
              #define MY_RS485_DE_PIN 2
              
              // Set RS485 baud rate to use
              #define MY_RS485_BAUD_RATE 9600
              
              // Set blinking period
              #define MY_DEFAULT_LED_BLINK_PERIOD 300
              
              // Flash leds on rx/tx/err
              //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
              //#define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
              //#define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
              
              
              // Enable this if RS485 is connected to a hardware serial port
              //#define MY_RS485_HWSERIAL Serial1
              //#include <MqttClient.h>
              #include <SPI.h>
              #include <MySensors.h>
              #include <Bounce2.h>
              
              #define CHILD_ID 4
              #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
              
              Bounce debouncer = Bounce(); 
              int oldValue=0;
              bool state;
              
              // Change to V_LIGHT if you use S_LIGHT in presentation below
              MyMessage msg(CHILD_ID,V_LIGHT);
              
              void setup()  
              {  
                // Setup the button
                pinMode(BUTTON_PIN,INPUT_PULLUP);
                // Activate internal pull-up
                //digitalWrite(BUTTON_PIN,HIGH);
                
                // After setting up the button, setup debouncer
                debouncer.attach(BUTTON_PIN);
                debouncer.interval(5);
                
              }
              
              void presentation() {
                // 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.
                sendSketchInfo("Button", "1.1");
              
                
                present(CHILD_ID, S_LIGHT);  
              }
              
              
              //  Check if digital input has changed and send in new value
              void loop() 
              {
                debouncer.update();
                // Get the update value
                int value = debouncer.read();
                if (value != oldValue && value==0) {
                    msg.setDestination(4);
                    send(msg.set(state?false:true), false);// Send new state and request ack back
                }
                oldValue = value;
              }  
              
              rejoe2R 1 Reply Last reply
              0
              • F FullMetal

                Hello,

                Sorry to resort to an old topic ...
                I am currently using mysensors RS485, and I would like to extend my installation with this protocol.
                and I would like to make the nodes communicate with each other through the gateway.
                But I can't do what I want ... help!
                on my node 4, I have an input and 1 output, the input activates and deactivates the output. (here no worries).
                On my node 5, I have an input to activate the output of node 4, so I can turn it off but not turn it on, and I don't see any frames towards the gateway

                here is the code for my node 5:

                // MySensors 
                #define MY_PARENT_NODE_ID 0                   // define if fixed parent
                #define MY_PARENT_NODE_IS_STATIC
                #undef MY_REGISTRATION_FEATURE                  // sketch moves on if no registration
                #define MY_NODE_ID 5                     // fixed node number
                
                // Enable debug prints to serial monitor
                #define MY_DEBUG
                
                // Enable RS485 transport layer
                #define MY_RS485
                
                // Define this to enables DE-pin management on defined pin
                #define MY_RS485_DE_PIN 2
                
                // Set RS485 baud rate to use
                #define MY_RS485_BAUD_RATE 9600
                
                // Set blinking period
                #define MY_DEFAULT_LED_BLINK_PERIOD 300
                
                // Flash leds on rx/tx/err
                //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
                //#define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
                //#define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
                
                
                // Enable this if RS485 is connected to a hardware serial port
                //#define MY_RS485_HWSERIAL Serial1
                //#include <MqttClient.h>
                #include <SPI.h>
                #include <MySensors.h>
                #include <Bounce2.h>
                
                #define CHILD_ID 4
                #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                
                Bounce debouncer = Bounce(); 
                int oldValue=0;
                bool state;
                
                // Change to V_LIGHT if you use S_LIGHT in presentation below
                MyMessage msg(CHILD_ID,V_LIGHT);
                
                void setup()  
                {  
                  // Setup the button
                  pinMode(BUTTON_PIN,INPUT_PULLUP);
                  // Activate internal pull-up
                  //digitalWrite(BUTTON_PIN,HIGH);
                  
                  // After setting up the button, setup debouncer
                  debouncer.attach(BUTTON_PIN);
                  debouncer.interval(5);
                  
                }
                
                void presentation() {
                  // 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.
                  sendSketchInfo("Button", "1.1");
                
                  
                  present(CHILD_ID, S_LIGHT);  
                }
                
                
                //  Check if digital input has changed and send in new value
                void loop() 
                {
                  debouncer.update();
                  // Get the update value
                  int value = debouncer.read();
                  if (value != oldValue && value==0) {
                      msg.setDestination(4);
                      send(msg.set(state?false:true), false);// Send new state and request ack back
                  }
                  oldValue = value;
                }  
                
                rejoe2R Offline
                rejoe2R Offline
                rejoe2
                wrote on last edited by
                #11

                @FullMetal Imo, you have to specify all send-settings in one line, e.g. like this:

                send(buttonMsg.setDestination(MY_SISTER_NODE_ID).setSensor(CHILD_ID_RESET).set( button[i] ? "1" : "0"));
                

                Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                F 1 Reply Last reply
                0
                • rejoe2R rejoe2

                  @FullMetal Imo, you have to specify all send-settings in one line, e.g. like this:

                  send(buttonMsg.setDestination(MY_SISTER_NODE_ID).setSensor(CHILD_ID_RESET).set( button[i] ? "1" : "0"));
                  
                  F Offline
                  F Offline
                  FullMetal
                  wrote on last edited by
                  #12

                  @rejoe2
                  thank you for your return,
                  but I have the same problem, I manage to activate the relay of node 4 from node 5, but I cannot deactivate it. and when I act on node 5 the gateway does not receive frames since it calls node 4.
                  I think that node 4 should send the relay status to node 5 so that it knows whether it is activated or not.

                  tekkaT rejoe2R 2 Replies Last reply
                  1
                  • F FullMetal

                    @rejoe2
                    thank you for your return,
                    but I have the same problem, I manage to activate the relay of node 4 from node 5, but I cannot deactivate it. and when I act on node 5 the gateway does not receive frames since it calls node 4.
                    I think that node 4 should send the relay status to node 5 so that it knows whether it is activated or not.

                    tekkaT Offline
                    tekkaT Offline
                    tekka
                    Admin
                    wrote on last edited by
                    #13

                    @FullMetal Please post a full debug log of both nodes showing the observed behaviour.

                    F 1 Reply Last reply
                    0
                    • F FullMetal

                      @rejoe2
                      thank you for your return,
                      but I have the same problem, I manage to activate the relay of node 4 from node 5, but I cannot deactivate it. and when I act on node 5 the gateway does not receive frames since it calls node 4.
                      I think that node 4 should send the relay status to node 5 so that it knows whether it is activated or not.

                      rejoe2R Offline
                      rejoe2R Offline
                      rejoe2
                      wrote on last edited by
                      #14

                      @FullMetal Pls add also code from node 4.

                      In general:

                      • if you want also info from node 5 to be sent to your controller/gateway, you have to add a second (normal) send command.
                      • wrt. to how node 4 reacts on the messages, you may better use sth. like a toggle logic.

                      Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                      1 Reply Last reply
                      0
                      • tekkaT tekka

                        @FullMetal Please post a full debug log of both nodes showing the observed behaviour.

                        F Offline
                        F Offline
                        FullMetal
                        wrote on last edited by
                        #15

                        @tekka @rejoe2
                        Désolé de revenir si tard ..
                        J'ai modifié mon code sur mes nœuds, mais le résultat n'est toujours pas là!

                        Voici mes codes:

                        node 4:

                        // MySensors 
                        #define MY_PARENT_NODE_ID 0                   // define if fixed parent
                        #define MY_PARENT_NODE_IS_STATIC
                        #undef MY_REGISTRATION_FEATURE                  // sketch moves on if no registration
                        #define MY_NODE_ID 4                    // fixed node number
                        
                        // Enable debug prints to serial monitor
                        #define MY_DEBUG
                        
                        // Enable RS485 transport layer
                        #define MY_RS485
                        
                        // Define this to enables DE-pin management on defined pin
                        #define MY_RS485_DE_PIN 2
                        
                        // Set RS485 baud rate to use
                        #define MY_RS485_BAUD_RATE 9600
                        
                        // Set blinking period
                        #define MY_DEFAULT_LED_BLINK_PERIOD 300
                        
                        // Flash leds on rx/tx/err
                        //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
                        //#define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
                        //#define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
                        
                        
                        
                        #include <MySensors.h>
                        #include <Bounce2.h>
                        
                        #define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
                        #define BUTTON_PIN  3  // Arduino Digital I/O pin number for button 
                        #define CHILD_ID 1   // Id of the sensor child
                        #define SYSTER_ID 5
                        #define RELAY_ON 1
                        #define RELAY_OFF 0
                        
                        Bounce debouncer = Bounce(); 
                        int oldValue=0;
                        bool state;
                        
                        MyMessage msg(CHILD_ID,V_LIGHT);
                        //MyMessage msgconf(CHILD_ID,V_VAR1);
                        
                        void setup()  
                        {  
                          // Setup the button
                          pinMode(BUTTON_PIN,INPUT_PULLUP);
                          // Activate internal pull-up
                          //digitalWrite(BUTTON_PIN,HIGH);
                          
                          // After setting up the button, setup debouncer
                          debouncer.attach(BUTTON_PIN);
                          debouncer.interval(5);
                        
                          // Make sure relays are off when starting up
                          digitalWrite(RELAY_PIN, RELAY_OFF);
                          // Then set relay pins in output mode
                          pinMode(RELAY_PIN, OUTPUT);   
                              
                          // Set relay to last known state (using eeprom storage) 
                          state = loadState(CHILD_ID);
                          digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                        }
                        
                        void presentation()  {
                          // Send the sketch version information to the gateway and Controller
                          sendSketchInfo("Relay & Button", "1.0");
                        
                          // Register all sensors to gw (they will be created as child devices)
                          present(CHILD_ID, S_LIGHT);
                        }
                        
                        /*
                        *  Example on how to asynchronously check for new messages from gw
                        */
                        void loop() 
                        {
                          debouncer.update();
                          // Get the update value
                          int value = debouncer.read();
                          if (value != oldValue && value==0) {
                              send(msg.setDestination(MY_PARENT_NODE_ID).setSensor(CHILD_ID).set(state?false:true), true); // Send new state and request ack back
                              wait(100);
                              send(msg.setDestination(SYSTER_ID).setSensor(CHILD_ID).set(state?false:true), true);
                          }
                          oldValue = value;
                        } 
                         
                        void receive(const MyMessage &message) {
                          // We only expect one type of message from controller. But we better check anyway.
                          if (message.isAck()) {
                             Serial.println("This is an ack from gateway");
                          }
                        
                          if (message.type == V_LIGHT) {
                             // Change relay state
                             state = message.getBool();
                             digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                             // Store state in eeprom
                             saveState(CHILD_ID, state);
                               
                             // Write some debug info
                             Serial.print("Incoming change for sensor:");
                             Serial.print(message.sensor);
                             Serial.print(", New status: ");
                             Serial.println(message.getBool());
                           } 
                        
                        }
                        

                        node 5:

                        // MySensors 
                        #define MY_PARENT_NODE_ID 0                   // define if fixed parent
                        #define MY_PARENT_NODE_IS_STATIC
                        #undef MY_REGISTRATION_FEATURE                  // sketch moves on if no registration
                        #define MY_NODE_ID 5                     // fixed node number
                        
                        // Enable debug prints to serial monitor
                        #define MY_DEBUG
                        
                        // Enable RS485 transport layer
                        #define MY_RS485
                        
                        // Define this to enables DE-pin management on defined pin
                        #define MY_RS485_DE_PIN 2
                        
                        // Set RS485 baud rate to use
                        #define MY_RS485_BAUD_RATE 9600
                        
                        // Set blinking period
                        #define MY_DEFAULT_LED_BLINK_PERIOD 300
                        
                        // Flash leds on rx/tx/err
                        //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
                        //#define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
                        //#define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
                        
                        
                        // Enable this if RS485 is connected to a hardware serial port
                        //#define MY_RS485_HWSERIAL Serial1
                        //#include <MqttClient.h>
                        #include <SPI.h>
                        #include <MySensors.h>
                        #include <Bounce2.h>
                        
                        #define CHILD_ID 1
                        #define SYSTER_ID 4
                        #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                        
                        Bounce debouncer = Bounce(); 
                        int oldValue=0;
                        bool state;
                        
                        // Change to V_LIGHT if you use S_LIGHT in presentation below
                        MyMessage msg(CHILD_ID,V_LIGHT);
                        
                        void setup()  
                        {  
                          // Setup the button
                          pinMode(BUTTON_PIN,INPUT_PULLUP);
                          // Activate internal pull-up
                          //digitalWrite(BUTTON_PIN,HIGH);
                          
                          // After setting up the button, setup debouncer
                          debouncer.attach(BUTTON_PIN);
                          debouncer.interval(5);
                          
                        }
                        
                        void presentation() {
                          // 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.
                          sendSketchInfo("Button", "1.1");
                        
                          
                          present(CHILD_ID, S_LIGHT);  
                        }
                        
                        
                        //  Check if digital input has changed and send in new value
                        void loop() 
                        {
                          debouncer.update();
                          // Get the update value
                          int value = debouncer.read();
                          if (value != oldValue && value==0) {
                              send(msg.setDestination(MY_PARENT_NODE_ID).setSensor(CHILD_ID).set(state?false:true), false);// Send new state and request ack back
                              Serial.println("wait 1/10sec");
                              wait(100);
                              send(msg.setDestination(SYSTER_ID).setSensor(CHILD_ID).set(state?false:true), false);
                          }
                          oldValue = value;
                        }  
                        void receive(const MyMessage &message) {
                          // We only expect one type of message from controller. But we better check anyway.
                          if (message.isAck()) {
                             Serial.println("This is an ack from gateway");
                          }
                        
                          if (message.type == V_LIGHT) {
                             // Change relay state
                             state = message.getBool();
                             //digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                             // Store state in eeprom
                             saveState(SYSTER_ID, state);
                               
                             // Write some debug info
                             Serial.print("Incoming change for sensor:");
                             Serial.print(message.sensor);
                             Serial.print(", New status: ");
                             Serial.println(message.getBool());
                           } 
                        
                        }
                        

                        From node 4, my output is activated and deactivated immediately, due to double sending

                        from node 5, I can activate or deactivate if I launch the command from node 4 before otherwise.

                        tekkaT 1 Reply Last reply
                        0
                        • F FullMetal

                          @tekka @rejoe2
                          Désolé de revenir si tard ..
                          J'ai modifié mon code sur mes nœuds, mais le résultat n'est toujours pas là!

                          Voici mes codes:

                          node 4:

                          // MySensors 
                          #define MY_PARENT_NODE_ID 0                   // define if fixed parent
                          #define MY_PARENT_NODE_IS_STATIC
                          #undef MY_REGISTRATION_FEATURE                  // sketch moves on if no registration
                          #define MY_NODE_ID 4                    // fixed node number
                          
                          // Enable debug prints to serial monitor
                          #define MY_DEBUG
                          
                          // Enable RS485 transport layer
                          #define MY_RS485
                          
                          // Define this to enables DE-pin management on defined pin
                          #define MY_RS485_DE_PIN 2
                          
                          // Set RS485 baud rate to use
                          #define MY_RS485_BAUD_RATE 9600
                          
                          // Set blinking period
                          #define MY_DEFAULT_LED_BLINK_PERIOD 300
                          
                          // Flash leds on rx/tx/err
                          //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
                          //#define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
                          //#define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
                          
                          
                          
                          #include <MySensors.h>
                          #include <Bounce2.h>
                          
                          #define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
                          #define BUTTON_PIN  3  // Arduino Digital I/O pin number for button 
                          #define CHILD_ID 1   // Id of the sensor child
                          #define SYSTER_ID 5
                          #define RELAY_ON 1
                          #define RELAY_OFF 0
                          
                          Bounce debouncer = Bounce(); 
                          int oldValue=0;
                          bool state;
                          
                          MyMessage msg(CHILD_ID,V_LIGHT);
                          //MyMessage msgconf(CHILD_ID,V_VAR1);
                          
                          void setup()  
                          {  
                            // Setup the button
                            pinMode(BUTTON_PIN,INPUT_PULLUP);
                            // Activate internal pull-up
                            //digitalWrite(BUTTON_PIN,HIGH);
                            
                            // After setting up the button, setup debouncer
                            debouncer.attach(BUTTON_PIN);
                            debouncer.interval(5);
                          
                            // Make sure relays are off when starting up
                            digitalWrite(RELAY_PIN, RELAY_OFF);
                            // Then set relay pins in output mode
                            pinMode(RELAY_PIN, OUTPUT);   
                                
                            // Set relay to last known state (using eeprom storage) 
                            state = loadState(CHILD_ID);
                            digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                          }
                          
                          void presentation()  {
                            // Send the sketch version information to the gateway and Controller
                            sendSketchInfo("Relay & Button", "1.0");
                          
                            // Register all sensors to gw (they will be created as child devices)
                            present(CHILD_ID, S_LIGHT);
                          }
                          
                          /*
                          *  Example on how to asynchronously check for new messages from gw
                          */
                          void loop() 
                          {
                            debouncer.update();
                            // Get the update value
                            int value = debouncer.read();
                            if (value != oldValue && value==0) {
                                send(msg.setDestination(MY_PARENT_NODE_ID).setSensor(CHILD_ID).set(state?false:true), true); // Send new state and request ack back
                                wait(100);
                                send(msg.setDestination(SYSTER_ID).setSensor(CHILD_ID).set(state?false:true), true);
                            }
                            oldValue = value;
                          } 
                           
                          void receive(const MyMessage &message) {
                            // We only expect one type of message from controller. But we better check anyway.
                            if (message.isAck()) {
                               Serial.println("This is an ack from gateway");
                            }
                          
                            if (message.type == V_LIGHT) {
                               // Change relay state
                               state = message.getBool();
                               digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                               // Store state in eeprom
                               saveState(CHILD_ID, state);
                                 
                               // Write some debug info
                               Serial.print("Incoming change for sensor:");
                               Serial.print(message.sensor);
                               Serial.print(", New status: ");
                               Serial.println(message.getBool());
                             } 
                          
                          }
                          

                          node 5:

                          // MySensors 
                          #define MY_PARENT_NODE_ID 0                   // define if fixed parent
                          #define MY_PARENT_NODE_IS_STATIC
                          #undef MY_REGISTRATION_FEATURE                  // sketch moves on if no registration
                          #define MY_NODE_ID 5                     // fixed node number
                          
                          // Enable debug prints to serial monitor
                          #define MY_DEBUG
                          
                          // Enable RS485 transport layer
                          #define MY_RS485
                          
                          // Define this to enables DE-pin management on defined pin
                          #define MY_RS485_DE_PIN 2
                          
                          // Set RS485 baud rate to use
                          #define MY_RS485_BAUD_RATE 9600
                          
                          // Set blinking period
                          #define MY_DEFAULT_LED_BLINK_PERIOD 300
                          
                          // Flash leds on rx/tx/err
                          //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
                          //#define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
                          //#define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
                          
                          
                          // Enable this if RS485 is connected to a hardware serial port
                          //#define MY_RS485_HWSERIAL Serial1
                          //#include <MqttClient.h>
                          #include <SPI.h>
                          #include <MySensors.h>
                          #include <Bounce2.h>
                          
                          #define CHILD_ID 1
                          #define SYSTER_ID 4
                          #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                          
                          Bounce debouncer = Bounce(); 
                          int oldValue=0;
                          bool state;
                          
                          // Change to V_LIGHT if you use S_LIGHT in presentation below
                          MyMessage msg(CHILD_ID,V_LIGHT);
                          
                          void setup()  
                          {  
                            // Setup the button
                            pinMode(BUTTON_PIN,INPUT_PULLUP);
                            // Activate internal pull-up
                            //digitalWrite(BUTTON_PIN,HIGH);
                            
                            // After setting up the button, setup debouncer
                            debouncer.attach(BUTTON_PIN);
                            debouncer.interval(5);
                            
                          }
                          
                          void presentation() {
                            // 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.
                            sendSketchInfo("Button", "1.1");
                          
                            
                            present(CHILD_ID, S_LIGHT);  
                          }
                          
                          
                          //  Check if digital input has changed and send in new value
                          void loop() 
                          {
                            debouncer.update();
                            // Get the update value
                            int value = debouncer.read();
                            if (value != oldValue && value==0) {
                                send(msg.setDestination(MY_PARENT_NODE_ID).setSensor(CHILD_ID).set(state?false:true), false);// Send new state and request ack back
                                Serial.println("wait 1/10sec");
                                wait(100);
                                send(msg.setDestination(SYSTER_ID).setSensor(CHILD_ID).set(state?false:true), false);
                            }
                            oldValue = value;
                          }  
                          void receive(const MyMessage &message) {
                            // We only expect one type of message from controller. But we better check anyway.
                            if (message.isAck()) {
                               Serial.println("This is an ack from gateway");
                            }
                          
                            if (message.type == V_LIGHT) {
                               // Change relay state
                               state = message.getBool();
                               //digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                               // Store state in eeprom
                               saveState(SYSTER_ID, state);
                                 
                               // Write some debug info
                               Serial.print("Incoming change for sensor:");
                               Serial.print(message.sensor);
                               Serial.print(", New status: ");
                               Serial.println(message.getBool());
                             } 
                          
                          }
                          

                          From node 4, my output is activated and deactivated immediately, due to double sending

                          from node 5, I can activate or deactivate if I launch the command from node 4 before otherwise.

                          tekkaT Offline
                          tekkaT Offline
                          tekka
                          Admin
                          wrote on last edited by
                          #16

                          @FullMetal said in Node to Node Communication via Gatreway: Please upload the debug logs for further troubleshooting.

                          F 2 Replies Last reply
                          0
                          • tekkaT tekka

                            @FullMetal said in Node to Node Communication via Gatreway: Please upload the debug logs for further troubleshooting.

                            F Offline
                            F Offline
                            FullMetal
                            wrote on last edited by
                            #17

                            @tekka said in Node to Node Communication via Gatreway:

                            @FullMetal said in Node to Node Communication via Gatreway: Please upload the debug logs for further troubleshooting.

                            Sorry

                            Debug logs node 4
                            Press button node 4

                            08:16:01.668 -> 13555 TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
                            08:16:01.701 -> 13582 TSF:MSG:READ,0-0-4,s=1,c=1,t=2,pt=1,l=1,sg=0:0
                            08:16:01.701 -> 13586 TSF:MSG:ECHO
                            08:16:01.701 -> This is an ack from gateway

                            08:16:01.701 -> Incoming change for sensor:1, New status: 0

                            08:16:01.800 -> 13678 TSF:MSG:SEND,4-4-5-5,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1
                            08:16:01.800 -> 13684 TSF:RTE:N2N OK
                            08:16:01.800 -> 13703 TSF:MSG:READ,5-5-4,s=1,c=1,t=2,pt=1,l=1,sg=0:1
                            08:16:01.833 -> 13708 TSF:MSG:ECHO
                            08:16:01.833 -> This is an ack from gateway

                            08:16:01.833 -> Incoming change for sensor:1, New status: 1

                            Press button node 5

                            08:21:01.371 -> 313012 TSF:MSG:READ,5-5-4,s=1,c=1,t=2,pt=1,l=1,sg=0:0
                            08:21:01.371 -> Incoming change for sensor:1, New status: 0

                            second press node 5

                            08:21:06.238 -> 317865 TSF:MSG:READ,5-5-4,s=1,c=1,t=2,pt=1,l=1,sg=0:0
                            08:21:06.238 -> Incoming change for sensor:1, New status: 0

                            Debug logs node 5
                            Press button node 4

                            08:23:59.955 -> 51752 TSF:MSG:READ,4-4-5,s=1,c=1,t=2,pt=1,l=1,sg=0:1
                            08:23:59.955 -> 51757 TSF:MSG:ECHO REQ
                            08:23:59.988 -> 51777 TSF:MSG:SEND,5-5-4-4,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1
                            08:23:59.988 -> 51783 TSF:RTE:N2N OK
                            08:23:59.988 -> Incoming change for sensor:1, New status: 1

                            Press button node 5

                            08:24:36.929 -> 88704 TSF:MSG:SEND,5-5-0-0,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
                            08:24:36.929 -> wait 1/10sec

                            08:24:37.062 -> 88827 TSF:MSG:SEND,5-5-4-4,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
                            08:24:37.062 -> 88834 TSF:RTE:N2N OK

                            Debug logs gateway
                            Press button node 4 and node 5

                            08:26:19.261 -> 0;255;3;0;9;79078 TSF:MSG:READ,4-4-0,s=1,c=1,t=2,pt=1,l=1,sg=0:0
                            08:26:19.261 -> 0;255;3;0;9;79084 TSF:MSG:ACK REQ
                            08:26:19.294 -> 0;255;3;0;9;79105 TSF:MSG:SEND,0-0-4-4,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
                            08:26:19.294 -> 4;1;1;0;2;0
                            08:26:20.321 -> 0;255;3;0;9;80116 TSF:MSG:READ,5-5-0,s=1,c=1,t=2,pt=1,l=1,sg=0:0
                            08:26:20.321 -> 5;1;1;0;2;0

                            1 Reply Last reply
                            0
                            • tekkaT tekka

                              @FullMetal said in Node to Node Communication via Gatreway: Please upload the debug logs for further troubleshooting.

                              F Offline
                              F Offline
                              FullMetal
                              wrote on last edited by FullMetal
                              #18

                              @tekka @rejoe2
                              I just found!

                              ask the gateway not to send back acq
                              send(msg.setDestination(MY_PARENT_NODE_ID).setSensor(CHILD_ID).set(state?false:true), false); // Send new state and request ack back
                              wait(100);
                              send(msg.setDestination(SYSTER_ID).setSensor(CHILD_ID).set(state?false:true), true);

                              1 Reply Last reply
                              0
                              • rejoe2R Offline
                                rejoe2R Offline
                                rejoe2
                                wrote on last edited by
                                #19

                                Good to her you found that point :smile:.
                                Imo you'd better change also your receive functions to not react on "ack" messages (via "else" prior to message.type-comparison).

                                Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                17

                                Online

                                11.7k

                                Users

                                11.2k

                                Topics

                                113.0k

                                Posts


                                Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • MySensors
                                • OpenHardware.io
                                • Categories
                                • Recent
                                • Tags
                                • Popular