ESP8266 MQTT Client Node ID
-
Hi !
My goal is to make a sensor node on a wemos D1 mini on ESP8266 with MQTT directly on WIFI.
I can push and receive message from the MQTT broker but when i send something (like a relay status) the node id of my sensor is 0 and i can't change it even with#define MY_NODE_ID 5
.
I use GatewayESP8266MQTTClient sketch and i comment//#define MY_RADIO_NRF24
So how can i force it ? Thanks.
-
@tchoblond59 a gateway always has node ID 0. It can use sensor IDs from 0 to 254 though.
-
@mfalkvidd
why node ID need to be 0 ? I want to have a few node ( different localization ) and all arduino node should be have unical node_id but only sketch name can by unical.I'm using MY_GATEWAY_MQTT_CLIENT
-
@msolo because the node ID is used in routing within a MySensors network, and there can only be one gateway per MySensors network.
You can use MY_MQTT_CLIENT_ID, MY_MQTT_PUBLISH_TOPIC_PREFIX and MY_MQTT_SUBSCRIBE_TOPIC_PREFIX to differentiate between different MySensors gateways/networks.
-
@mfalkvidd
MY_MQTT_CLIENT_ID was rewrite for other deviceso if I good understand, the best options is use dedicated channel for communication
ex:
arduino00:
MY_MQTT_PUBLISH_TOPIC_PREFIX=mysensors-in00
MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mysensors-out00
domoticz for ex:
new: mysensor gateway mqtt with TOPIC : mysensors-${in/out}00arduino01
the same action but change 00->01
-
@msolo yes I think that will work. I have not used MySensors with MQTT though, so I can't say for sure.
-
@mfalkvidd it's working, but i think in not pro way - why ? you need create separate channel for communicastion ( for security point it's ok ) but if you have many nodes and you want exchange some informasion insite network it't will be not working you need some integrasion ex domoticz, hassio etc bo some think chane in other node. Maybe you add this option to change node_id in mqtt gatway ?
-
@msolo "adding" that would risk breaking a lot of stuff, but you're welcome to try. https://www.mysensors.org/download/contributing has some useful information if you want to work on it.