[SOLVED] GatewayESP8266MQTTClient node reboots permanently as soon as MyController activates it as gateway



  • Hi everyone,

    up to now I used MySensors release 2.0.1-beta together with Arduino µCs and nRF24L01+ modules which works fine. Thanks to all developers and supporters for this great project.

    Today I tried to include an ESP8266 node (ESP-01 module with a Dallas temperature sensor attached) into my network. I chose the GatewayESP8266MQTTClient sketch from the examples folder and adapted it to my Wifi network. The communication with the MQTT broker works flawlessly so far. After powering the node it transmits its meta/vital data and the temperature value:

    ;MCO:BGN:INIT GW,CP=R-NGE--,VER=2.0.1-beta
    scandone
    f 0, scandone
    state: 0 -> 2 (b0)
    state: 2 -> 3 (0)
    state: 3 -> 5 (10)
    add 0
    aid 5
    cnt
    
    connected with Kumanet, channel 6
    ip:192.168.64.99,mask:255.255.255.0,gw:192.168.64.253
    chg_B1:-40
    .IP: 192.168.64.99
    0;255;3;0;9;MCO:REG:NOT NEEDED
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1
    IP: 192.168.64.99
    0;255;3;0;9;Attempting MQTT connection...
    chg_B1:-80
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/11
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/12
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/0/0/6
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    chg_B1:-120
    pm open,type:2 0
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    ...
    

    The problems starts as soon as I register the node in MyController as MQTT gateway:

    0_1477239934365_screenshot1.png

    As soon as I enable the newly added gateway the ESP8266 sensor node reboots and goes into a boot loop:

    connected with Kumanet, channel 6
    ip:192.168.64.99,mask:255.255.255.0,gw:192.168.64.253
    chg_B1:-40
    .IP: 192.168.64.99
    0;255;3;0;9;MCO:REG:NOT NEEDED
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1
    IP: 192.168.64.99
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/11
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/12
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/0/0/6
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    chg_B1:-80
    chg_B1:-120
    pm open,type:2 0
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0
    IP: 192.168.64.99
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/11
    IP: 192.168.64.99
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17
    IP: 192.168.64.99
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17
    IP: 192.168.64.99
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17
    ...
    

    Unfortunately there are no further debug outputs. Neither on MySensors side nor on MyController side. As far as I see MyController does not send any MQTT messages at any time.

    Is it possible that the sensor node reboots because it does not get any responses? But why aren't there any reboots if the node is not an enabled gateway in MyController? There must be any non-visible communication which causes the reboots...
    Did anybody include a GatewayESP8266MQTTClient successfully into MyController yet?

    The MQTT broker is Mosquitto by the way, hostet on the same server as MyController.

    This is my sketch:

    #include <Arduino.h>
    #include <EEPROM.h>
    #include <SPI.h>
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
    #define MY_BAUD_RATE 115200
    
    #define MY_NODE_ID 4
    #define MY_PARENT_NODE_ID 0
    
    #define MY_GATEWAY_MQTT_CLIENT
    #define MY_GATEWAY_ESP8266
    
    // Set this node's subscribe and publish topic prefix
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
    
    // Set MQTT client id
    #define MY_MQTT_CLIENT_ID "mysensors-1"
    
    // Set WIFI SSID and password
    #define MY_ESP8266_SSID "Kumanet"
    #define MY_ESP8266_PASSWORD "<<REMOVED>>"
    
    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    #define MY_IP_ADDRESS 192,168,64,99
    
    // If using static ip you need to define Gateway and Subnet address as well
    #define MY_IP_GATEWAY_ADDRESS 192,168,64,253
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // MQTT broker ip address.  
    #define MY_CONTROLLER_IP_ADDRESS 192, 168, 64, 253
    
    // The MQTT broker port to to open 
    #define MY_PORT 1883      
    
    #include <ESP8266WiFi.h>
    #include <MySensors.h>
    #include <OneWire.h>
    #include <DallasTemperature.h>
    
    #define ONE_WIRE_BUS 0
    
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensors(&oneWire);
    
    #define CHILD_ID_TEMPERATURE        0
    MyMessage msgTemperature(CHILD_ID_TEMPERATURE, V_TEMP);
    
    unsigned long lastSent = 0;
    
    void setup() {
      sensors.begin();
    }
    
    void presentation() {
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo("ESP8266TempSensor", "0.9");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_TEMPERATURE, S_TEMP);
    }
    
    void loop() {
    
      sensors.requestTemperatures(); // Send the command to get temperatures
      delay(50);
      send(msgTemperature.set(sensors.getTempCByIndex(0), 1));
    
      delay(10000);
    }
    


  • @DerTomm said:

    #define MY_MQTT_CLIENT_ID "mysensors-1"
    

    try changing to something like

    #define MY_MQTT_CLIENT_ID "mywifinode-1"
    

    You are using the same client ID on both controller and node



  • Thanks - that solved the problem!


Log in to reply
 

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