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. Announcements
  3. 💬 Air Humidity Sensor - DHT

💬 Air Humidity Sensor - DHT

Scheduled Pinned Locked Moved Announcements
149 Posts 48 Posters 47.8k Views 38 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.
  • P Offline
    P Offline
    Pavel Polititsky
    wrote on last edited by
    #134

    In a serial debug of the sensor module
    It write something like "Failed to read data humidity (temperature)
    Also no send any data to gateway

    Without getMinimumSamplingPeriod I've receiving hum & temp through gateway

    1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #135

      DHT sensor is not very fast, it needs some times between initialization and the different readings

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Maschler
        wrote on last edited by
        #136

        Hi
        this program doesn’t work with my setup. For the Gateway I am using a Ardunio nano as a serial Gateway. Thus, I am using the GatewaySerial.ino. Even the Node is based on an Arduino nano with a DHT22 connected. The general communication between both seems to work. But I do not receive any sensor data. When testing the setup with another library for the dht sensor, it works fine (without sending to the gateway, only serial Monitor). Because I am new in the mysensors community there is perhaps a simple mistake which I don’t see… I hope you can help me finding my mistake.
        Here is a short extract of the Debugging Information’s. As far as I see there are no data transferred.
        Gateway:

        0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RRNGA---,VER=2.3.0
        0;255;3;0;9;4 TSM:INIT
        0;255;3;0;9;6 TSF:WUR:MS=0
        0;255;3;0;9;9 TSM:INIT:TSP OK
        0;255;3;0;9;12 TSM:INIT:GW MODE
        0;255;3;0;9;15 TSM:READY:ID=0,PAR=0,DIS=0
        0;255;3;0;9;19 MCO:REG:NOT NEEDED
        0;255;3;0;14;Gateway startup complete.
        0;255;0;0;18;2.3.0
        0;255;3;0;9;23 MCO:BGN:STP
        0;255;3;0;9;29 MCO:BGN:INIT OK,TSP=1
        0;255;3;0;9;1907 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
        0;255;3;0;9;1913 TSF:MSG:BC
        0;255;3;0;9;1916 TSF:MSG:FPAR REQ,ID=255
        0;255;3;0;9;1920 TSF:CKU:OK,FCTRL
        0;255;3;0;9;1923 TSF:MSG:GWL OK
        0;255;3;0;9;4047 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
        0;255;3;0;9;5136 TSF:MSG:READ,255-255-0,s=187,c=3,t=3,pt=0,l=0,sg=0:
        255;187;3;0;3;
        0;255;3;0;9;7150 TSF:MSG:READ,255-255-0,s=155,c=3,t=3,pt=0,l=0,sg=0:
        255;155;3;0;3;
        0;255;3;0;9;9164 TSF:MSG:READ,255-255-0,s=123,c=3,t=3,pt=0,l=0,sg=0:
        255;123;3;0;3;
        0;255;3;0;9;11179 TSF:MSG:READ,255-255-0,s=91,c=3,t=3,pt=0,l=0,sg=0:
        255;91;3;0;3;
        Sensor:
        16 MCO:BGN:INIT NODE,CP=RRNNA---,VER=2.3.0
        25 TSM:INIT
        26 TSF:WUR:MS=0
        29 TSM:INIT:TSP OK
        30 TSM:FPAR
        1250 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
        1368 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
        1373 TSF:MSG:FPAR OK,ID=0,D=1
        1571 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
        1774 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
        1977 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
        3257 TSM:FPAR:OK
        3258 TSM:ID
        3259 TSM:ID:REQ
        3267 TSF:MSG:SEND,255-255-0-0,s=187,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
        5274 TSM:ID
        5275 TSM:ID:REQ
        5283 TSF:MSG:SEND,255-255-0-0,s=155,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
        7290 TSM:ID
        7291 TSM:ID:REQ
        7299 TSF:MSG:SEND,255-255-0-0,s=123,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
        9306 TSM:ID
        9307 TSM:ID:REQ
        9315 TSF:MSG:SEND,255-255-0-0,s=91,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
        11322 !TSM:ID:FAIL
        11323 TSM:FAIL:CNT=1
        11325 TSM:FAIL:DIS
        11327 TSF:TDI:TSL
        21330 TSM:FAIL:RE-INIT
        21332 TSM:INIT
        21335 TSM:INIT:TSP OK
        21337 TSM:FPAR

        1 Reply Last reply
        0
        • bgunnarbB Offline
          bgunnarbB Offline
          bgunnarb
          wrote on last edited by
          #137

          Hi!
          What controller are you using?
          From the logs it seems that the sensor is asking for an ID but does not get any.
          Node ID is handed out by the controller. Or else you have to set the node ID in the sketch. What does the sketch look like?

          I have never been so busy since I retired!

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Maschler
            wrote on last edited by
            #138

            Hi
            thanks for reply. I am using this sketch: https://github.com/mysensors/MySensors/blob/development/examples/GatewaySerial/GatewaySerial.ino
            The only thing I changed is the radio type and I disabled the inclusion mode.

            1 Reply Last reply
            0
            • bgunnarbB Offline
              bgunnarbB Offline
              bgunnarb
              wrote on last edited by
              #139

              Yes but the issue is with the sensor node. What sketch are you using there?

              I have never been so busy since I retired!

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Maschler
                wrote on last edited by
                #140

                Oh. I am using the sketch in from above and only changed the radio module.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Maschler
                  wrote on last edited by
                  #141

                  @bgunnarb
                  You are right. I had to define a sensor id and now it works perfectly :) Thank you very much!

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    roachgf85
                    wrote on last edited by
                    #142

                    Note: Double check your DHT11 module! The pinouts of the PCB of my DHT11 module differed from those in this article. My leftmost pin was Data out, the middle pin was VCC and the right was GND.

                    1 Reply Last reply
                    0
                    • cneroneC Offline
                      cneroneC Offline
                      cnerone
                      wrote on last edited by
                      #143

                      Hi all,
                      I recoded this sketch and I posted on GitHub (1 year ago, and I updated it today). It runs good from 1 year with no issues.
                      I don't know why it's still not merged in master branch. I forgot to do some action??
                      Can anyone help me? please.
                      Meanwhile you can download and use it; this is its link:
                      https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino

                      mfalkviddM 1 Reply Last reply
                      1
                      • cneroneC cnerone

                        Hi all,
                        I recoded this sketch and I posted on GitHub (1 year ago, and I updated it today). It runs good from 1 year with no issues.
                        I don't know why it's still not merged in master branch. I forgot to do some action??
                        Can anyone help me? please.
                        Meanwhile you can download and use it; this is its link:
                        https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino

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

                        @cnerone no you did 't forget anything. It is just that the external examples don't get much attention and are a bit truoublesome (due to the need of handling third party libraries).

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          rmalbers
                          wrote on last edited by
                          #145

                          I used the code that cnerone has in his comment below with a nano and DHT22 and it worked great. For my nano I did have to use the 'old' bootloader for the program to download into the nano correctly with the arduino IDE. The code in the example here wouldn't compile for me, I think because someone changed the DHT library but for some reason kept the name the same so I ran into some kind of conflicts with variables. I wish when people modified libraries they would give them new/different names because the IDE does not have a good way of handling multiple libraries with the same name. BTW: That is not a MySensors issue, it's the IDE.

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            rmalbers
                            wrote on last edited by
                            #146

                            Also, I could not get a clean compile/download to a arduino mini 3.3v with 168 processor. From what I could find there is not enough memory to handle the newest mysensor libraries, at least that's what some people are saying in forums. I didn't spend much time on it and moved on to other arduinos.

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              catchra
                              wrote on last edited by
                              #147

                              For any one that needs it this is how I got the DHT22 to work.
                              This is my poor attempt at trying to get the DHT22 to work as the original code
                              https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino
                              will not compile for me.

                              // Enable debug prints
                              #define MY_DEBUG
                              
                              // Enable and select radio type attached 
                              #define MY_RADIO_RF24
                              //#define MY_RADIO_RFM69
                              //#define MY_RS485
                              
                              #define MY_RF24_CE_PIN 9
                              #define MY_RF24_CS_PIN 10
                              
                              #include <SPI.h>
                              #include <MySensors.h>  
                              #include <DHT.h>
                              
                              // Set this to the pin you connected the DHT's data pin to
                              #define DHTPIN 2     // what digital pin we're connected to
                              #define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
                              
                              #define CHILD_ID_HUM 0
                              #define CHILD_ID_TEMP 1
                              
                              MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                              MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
                              DHT dht(DHTPIN, DHTTYPE);
                              
                              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);
                                
                              }
                              
                              void setup()
                              {
                                dht.begin(); // set data pin of DHT sensor
                              
                              }
                              
                              void loop()      
                              {  
                               delay(2000);
                               // Reading temperature or humidity takes about 250 milliseconds!
                                // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
                                float h = dht.readHumidity();
                                // Read temperature as Celsius (the default)
                                float t = dht.readTemperature();
                                // Read temperature as Fahrenheit (isFahrenheit = true)
                                float f = dht.readTemperature(true);
                              
                                // Check if any reads failed and exit early (to try again).
                                if (isnan(h) || isnan(t) || isnan(f)) {
                                  return;
                                }
                              
                                // Compute heat index in Fahrenheit (the default)
                                float hif = dht.computeHeatIndex(f, h);
                                // Compute heat index in Celsius (isFahreheit = false)
                                float hic = dht.computeHeatIndex(t, h, false);
                                
                              
                                  send(msgTemp.set(f, 1));
                                  send(msgHum.set(h, 1));
                              
                                }
                              
                              skywatchS 1 Reply Last reply
                              1
                              • C catchra

                                For any one that needs it this is how I got the DHT22 to work.
                                This is my poor attempt at trying to get the DHT22 to work as the original code
                                https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino
                                will not compile for me.

                                // Enable debug prints
                                #define MY_DEBUG
                                
                                // Enable and select radio type attached 
                                #define MY_RADIO_RF24
                                //#define MY_RADIO_RFM69
                                //#define MY_RS485
                                
                                #define MY_RF24_CE_PIN 9
                                #define MY_RF24_CS_PIN 10
                                
                                #include <SPI.h>
                                #include <MySensors.h>  
                                #include <DHT.h>
                                
                                // Set this to the pin you connected the DHT's data pin to
                                #define DHTPIN 2     // what digital pin we're connected to
                                #define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
                                
                                #define CHILD_ID_HUM 0
                                #define CHILD_ID_TEMP 1
                                
                                MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                                MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
                                DHT dht(DHTPIN, DHTTYPE);
                                
                                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);
                                  
                                }
                                
                                void setup()
                                {
                                  dht.begin(); // set data pin of DHT sensor
                                
                                }
                                
                                void loop()      
                                {  
                                 delay(2000);
                                 // Reading temperature or humidity takes about 250 milliseconds!
                                  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
                                  float h = dht.readHumidity();
                                  // Read temperature as Celsius (the default)
                                  float t = dht.readTemperature();
                                  // Read temperature as Fahrenheit (isFahrenheit = true)
                                  float f = dht.readTemperature(true);
                                
                                  // Check if any reads failed and exit early (to try again).
                                  if (isnan(h) || isnan(t) || isnan(f)) {
                                    return;
                                  }
                                
                                  // Compute heat index in Fahrenheit (the default)
                                  float hif = dht.computeHeatIndex(f, h);
                                  // Compute heat index in Celsius (isFahreheit = false)
                                  float hic = dht.computeHeatIndex(t, h, false);
                                  
                                
                                    send(msgTemp.set(f, 1));
                                    send(msgHum.set(h, 1));
                                
                                  }
                                
                                skywatchS Offline
                                skywatchS Offline
                                skywatch
                                wrote on last edited by
                                #148

                                @catchra This bit might be important.....
                                "This example uses a modified version of the external DHT library, which is included in the MySensors external examples. Please install it and restart the Arduino IDE before trying to compile."

                                Did you do this already?

                                C 1 Reply Last reply
                                0
                                • skywatchS skywatch

                                  @catchra This bit might be important.....
                                  "This example uses a modified version of the external DHT library, which is included in the MySensors external examples. Please install it and restart the Arduino IDE before trying to compile."

                                  Did you do this already?

                                  C Offline
                                  C Offline
                                  catchra
                                  wrote on last edited by
                                  #149

                                  @skywatch
                                  ya i did try that 1st but it did not work so I tried to get it to work with the updated lib and so far it has been working well

                                  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.0k

                                  Posts


                                  Copyright 2019 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