Mqtt-client-gateway / nodes do not get an id



  • ... After playing around with v. 1.5 some time ago, I have restarted with version 2.0 - primarily because another project pushed me in direction of mqtt.
    I do not yet have a controller. for now I connect to broker.hivemq.com and use mqtt.fx do see what is published.

    Fist - what I have - and below the problem I face - that sensors do not get a node id from the gateway.

    I started with the examples. I used the ClearEepromConfig sketch to init the eeprom before loading the examples. I am not really sure it that changed anything.

    It took some time to make the gw run. For some reason, the hw played up... One thing that tricked me was all the talk about editing myconfig.h - especially with the softspi. It turned out that the gateway sketch handles it all by it self - so no need to change myconfig.h. If changes are needed then the changes can be made before #include <mysensors.h> in the sketches.
    But eventually I got it up and running.

    Ethernet is a w5100 shield and radios are NRF24

    GatewayW5100MQTTClient
    Commented the ip-address out to use DHCP:
    //#define MY_IP_ADDRESS 192,168,178,87
    Updated broker address:
    #define MY_CONTROLLER_URL_ADDRESS "broker.hivemq.com"
    It works as a charm:
    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSM:RADIO:OK
    0;255;3;0;9;TSM:GW MODE
    0;255;3;0;9;TSM:READY
    IP: 192.168.0.67
    0;255;3;0;9;No registration required
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
    IP: 192.168.0.67
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;TSP:MSG:READ 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;TSP:MSG:BC
    0;255;3;0;9;TSP:MSG:FPAR REQ (sender=255)
    0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
    0;255;3;0;9;TSP:MSG:GWL OK
    0;255;3;0;9;TSP:MSG:SEND 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0
    0;255;3;0;9;TSP:MSG:READ 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;TSP:MSG:BC
    0;255;3;0;9;TSP:MSG:FPAR REQ (sender=255)
    0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
    0;255;3;0;9;TSP:MSG:GWL OK
    0;255;3;0;9;TSP:MSG:SEND 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0

    BinarySwitchSleepSensor
    To make it work I added node id manually above including mysensors.h:
    #define MY_NODE_ID 75
    And again - it works great:
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=75)
    TSM:FPAR
    TSP:MSG:SEND 75-75-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-75 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=75)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 75-75-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:MSG:READ 0-0-75 s=255,c=3,t=25,pt=1,l=1,sg=0:1
    TSP:MSG:PONG RECV (hops=1)
    TSP:CHKUPL:OK
    TSM:UPL:OK
    TSM:READY
    TSP:MSG:SEND 75-75-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    !TSP:MSG:SEND 75-75-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=fail:2.0.0
    TSP:MSG:SEND 75-75-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=1,st=ok:0
    TSP:MSG:SEND 75-75-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=ok:Binary Sensor
    TSP:MSG:SEND 75-75-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.0
    TSP:MSG:SEND 75-75-0-0 s=3,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=ok:
    TSP:MSG:SEND 75-75-0-0 s=4,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=ok:
    Request registration...
    TSP:MSG:SEND 75-75-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
    TSP:MSG:READ 0-0-75 s=255,c=3,t=27,pt=1,l=1,sg=0:1
    Node registration=1
    Init complete, id=75, parent=0, distance=1, registration=1
    TSP:MSG:SEND 75-75-0-0 s=3,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=ok:1
    TSP:MSG:SEND 75-75-0-0 s=4,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=ok:1

    BUT here the problems begins 😞
    I would like to have the nodes get the node id auto assigned - so I removed the node-id assignment, cleared the eeprom (again) and loaded the now competely unchanged binary sensor.
    //#define MY_NODE_ID 75
    #define MY_NODE_ID AUTO
    The result is:
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-255 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    !TSM:CHKID:FAIL (ID=255)
    !TSM:FAILURE

    TSM:PDT

    I have looked at this forum and google in general but there are not much v2.0 help to be found. I thought it might be related to inclusion mode - but I have not had success with experimenting with that...

    Please help!



  • @Thomas-Augustinus

    I'm not 100 percent sure, but i think that the controller tells the nodes what id they have. Right now you do not have this. To solve this: set a static ID (see 2.0 API) or attach a controller.



  • Hi @nielsokker,
    Yes - I get that part - as mentioned I did just that to make it work - and that was the test I made to verify that everything works.
    But - I really want the automatic id allocation so I do not have to program devices with correct id individually.
    I have seen somewhere on google that the mqtt gw can assign node-id to the sensors. So I assume that the library supports this - perhaps it just needs to be activated?
    /th



  • Oh sorry I see it now. In that case good luck 😉

    I am going to take a look at the API to see if something is there.


  • Hardware Contributor

    @Thomas-Augustinus the gw does not generate an id. it's up to the controller to do this. so you have to use a static id.



  • Hi @scalz
    Ok - I see that mentioned many places - does that mean that the mysensors library does not have the algorithms to deliver the node-id's?
    I am pretty sure that I found a description (of a 1.4 mqtt gateway I think) that claimed it was possible with the mqtt gateway...?
    /th


  • Hardware Contributor

    yep. not for the moment at least, and I don't know for the future.
    this is a part of the controller side code.
    imho, I think this is/was not really a question of algo, but perhaps more memory related for small mcu, etc..


  • Admin

    Right now we let the controller hand out (or re-assign in 2.0) ids to the nodes.

    If we'd led gateway handle this it would introduce a lot of more control commands between gateway and controller to release/query and handle assignment.



  • Hi @hek and @scalz
    Thanks for your response. I have been unable to locate the guide I thought I previously found... So I probably misread that.

    Thank you for the clear answer - which leaves me with only one more ( at the moment 🙂 )... If I install OpenHAB - will it be able to hand out id's via MQTT? I noticed that the clients without an id keep posting to MQTT... under node id 255...

    /th


Log in to reply
 

Suggested Topics

  • 3
  • 6
  • 2
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts