ESP8266 MQTT Gateway and setting NODE_ID



  • Re: Connecting first node to new gateway - what am I missing?

    Hi, I have a working setup now thanks to the above thread with an ESP8266 acting as gateway and a nano acting as a sensor.

    Regarding the node id of the gateway, is there something special you have to do to set the node id?
    Because I added #define MY_NODE_ID 1 to my gateway sketch but the gateway always reports node id 0.


  • Mod

    @pop a gateway always has node id 0. Changing node id for a gateway is not possible.

    Could you describe why you'd prefer a separate node id?



  • @mfalkvidd hi. I thought I could build several ESP8266 devices with their own sensors and place them (within wifi range) then have several nano-based sensors calling in to each ESP8266.
    How would I make sensors using the ESP8266 without hitting gateway limitations?



  • @pop said:

    @mfalkvidd hi. I thought I could build several ESP8266 devices with their own sensors and place them (within wifi range) then have several nano-based sensors calling in to each ESP8266.
    How would I make sensors using the ESP8266 without hitting gateway limitations?

    I should have added, I'm using openhab and as far as I understand, we have to use MQTT to talk to it. Hance the ESP8266 MQTT Gateway.


  • Mod

    @pop you would just add each esp to OpenHab I think. No need to have different node id.



  • @mfalkvidd Oh right, thanks. I think I get it now.
    So I just add more ESPs and the MQTT messages will be identified by the MQTT prefix which will be unique to each gateway.
    Duh! I was thinking the node id identified the MQTT stream.

    Thanks for putting me right.


  • Mod

    @pop great! Thanks for clarifying your use case.



  • Glad I found this post. I couldn't work out why my ESP8266 which is an MQTT gateway and sensor in one was always ignoring the MY_NODE_ID. Perhaps good to mention in the doc that if you have MY_GATEWAY_MQTT_CLIENT defined the node will always be 0 ?



  • I found this topic by chance and there might be new info - if so, I'm sorry.
    However, I was thinking how the "forced" node-id 0 will work if more than one ESP8266 gateway is installed within possible radio range of the sensor nodes. Wouldn't that be leading to unpredictable behavior, like messages sent more than one?


  • Mod

    @jjk yes it would be a problem. The solution is to use different radio channels (or protocols) for each MySensors network.

    From https://www.mysensors.org/about/network

    ... you can create another parallel radio network on a different channel and there are 126 available channels [NRF24L01+].



  • @mfalkvidd thanks for the swift reply - sometimes the obvious is hard to see ;)



  • @mfalkvidd Hi, just for completeness, how do you actually select another channel? The article that was linked to didn't cover how to do it.
    I don't need to use an extra channel, I just thought it would be interesting for people to know.


  • Mod

    @pop for nrf24l01+ based networks, set MY_RF24_CHANNEL
    for rfm69, set MY_RFM69_NETWORKID
    They are documented at https://www.mysensors.org/download/sensor_api_20#configuration


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.