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. Controllers
  3. Home Assistant
  4. Node 0 unknown, error decoding message from gateway

Node 0 unknown, error decoding message from gateway

Scheduled Pinned Locked Moved Home Assistant
15 Posts 2 Posters 3.5k Views 2 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.
  • martinhjelmareM Offline
    martinhjelmareM Offline
    martinhjelmare
    Plugin Developer
    wrote on last edited by
    #2

    There's a bug in mysensors 2.0 where a gateway without radio doesn't present itself. This has been fixed in the mysensors dev branch. See this issue for more info and a workaround:
    https://github.com/theolind/pymysensors/issues/51

    1 Reply Last reply
    1
    • MaKinM Offline
      MaKinM Offline
      MaKin
      wrote on last edited by
      #3
      This post is deleted!
      1 Reply Last reply
      0
      • MaKinM Offline
        MaKinM Offline
        MaKin
        wrote on last edited by MaKin
        #4

        Now it's not about the node 0 but the children.

        16-12-17 11:39:31 mysensors.mysensors: Child 1 is unknown
        16-12-17 11:39:31 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 22.50
        
        16-12-17 11:39:31 mysensors.mysensors: Child 0 is unknown
        16-12-17 11:39:31 mysensors.mysensors: Error decoding message from gateway, bad data received: H: 40.20
        

        The serial monitor shows me the following:

        0;255;3;0;9;Starting gateway (R-NGA-, 2.0.0)
        0;255;3;0;14;Gateway startup complete.
        0;255;0;0;18;2.0.0
        0;255;3;0;9;No registration required
        0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
        0;1;1;0;0;23.2
        T: 23.20
        0;0;1;0;1;44.5
        H: 44.50
        0;0;1;0;1;44.4
        

        Is anything wrong with my sketch? I hacked it together...

        // Enable debug prints
        #define MY_DEBUG
        
        // Enable and select radio type attached 
        //#define MY_RADIO_NRF24
        //#define MY_RADIO_RFM69
        //#define MY_RS485
        
        // Enable serial gateway
        #define MY_GATEWAY_SERIAL
        
        // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
        #if F_CPU == 8000000L
        #define MY_BAUD_RATE 38400
        #endif
        
        // Flash leds on rx/tx/err
        #define MY_LEDS_BLINKING_FEATURE
        // Set blinking period
        #define MY_DEFAULT_LED_BLINK_PERIOD 300
        
        // Inverses the behavior of leds
        //#define MY_WITH_LEDS_BLINKING_INVERSE
        
        // Enable inclusion mode
        #define MY_INCLUSION_MODE_FEATURE
        // Enable Inclusion mode button on gateway
        #define MY_INCLUSION_BUTTON_FEATURE
        
        // Inverses behavior of inclusion button (if using external pullup)
        //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
        
        // Set inclusion mode duration (in seconds)
        #define MY_INCLUSION_MODE_DURATION 60 
        // Digital pin used for inclusion mode button
        #define MY_INCLUSION_MODE_BUTTON_PIN  3 
        
        // Uncomment to override default HW configurations
        //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
        #define MY_DEFAULT_RX_LED_PIN  11  // Receive led pin
        //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
        
        #define MY_DEBUG
        
        #include <SPI.h>
        #include <MySensors.h>  
        #include <DHT.h>
        
        
        // Set this to the pin you connected the DHT's data pin to
        #define DHT_DATA_PIN 3
        
        // Set this offset if the sensor has a permanent small offset to the real temperatures
        #define SENSOR_TEMP_OFFSET 0
        
        // Sleep time between sensor updates (in milliseconds)
        // Must be >1000ms for DHT22 and >2000ms for DHT11
        static const uint64_t UPDATE_INTERVAL = 2500;
        
        // Force sending an update of the temperature after n sensor reads, so a controller showing the
        // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
        // the value didn't change since;
        // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
        static const uint8_t FORCE_UPDATE_N_READS = 10;
        
        #define CHILD_ID_HUM 0
        #define CHILD_ID_TEMP 1
        
        float lastTemp;
        float lastHum;
        uint8_t nNoUpdatesTemp;
        uint8_t nNoUpdatesHum;
        bool metric = true;
        
        MyMessage msgHum(CHILD_ID_HUM, V_HUM);
        MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
        DHT dht;
        
        
        void presentation()  
        { 
          // Send the sketch version information to the gateway
          sendSketchInfo("TemperatureAndHumidity", "1.1");
        
          // Register all sensors to gw (they will be created as child devices)
          present(CHILD_ID_HUM, S_HUM);
          present(CHILD_ID_TEMP, S_TEMP);
        
          metric = getConfig().isMetric;
        }
        
        
        void setup()
        {
          present(255, 18);
          dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
          if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
            Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
          }
          // Sleep for the time of the minimum sampling period to give the sensor time to power up
          // (otherwise, timeout errors might occure for the first reading)
          sleep(dht.getMinimumSamplingPeriod());
        }
        
        
        void loop()      
        {  
          // Force reading sensor, so it works also after sleep()
          dht.readSensor(true);
        
          // Get temperature from DHT library
          float temperature = dht.getTemperature();
          if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT!");
          } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
            // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
            lastTemp = temperature;
            if (!metric) {
              temperature = dht.toFahrenheit(temperature);
            }
            // Reset no updates counter
            nNoUpdatesTemp = 0;
            temperature += SENSOR_TEMP_OFFSET;
            send(msgTemp.set(temperature, 1));
        
            #ifdef MY_DEBUG
            Serial.print("T: ");
            Serial.println(temperature);
            #endif
          } else {
            // Increase no update counter if the temperature stayed the same
            nNoUpdatesTemp++;
          }
        
          // Get humidity from DHT library
          float humidity = dht.getHumidity();
          if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
          } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
            // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
            lastHum = humidity;
            // Reset no updates counter
            nNoUpdatesHum = 0;
            send(msgHum.set(humidity, 1));
        
            #ifdef MY_DEBUG
            Serial.print("H: ");
            Serial.println(humidity);
            #endif
          } else {
            // Increase no update counter if the humidity stayed the same
            nNoUpdatesHum++;
          }
        
          // Sleep for a while to save energy
          sleep(UPDATE_INTERVAL); 
        }
        
        1 Reply Last reply
        0
        • martinhjelmareM Offline
          martinhjelmareM Offline
          martinhjelmare
          Plugin Developer
          wrote on last edited by
          #5

          Looks like presentation function is never called. Try calling it yourself from setup.

          1 Reply Last reply
          0
          • MaKinM Offline
            MaKinM Offline
            MaKin
            wrote on last edited by
            #6

            How would you do that? You can see my sketch above.

            1 Reply Last reply
            0
            • martinhjelmareM Offline
              martinhjelmareM Offline
              martinhjelmare
              Plugin Developer
              wrote on last edited by
              #7

              Put this after the gateway present call in setup:

              presentation();
              

              Also replace all sleep with wait. The gateway is not allowed to sleep.

              MaKinM 1 Reply Last reply
              1
              • martinhjelmareM martinhjelmare

                Put this after the gateway present call in setup:

                presentation();
                

                Also replace all sleep with wait. The gateway is not allowed to sleep.

                MaKinM Offline
                MaKinM Offline
                MaKin
                wrote on last edited by MaKin
                #8

                @martinhjelmare said:

                presentation();

                I'll try that. Thanks. :)

                Now this error remains:

                16-12-17 21:58:00 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.90
                
                16-12-17 21:58:00 mysensors.mysensors: Error decoding message from gateway, bad data received: H: 49.30
                
                16-12-17 21:58:02 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 24.00
                
                16-12-17 21:58:14 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.90
                

                But the sensors are listed in HASS:

                sensor.temperatureandhumidity_0_0:

                friendly_name: TemperatureAndHumidity 0 0
                V_HUM: 49.2
                node_id: 0
                device: /dev/ttyACM0
                battery_level: 0
                description: 
                child_id: 0
                unit_of_measurement: %
                
                1 Reply Last reply
                0
                • martinhjelmareM Offline
                  martinhjelmareM Offline
                  martinhjelmare
                  Plugin Developer
                  wrote on last edited by martinhjelmare
                  #9

                  That's because you are printing debug to serial from the gateway and the controller doesn't expect serial messages from the gateway other than mysensors API messages. Either ignore the errors or remove those debug prints.

                  MaKinM 1 Reply Last reply
                  1
                  • martinhjelmareM martinhjelmare

                    That's because you are printing debug to serial from the gateway and the controller doesn't expect serial messages from the gateway other than mysensors API messages. Either ignore the errors or remove those debug prints.

                    MaKinM Offline
                    MaKinM Offline
                    MaKin
                    wrote on last edited by
                    #10

                    @martinhjelmare thank you so much for your help. :)

                    Is there a way to declare sensor names so that HA receives a presentation with something like

                    mysensors.livingroom.temp

                    Instead of a more cryptic name with node_id?

                    1 Reply Last reply
                    1
                    • martinhjelmareM Offline
                      martinhjelmareM Offline
                      martinhjelmare
                      Plugin Developer
                      wrote on last edited by
                      #11

                      The entity_id always has the same structure, sketchname_nodeid_childid. You can customize the friendly_name in the config under customize to change what is shown in the gui as name of the sensor.

                      1 Reply Last reply
                      1
                      • MaKinM Offline
                        MaKinM Offline
                        MaKin
                        wrote on last edited by
                        #12

                        But my Sketch name is SerialGateWayDHT22 and my sensors are called sensor.temperatureandhumidity_0_0 and sensor.temperatureandhumidity_0_1. If it was the Sketchname, it was much simpler to assign the sensors to the rooms later as I could simply name the switch after the room.

                        But it's not much of a problem, as like you said friendly names can be used.

                        1 Reply Last reply
                        0
                        • martinhjelmareM Offline
                          martinhjelmareM Offline
                          martinhjelmare
                          Plugin Developer
                          wrote on last edited by martinhjelmare
                          #13

                          By sketchname I mean what you send to the controller as sketchname using sendSketchInfo method. This is from your sketch:

                            // Send the sketch version information to the gateway
                            sendSketchInfo("TemperatureAndHumidity", "1.1");
                          
                          1 Reply Last reply
                          0
                          • MaKinM Offline
                            MaKinM Offline
                            MaKin
                            wrote on last edited by
                            #14

                            Just saw that myself. Thanks once again. I'm starting to feel embarrassed... :)

                            1 Reply Last reply
                            1
                            • martinhjelmareM Offline
                              martinhjelmareM Offline
                              martinhjelmare
                              Plugin Developer
                              wrote on last edited by
                              #15

                              Happy to help and great to hear about user stories and also any feedback, both when things are working and when things are not working or missing features.

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


                              19

                              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