Node to Node Communication via Gatreway

  • Plugin Developer

    My topology is as follows,
    Node-1 <--> Gateway <--> Node-2.

    When I send message from Node-1 to Node-2 (or) Node-2 to Node-1 is not working,
    Node-1 and Node-2 are repeater nodes.

    Gateway does not route packets to another node in the network?

  • Admin

    That's strange. You probably have to look at the serial output from the nodes and gateway to find the cause.

  • Plugin Developer

    @hek Thank you I did serial debug, I'm not clear about route (to) address

    send: 1-1-0-0 s=255,c=0,t=18,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    repeater started, id=1, parent=0, distance=1
    send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=ok:LevelSensor
    send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 1-1-0-0 s=1,c=0,t=15,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 1-1-0-0 s=1,c=1,t=13,pt=2,l=2,sg=0,st=ok:0
    send: 1-1-3-3 s=1,c=1,t=13,pt=2,l=2,sg=0,st=fail:0

    above '3' is 'to' (route) address, I do not understand what is '3' and how it was calculated, I hope here 'to' should be a parent address, which is 0

    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;read: 1-1-0 s=255,c=0,t=18,pt=0,l=6,sg=0:1.5 b1
    1;255;0;0;18;1.5 b1
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=11,pt=0,l=16,sg=0:LevelSensor

    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    0;0;3;0;9;read: 1-1-0 s=1,c=0,t=15,pt=0,l=6,sg=0:1.5 b1
    1;1;0;0;15;1.5 b1
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=13,pt=2,l=2,sg=0:0

    0;0;3;0;9;read: 3-3-0 s=255,c=0,t=18,pt=0,l=6,sg=0:1.5 b1
    3;255;0;0;18;1.5 b1
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=11,pt=0,l=19,sg=0:LevelIndicator
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    0;0;3;0;9;read: 3-3-0 s=1,c=0,t=15,pt=0,l=6,sg=0:1.5 b1
    3;1;0;0;15;1.5 b1

    send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    repeater started, id=3, parent=0, distance=1
    send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=19,sg=0,st=ok:LevelIndicator
    send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 3-3-0-0 s=1,c=0,t=15,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 3-3-1-1 s=1,c=1,t=13,pt=2,l=2,sg=0,st=fail:0

  • Admin

    What does your code look like on the sending node (1)?

  • Plugin Developer

    #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);
    int dist = getDistance();

  • Admin

    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.

  • Plugin Developer

    How to print routing table in serial console?

  • Admin

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

  • Plugin Developer

    @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.

  • 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
    #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
    // 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
      // Activate internal pull-up
      // After setting up the button, setup debouncer
    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() 
      // Get the update value
      int value =;
      if (value != oldValue && value==0) {
          send(msg.set(state?false:true), false);// Send new state and request ack back
      oldValue = value;

  • @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"));

  • @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.

  • Admin

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

  • @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.

Log in to reply

Suggested Topics

  • 27
  • 10
  • 3
  • 5
  • 12
  • 7
  • 4
  • 26