MySensor auto node ID



  • Setup:

    • Raspberry Pi serial gateway.
    • Node on Arduino Nano. Bare minimum code.

    Problem:
    Node fails to register when neither NODE_ID or MY_NODE_ID defined. It registers fine when MY_NODE_ID defined explicitly.

    Sketch:

    #define MY_RADIO_NRF24
    #define MY_BAUD_RATE 38400
    #define MY_DEBUG
    
    #include <MySensors.h>
    #include <SPI.h>
    
    #define SENSOR_ID 1
    
    #define OPEN 1
    #define CLOSE 0
    
    MyMessage msg(SENSOR_ID, V_TRIPPED);
    
    uint8_t value = OPEN;
    
    void presentation()
    {
        present(SENSOR_ID, S_DOOR);
    }
    
    void loop()
    {
        value = value == OPEN ? CLOSE : OPEN;
        send(msg.set(value));
        sleep(10000);
    }
    

    Gateway log when node uses MY_NODE_ID=AUTO:

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-beta
    mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    

    Node's log with MY_NODE_ID=AUTO:

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    10 TSM:INIT
    12 TSF:WUR:MS=0
    22 TSM:INIT:TSP OK
    28 !TSF:SID:FAIL,ID=0
    34 TSM:FAIL:CNT=1
    38 TSM:FAIL:PDT
    10045 TSM:FAIL:RE-INIT
    10051 TSM:INIT
    10061 TSM:INIT:TSP OK
    10067 !TSF:SID:FAIL,ID=0
    10074 TSM:FAIL:CNT=2
    10080 TSM:FAIL:PDT
    20086 TSM:FAIL:RE-INIT
    20092 TSM:INIT
    20103 TSM:INIT:TSP OK
    20109 !TSF:SID:FAIL,ID=0
    20115 TSM:FAIL:CNT=3
    20121 TSM:FAIL:PDT
    

    Gateway log when node uses MY_NODE_ID=1:

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-beta
    mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    mysgw: TSF:MSG:READ,1-1-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:BC
    mysgw: TSF:MSG:FPAR REQ,ID=1
    mysgw: TSF:PNG:SEND,TO=0
    mysgw: TSF:CKU:OK
    mysgw: TSF:MSG:GWL OK
    mysgw: TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    mysgw: TSF:MSG:PINGED,ID=1,HP=1
    mysgw: TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
    mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    mysgw: TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    mysgw: TSF:MSG:READ,1-1-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.1.1
    mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
    mysgw: TSF:MSG:READ,1-1-0,s=1,c=0,t=0,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
    mysgw: !TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=NACK:1
    mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
    mysgw: TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
    mysgw: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=1,l=1,sg=0:0
    mysgw: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=1,l=1,sg=0:1
    

    Node log with MY_NODE_ID=1:

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    10 TSM:INIT
    12 TSF:WUR:MS=0
    22 TSM:INIT:TSP OK
    28 TSM:INIT:STATID=1
    36 TSF:SID:OK,ID=1
    43 TSM:FPAR
    79 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    354 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    368 TSF:MSG:FPAR OK,ID=0,D=1
    2101 TSM:FPAR:OK
    2105 TSM:ID
    2109 TSM:ID:OK
    2113 TSM:UPL
    2117 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2136 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2150 TSF:MSG:PONG RECV,HP=1
    2158 TSM:UPL:OK
    2162 TSM:READY:ID=1,PAR=0,DIS=1
    2207 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=NACK:0100
    2228 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2256 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=1,st=OK:2.1.1
    2293 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    4313 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
    4331 MCO:REG:REQ
    4370 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
    6397 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
    6416 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    6430 MCO:PIM:NODE REG=1
    6436 MCO:BGN:INIT OK,TSP=1
    6453 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=OK:0
    6469 MCO:SLP:MS=10000,SMS=0,I1=255,M1=255,I2=255,M2=255
    6483 MCO:SLP:TPD
    6490 MCO:SLP:WUP=-1
    

    What's wrong with my setup?


  • Mod

    @benya it looks to me like AUTO has been redefined from 255 to 0. Could you check if there are any redefine warnings in the compile output? Adding a Serial.println(AUTO) in before() might help to check the value as well. Or try to set the node ID to the value 255.


  • Admin

    Did you use the node for something else earlier? Like a gateway? Try clearing EEPROM to get rid of old settings.



  • @mfalkvidd I added

    #if MY_NODE_ID==255
    #error MY_NODE_ID==255
    #endif
    

    And compiler reported

    dummy_mysensor:16: error: #error MY_NODE_ID==255
     #error MY_NODE_ID==255
      ^
    exit status 1
    

    So MY_NODE_ID is 255.

    Yes, I cleared EEPROM as well.


  • Admin

    Did you use the provided clear sketch or do a clear yourself? If the latter, node that you should write 0xff to all positions.



  • You can confirm that you have Cleared the EEPROM by opening the Serial Monitor and see what happens



  • @hek That was it. Got node registered after clearing with 0xff.
    Thanks a lot! 😂


Log in to reply
 

Suggested Topics

  • 3
  • 5
  • 6
  • 2

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts