Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. ESP-8266 gateway with sensor can't communicate with controller

ESP-8266 gateway with sensor can't communicate with controller

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 3 Posters 1.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Senne Vande SompeleS Offline
    Senne Vande SompeleS Offline
    Senne Vande Sompele
    wrote on last edited by
    #1

    hi everybody,

    I've read a lot of topics but can't seem to find out what i'm doing wrong.
    I've a wemos D1 mini with a switch connected to it and i want to send the state of this switch to Home Assistant
    The following code is running on my d1:

    #include <EEPROM.h>
    #include <SPI.h>
    #include <Bounce2.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 9600
    
    #define MY_GATEWAY_ESP8266
    
    #define MY_ESP8266_SSID "xxxxxxx"
    #define MY_ESP8266_PASSWORD "xxxxxxx"
    
    // If using static ip you need to define Gateway and Subnet address as well
    #define MY_IP_ADDRESS 192,168,0,9
    #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // The port to keep open on node server mode 
    #define MY_PORT 5003      
    
    // How many clients should be able to connect to this gateway (default 1)
    #define MY_GATEWAY_MAX_CLIENTS 2
    
    
    #define CHILD_ID 1
    #define BUTTON_PIN  0  // Arduino Digital I/O pin for button/reed switch
    
    
    #include <ESP8266WiFi.h>
    #include <MySensors.h>
    
    Bounce debouncer = Bounce(); 
    int oldValue=-1;
    bool initialValueSent = false;
    
    MyMessage msg(CHILD_ID,V_STATUS);
    
    void setup() { 
      pinMode(BUTTON_PIN,INPUT_PULLUP);
      // Activate internal pull-up
      //digitalWrite(BUTTON_PIN,HIGH);
      // After setting up the button, setup debouncer
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(5);
    }
    
    void presentation() {
      // Present locally attached sensors here    
      Serial.println("Presentation:");
      
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Switch", "1.1");
      present(CHILD_ID, S_BINARY); 
    }
    
    
    void loop() {
      debouncer.update();
      // Get the update value
       int value = debouncer.read();
      if (value != oldValue) {
         // Send in the new value
         Serial.println(value);
         send(msg.set(value==HIGH ? 1 : 0));
         oldValue = value;
      }
      // Send locally attached sensors data here
    }
    
    void receive(const MyMessage &message) {
      if (message.isAck()) {
         Serial.println("This is an ack from gateway");
      }
      Serial.println("something was received: "+ message.type);
    }
    
    

    and got follwing output

    0;255;3;0;9;Starting gateway (R-NGE-, 2.0.0)
    scandone
    f 0, scandone
    state: 0 -> 2 (b0)
    state: 2 -> 3 (0)
    state: 3 -> 5 (10)
    add 0
    aid 3
    cnt 
    
    connected with telenet-CED24D5, channel 11
    ip:192.168.0.9,mask:255.255.255.0,gw:192.168.0.1
    .IP: 192.168.0.9
    0;255;3;0;9;No registration required
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
    1
    pm open,type:2 0
    

    and in home assistant i get following in the debug:

    16-12-31 11:45:08 mysensors.mysensors: Trying to connect to ('192.168.0.9', 5003)
    16-12-31 11:45:08 mysensors.mysensors: Connected to ('192.168.0.9', 5003)
    16-12-31 11:45:09 netdisco.service: Scanning
    16-12-31 11:45:09 mysensors.mysensors: Received 0;255;3;0;14;Gateway startup complete.
    0;255;3;0;11;Switch
    0;255;3;0;12;1.1
    0;1;0;0;3;
    
    16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
    16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
    16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
    16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
    16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
    16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
    16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown, will not add child 1.
    16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
    
    16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
    
    16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
    

    can someone help me getting this working

    mfalkviddM martinhjelmareM 2 Replies Last reply
    0
    • Senne Vande SompeleS Senne Vande Sompele

      hi everybody,

      I've read a lot of topics but can't seem to find out what i'm doing wrong.
      I've a wemos D1 mini with a switch connected to it and i want to send the state of this switch to Home Assistant
      The following code is running on my d1:

      #include <EEPROM.h>
      #include <SPI.h>
      #include <Bounce2.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 9600
      
      #define MY_GATEWAY_ESP8266
      
      #define MY_ESP8266_SSID "xxxxxxx"
      #define MY_ESP8266_PASSWORD "xxxxxxx"
      
      // If using static ip you need to define Gateway and Subnet address as well
      #define MY_IP_ADDRESS 192,168,0,9
      #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
      #define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // The port to keep open on node server mode 
      #define MY_PORT 5003      
      
      // How many clients should be able to connect to this gateway (default 1)
      #define MY_GATEWAY_MAX_CLIENTS 2
      
      
      #define CHILD_ID 1
      #define BUTTON_PIN  0  // Arduino Digital I/O pin for button/reed switch
      
      
      #include <ESP8266WiFi.h>
      #include <MySensors.h>
      
      Bounce debouncer = Bounce(); 
      int oldValue=-1;
      bool initialValueSent = false;
      
      MyMessage msg(CHILD_ID,V_STATUS);
      
      void setup() { 
        pinMode(BUTTON_PIN,INPUT_PULLUP);
        // Activate internal pull-up
        //digitalWrite(BUTTON_PIN,HIGH);
        // After setting up the button, setup debouncer
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
      }
      
      void presentation() {
        // Present locally attached sensors here    
        Serial.println("Presentation:");
        
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Switch", "1.1");
        present(CHILD_ID, S_BINARY); 
      }
      
      
      void loop() {
        debouncer.update();
        // Get the update value
         int value = debouncer.read();
        if (value != oldValue) {
           // Send in the new value
           Serial.println(value);
           send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
        // Send locally attached sensors data here
      }
      
      void receive(const MyMessage &message) {
        if (message.isAck()) {
           Serial.println("This is an ack from gateway");
        }
        Serial.println("something was received: "+ message.type);
      }
      
      

      and got follwing output

      0;255;3;0;9;Starting gateway (R-NGE-, 2.0.0)
      scandone
      f 0, scandone
      state: 0 -> 2 (b0)
      state: 2 -> 3 (0)
      state: 3 -> 5 (10)
      add 0
      aid 3
      cnt 
      
      connected with telenet-CED24D5, channel 11
      ip:192.168.0.9,mask:255.255.255.0,gw:192.168.0.1
      .IP: 192.168.0.9
      0;255;3;0;9;No registration required
      0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
      1
      pm open,type:2 0
      

      and in home assistant i get following in the debug:

      16-12-31 11:45:08 mysensors.mysensors: Trying to connect to ('192.168.0.9', 5003)
      16-12-31 11:45:08 mysensors.mysensors: Connected to ('192.168.0.9', 5003)
      16-12-31 11:45:09 netdisco.service: Scanning
      16-12-31 11:45:09 mysensors.mysensors: Received 0;255;3;0;14;Gateway startup complete.
      0;255;3;0;11;Switch
      0;255;3;0;12;1.1
      0;1;0;0;3;
      
      16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
      16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
      16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
      16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
      16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
      16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
      16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown, will not add child 1.
      16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
      
      16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
      
      16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
      

      can someone help me getting this working

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @Senne-Vande-Sompele try upgrading to MySensors 2.1 (which was relesed yesterday). 2.0 has a problem that causes the receive function to not be called on nodes that are gateways.

      1 Reply Last reply
      0
      • Senne Vande SompeleS Senne Vande Sompele

        hi everybody,

        I've read a lot of topics but can't seem to find out what i'm doing wrong.
        I've a wemos D1 mini with a switch connected to it and i want to send the state of this switch to Home Assistant
        The following code is running on my d1:

        #include <EEPROM.h>
        #include <SPI.h>
        #include <Bounce2.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 9600
        
        #define MY_GATEWAY_ESP8266
        
        #define MY_ESP8266_SSID "xxxxxxx"
        #define MY_ESP8266_PASSWORD "xxxxxxx"
        
        // If using static ip you need to define Gateway and Subnet address as well
        #define MY_IP_ADDRESS 192,168,0,9
        #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
        #define MY_IP_SUBNET_ADDRESS 255,255,255,0
        
        // The port to keep open on node server mode 
        #define MY_PORT 5003      
        
        // How many clients should be able to connect to this gateway (default 1)
        #define MY_GATEWAY_MAX_CLIENTS 2
        
        
        #define CHILD_ID 1
        #define BUTTON_PIN  0  // Arduino Digital I/O pin for button/reed switch
        
        
        #include <ESP8266WiFi.h>
        #include <MySensors.h>
        
        Bounce debouncer = Bounce(); 
        int oldValue=-1;
        bool initialValueSent = false;
        
        MyMessage msg(CHILD_ID,V_STATUS);
        
        void setup() { 
          pinMode(BUTTON_PIN,INPUT_PULLUP);
          // Activate internal pull-up
          //digitalWrite(BUTTON_PIN,HIGH);
          // After setting up the button, setup debouncer
          debouncer.attach(BUTTON_PIN);
          debouncer.interval(5);
        }
        
        void presentation() {
          // Present locally attached sensors here    
          Serial.println("Presentation:");
          
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("Switch", "1.1");
          present(CHILD_ID, S_BINARY); 
        }
        
        
        void loop() {
          debouncer.update();
          // Get the update value
           int value = debouncer.read();
          if (value != oldValue) {
             // Send in the new value
             Serial.println(value);
             send(msg.set(value==HIGH ? 1 : 0));
             oldValue = value;
          }
          // Send locally attached sensors data here
        }
        
        void receive(const MyMessage &message) {
          if (message.isAck()) {
             Serial.println("This is an ack from gateway");
          }
          Serial.println("something was received: "+ message.type);
        }
        
        

        and got follwing output

        0;255;3;0;9;Starting gateway (R-NGE-, 2.0.0)
        scandone
        f 0, scandone
        state: 0 -> 2 (b0)
        state: 2 -> 3 (0)
        state: 3 -> 5 (10)
        add 0
        aid 3
        cnt 
        
        connected with telenet-CED24D5, channel 11
        ip:192.168.0.9,mask:255.255.255.0,gw:192.168.0.1
        .IP: 192.168.0.9
        0;255;3;0;9;No registration required
        0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
        1
        pm open,type:2 0
        

        and in home assistant i get following in the debug:

        16-12-31 11:45:08 mysensors.mysensors: Trying to connect to ('192.168.0.9', 5003)
        16-12-31 11:45:08 mysensors.mysensors: Connected to ('192.168.0.9', 5003)
        16-12-31 11:45:09 netdisco.service: Scanning
        16-12-31 11:45:09 mysensors.mysensors: Received 0;255;3;0;14;Gateway startup complete.
        0;255;3;0;11;Switch
        0;255;3;0;12;1.1
        0;1;0;0;3;
        
        16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
        16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
        16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
        16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
        16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown
        16-12-31 11:45:09 mysensors.mysensors: Requesting new presentation for node 0
        16-12-31 11:45:09 mysensors.mysensors: Node 0 is unknown, will not add child 1.
        16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
        
        16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
        
        16-12-31 11:45:09 mysensors.mysensors: Sending 0;255;3;0;19;
        

        can someone help me getting this working

        martinhjelmareM Offline
        martinhjelmareM Offline
        martinhjelmare
        Plugin Developer
        wrote on last edited by
        #3

        @Senne-Vande-Sompele

        Mysensors 2.0 has a bug that leads to gateways without radio to not present themselves, which is why node 0 (gateway) is unknown in your log. This is fixed in mysensors 2.1.

        Senne Vande SompeleS 1 Reply Last reply
        1
        • martinhjelmareM martinhjelmare

          @Senne-Vande-Sompele

          Mysensors 2.0 has a bug that leads to gateways without radio to not present themselves, which is why node 0 (gateway) is unknown in your log. This is fixed in mysensors 2.1.

          Senne Vande SompeleS Offline
          Senne Vande SompeleS Offline
          Senne Vande Sompele
          wrote on last edited by
          #4

          I've upgraded and everything works now thank you very much

          mfalkviddM 1 Reply Last reply
          2
          • Senne Vande SompeleS Senne Vande Sompele

            I've upgraded and everything works now thank you very much

            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #5

            Great work @Senne-Vande-Sompele, thanks for reporting back!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            16

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular