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.9k 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.
  • gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by
    #112

    It's a Domoticz problem, sometimes just rebooting everything can solve but try to search on domoticz forum too.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cristi
      wrote on last edited by
      #113

      2 issues I see with the example:
      a) I'm not a native english speaker, but to me, on top of the page, "sampling rate" of "2 times/sec" for dht-22 is wrong. From code and pdf you can see that you can't ask for data faster than at 2 seconds.
      As such, I would change the top of the page to read either "0.5 times/sec" or "1 time at 2 seconds".

      b) use of SENSOR_TEMP_OFFSET is wrong. Because depending on how the controller wants this sensor's data (Celsius | Fahrenheit), the offset will be different. If you happen to change the metric system value in the controller and ask for the data (after sensor restart let's say), you'll get a different value than expected).
      I would do:

        • add to the comment for SENSOR_TEMP_OFFSET that we're talking about a Celsius offset
        • and move the statement "temperature += SENSOR_TEMP_OFFSET;" before the conversion to Fahrenheit.

      Regards.

      mfalkviddM 1 Reply Last reply
      1
      • C cristi

        2 issues I see with the example:
        a) I'm not a native english speaker, but to me, on top of the page, "sampling rate" of "2 times/sec" for dht-22 is wrong. From code and pdf you can see that you can't ask for data faster than at 2 seconds.
        As such, I would change the top of the page to read either "0.5 times/sec" or "1 time at 2 seconds".

        b) use of SENSOR_TEMP_OFFSET is wrong. Because depending on how the controller wants this sensor's data (Celsius | Fahrenheit), the offset will be different. If you happen to change the metric system value in the controller and ask for the data (after sensor restart let's say), you'll get a different value than expected).
        I would do:

          • add to the comment for SENSOR_TEMP_OFFSET that we're talking about a Celsius offset
          • and move the statement "temperature += SENSOR_TEMP_OFFSET;" before the conversion to Fahrenheit.

        Regards.

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

        Thanks @cristi
        I have updated the table with the sample rate. Could you check if it looks good?

        For the code change a pull request will be needed. Could you do one? If you can't I'll add it to my todo but it might take a while.

        C 1 Reply Last reply
        0
        • mfalkviddM mfalkvidd

          Thanks @cristi
          I have updated the table with the sample rate. Could you check if it looks good?

          For the code change a pull request will be needed. Could you do one? If you can't I'll add it to my todo but it might take a while.

          C Offline
          C Offline
          cristi
          wrote on last edited by
          #115

          @mfalkvidd

          • there's a typo in the table for DHT-11: it should be '1s per sample' instead of '10s per sample'
          • I created a pull request
          mfalkviddM 1 Reply Last reply
          0
          • C cristi

            @mfalkvidd

            • there's a typo in the table for DHT-11: it should be '1s per sample' instead of '10s per sample'
            • I created a pull request
            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #116

            @cristi according to http://www.micropik.com/PDF/dht11.pdf typical response time is 10s. Am I looking at the wrong number?

            Great work on the pull request. I'm adding a link in case someone needs it in the future. https://github.com/mysensors/MySensorsArduinoExamples/pull/29/

            C 1 Reply Last reply
            0
            • mfalkviddM mfalkvidd

              @cristi according to http://www.micropik.com/PDF/dht11.pdf typical response time is 10s. Am I looking at the wrong number?

              Great work on the pull request. I'm adding a link in case someone needs it in the future. https://github.com/mysensors/MySensorsArduinoExamples/pull/29/

              C Offline
              C Offline
              cristi
              wrote on last edited by
              #117

              @mfalkvidd Indeed, I see that 10 seconds in pdf, but it looks strange. I'd have to re-read to see if I can get what it is supposed to be for.
              But, meanwhile, in the same pdf, you get this note (chapter 6): "Note: Sampling period at intervals should be no less than 1 second.". Also, DHT library is using 1second sampling period.

              mfalkviddM 1 Reply Last reply
              0
              • C cristi

                @mfalkvidd Indeed, I see that 10 seconds in pdf, but it looks strange. I'd have to re-read to see if I can get what it is supposed to be for.
                But, meanwhile, in the same pdf, you get this note (chapter 6): "Note: Sampling period at intervals should be no less than 1 second.". Also, DHT library is using 1second sampling period.

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

                @cristi thanks. I have updated the table.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  ricmail85
                  wrote on last edited by
                  #119

                  I've created a DHT11 sensor based on this sketch. However the temperatures (and humidities) are reported as integer numbers in domoticz (either by looking at the devices and setup tabs). In the sketch I've specified the number of decimals like send(msgHum.set(temperatire, 2)). Even if I try larger decimal numbers, nothing change when the value is received in domoticz. What can I do?
                  Thanks in advance.

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

                    What kind of variable did you set for your "temperature"? If you can post your code it would help

                    1 Reply Last reply
                    0
                    • R ricmail85

                      I've created a DHT11 sensor based on this sketch. However the temperatures (and humidities) are reported as integer numbers in domoticz (either by looking at the devices and setup tabs). In the sketch I've specified the number of decimals like send(msgHum.set(temperatire, 2)). Even if I try larger decimal numbers, nothing change when the value is received in domoticz. What can I do?
                      Thanks in advance.

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

                      @ricmail85 you mean you're only getting integers here?
                      0_1516118501351_97c9afbc-5d93-4fc1-8886-2d8e6fd7c22c-image.png

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        ricmail85
                        wrote on last edited by
                        #122

                        @mfalkvidd yes I see only integer numbers here and in devices.

                        @gohan I've declared the variable temperature as float. However after I bit of debugging I found that it seems to be related to the dht lib included in the mysensors examples. If the model is dht11 the library is set for 0 decimals. For the dht22 it would be 1 decimal.

                        Am I right? Thanks in advance

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          scottdube
                          wrote on last edited by
                          #123

                          NEWBIE ALERT -- Has anyone else had trouble getting the code above to compile? I'm getting the following error.

                          ysensors_Humidity:91: error: 'class DHT' has no member named 'setup'
                          dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
                          ^
                          Mysensors_Humidity:92: error: 'class DHT' has no member named 'getMinimumSamplingPeriod'
                          if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
                          ^
                          Mysensors_Humidity:97: error: 'class DHT' has no member named 'getMinimumSamplingPeriod'
                          sleep(dht.getMinimumSamplingPeriod());
                          ^
                          /Users/scottdube/Documents/Arduino/Mysensors_Humidity/Mysensors_Humidity.ino: In function 'void loop()':
                          Mysensors_Humidity:104: error: 'class DHT' has no member named 'readSensor'
                          dht.readSensor(true);
                          ^
                          Mysensors_Humidity:107: error: 'class DHT' has no member named 'getTemperature'
                          float temperature = dht.getTemperature();
                          ^
                          Mysensors_Humidity:114: error: 'class DHT' has no member named 'toFahrenheit'
                          temperature = dht.toFahrenheit(temperature);
                          ^
                          Mysensors_Humidity:131: error: 'class DHT' has no member named 'getHumidity'
                          float humidity = dht.getHumidity();
                          ^
                          exit status 1
                          no matching function for call to 'DHT::DHT()'

                          Thanks

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

                            I guess you are using a different dht library version

                            S 1 Reply Last reply
                            2
                            • gohanG gohan

                              I guess you are using a different dht library version

                              S Offline
                              S Offline
                              scottdube
                              wrote on last edited by
                              #125

                              @gohan I got it past that point... Now I can't tell what the humidity or temp is? I cannot seem to find where (what file) controls what is being output. See below this is from my serial gateway, I can't figure out what these values represent. :READ,255-255-0,s=36,c=3,t=3,pt=0,l=0,sg=0:
                              255;36;3;0;3;

                              0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RNNGA---,VER=2.2.0
                              0;255;3;0;9;4 TSM:INIT
                              0;255;3;0;9;6 TSF:WUR:MS=0
                              0;255;3;0;9;14 TSM:INIT:TSP OK
                              0;255;3;0;9;17 TSM:INIT:GW MODE
                              0;255;3;0;9;20 TSM:READY:ID=0,PAR=0,DIS=0
                              0;255;3;0;9;23 MCO:REG:NOT NEEDED
                              0;255;3;0;14;Gateway startup complete.
                              0;255;0;0;18;2.2.0
                              0;255;3;0;9;28 MCO:BGN:STP
                              0;255;3;0;9;34 MCO:BGN:INIT OK,TSP=1
                              0;255;3;0;9;30224 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
                              0;255;3;0;9;30231 TSF:MSG:BC
                              0;255;3;0;9;30233 TSF:MSG:FPAR REQ,ID=255
                              0;255;3;0;9;30237 TSF:PNG:SEND,TO=0
                              0;255;3;0;9;30240 TSF:CKU:OK
                              0;255;3;0;9;30243 TSF:MSG:GWL OK
                              0;255;3;0;9;30832 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;32237 TSF:MSG:READ,255-255-0,s=36,c=3,t=3,pt=0,l=0,sg=0:
                              255;36;3;0;3;
                              0;255;3;0;9;34249 TSF:MSG:READ,255-255-0,s=1,c=3,t=3,pt=0,l=0,sg=0:
                              255;1;3;0;3;
                              0;255;3;0;9;36260 TSF:MSG:READ,255-255-0,s=220,c=3,t=3,pt=0,l=0,sg=0:
                              255;220;3;0;3;
                              0;255;3;0;9;38270 TSF:MSG:READ,255-255-0,s=183,c=3,t=3,pt=0,l=0,sg=0:
                              255;183;3;0;3;

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

                                The is the log parser on the mysensors site. Anyway that means you didn't set a node ID on your node and it is asking for one but there is no controller providing one.

                                S 1 Reply Last reply
                                0
                                • I Offline
                                  I Offline
                                  Ihor
                                  wrote on last edited by
                                  #127

                                  I have some problem...

                                  C:\Users\ibaturin\Desktop\DHT\DHT.ino: In function 'void loop()':

                                  DHT:104: error: no matching function for call to 'DHT::readSensor(bool)'

                                  dht.readSensor(true);

                                                    ^
                                  

                                  C:\Users\ibaturin\Desktop\DHT\DHT.ino:104:22: note: candidate is:

                                  In file included from C:\Users\ibaturin\Desktop\DHT\DHT.ino:44:0:

                                  C:\ARDUINO\arduino-nightly\portable\sketchbook\libraries\arduino-DHT-master/DHT.h:83:8: note: void DHT::readSensor()

                                  void readSensor();

                                      ^
                                  

                                  C:\ARDUINO\arduino-nightly\portable\sketchbook\libraries\arduino-DHT-master/DHT.h:83:8: note: candidate expects 0 arguments, 1 provided

                                  exit status 1
                                  no matching function for call to 'DHT::readSensor(bool)'

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

                                    did you read this?
                                    https://forum.mysensors.org/topic/4326/can-t-compile-humidity-sketch-2-0-what-dht-library-do-i-need/18

                                    1 Reply Last reply
                                    1
                                    • gohanG gohan

                                      The is the log parser on the mysensors site. Anyway that means you didn't set a node ID on your node and it is asking for one but there is no controller providing one.

                                      S Offline
                                      S Offline
                                      scottdube
                                      wrote on last edited by
                                      #129

                                      @gohan Thank you I was able to resolve that issue and get it communication with the gateway, the vera and now mqtt. Thanks again!

                                      1 Reply Last reply
                                      1
                                      • joaoabsJ Offline
                                        joaoabsJ Offline
                                        joaoabs
                                        wrote on last edited by
                                        #130

                                        For the ones looking for a library that makes this DHT sketch work, mysensors have compiled a set of libraries that include this DHT.h and many others. Just go to https://www.mysensors.org/about/arduino#optional---install-external-mysensors-examples (yes, the name is not intuitive, maybe the keyword library would make it more obvious?), or jump directly to here and follow the standard library instructions. It took me two hours to find this, hope it saves time for future followers of mysensors like myself.

                                        Good luck!

                                        1 Reply Last reply
                                        2
                                        • joaoabsJ Offline
                                          joaoabsJ Offline
                                          joaoabs
                                          wrote on last edited by
                                          #131

                                          Here is the set of libraries where you can find the DHT.h: https://github.com/mysensors/MySensorsArduinoExamples/archive/master.zip

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


                                          11

                                          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