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. Vera
  4. Can you calibrate DHT11?

Can you calibrate DHT11?

Scheduled Pinned Locked Moved Vera
5 Posts 3 Posters 6.7k 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.
  • stubtoeS Offline
    stubtoeS Offline
    stubtoe
    wrote on last edited by
    #1

    Hi all,

    Does anyone know if its possible to calibrate a DHT11 humidity/temperature sensor, specifically the temperature element?

    Based on other thermostats and temperature sensors it is reading about 2 degrees C high i.e. 23 deg C instead of 21 deg C.

    Alternatively, is there a way I can factor in an adjustment to the sketch so the temperature reported in the Arduino Temp device in Vera UI15 is reported 2 degrees lower?

    I've tried amending the code in the sketch as per below but this only changes the values printed to the serial monitor and not the device in Vera.

    [code]
    
    Serial.println(temperature - 2.0); // adjusted as reading 2 degrees C higher than room thermostat
    

    [/code]

    I'm a noob when it comes to Arduino, programming and Vera so please bear with me...

    Setup:

    • Vera Lite running UI15
    • Mysensors Serial Gateway
    • Mysensors DHT11 Humidity (& temperature) sensor

    Cheers,

    stubtoe

    YveauxY 1 Reply Last reply
    0
    • stubtoeS stubtoe

      Hi all,

      Does anyone know if its possible to calibrate a DHT11 humidity/temperature sensor, specifically the temperature element?

      Based on other thermostats and temperature sensors it is reading about 2 degrees C high i.e. 23 deg C instead of 21 deg C.

      Alternatively, is there a way I can factor in an adjustment to the sketch so the temperature reported in the Arduino Temp device in Vera UI15 is reported 2 degrees lower?

      I've tried amending the code in the sketch as per below but this only changes the values printed to the serial monitor and not the device in Vera.

      [code]
      
      Serial.println(temperature - 2.0); // adjusted as reading 2 degrees C higher than room thermostat
      

      [/code]

      I'm a noob when it comes to Arduino, programming and Vera so please bear with me...

      Setup:

      • Vera Lite running UI15
      • Mysensors Serial Gateway
      • Mysensors DHT11 Humidity (& temperature) sensor

      Cheers,

      stubtoe

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by Yveaux
      #2

      @stubtoe said:

      calibrate a DHT11 humidity/temperature sensor,

      Judging from the rest of your post you just want to lower the actual value reported by the sensor, correct?

      Don't change only the value printed to the serial port, as you do by changing the Serial.println statement.
      You should correct the value read from the sensor, e.g.:

      void loop()      
      {  
        delay(dht.getMinimumSamplingPeriod());
      
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
        } else if (temperature != lastTemp) {
          temperature = temperature - 2.0;   // Here you correct the value just read
          lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          gw.send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
        } 
      
      // etc....
      

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • stubtoeS Offline
        stubtoeS Offline
        stubtoe
        wrote on last edited by
        #3

        Yes that was correct, so your solution has worked perfectly. Thank you.

        I also understand where I went wrong now so thank you for point that out. I probably should have figured that out myself if I'd read and understood the code a bit better, but hey ho...

        1 Reply Last reply
        0
        • mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          That code will report the temperature every time, unless the new temperature is two degrees higher than last temperature.
          I guess it's not a big problem, but this is a more correct solution:

          void loop()
          {
            delay(dht.getMinimumSamplingPeriod());
          
            float temperature = dht.getTemperature();
            if (isnan(temperature)) {
              Serial.println("Failed reading temperature from DHT");
            } else {
              temperature = temperature - 2.0;   // Here you correct the value just read
              if (temperature != lastTemp) {
          
                lastTemp = temperature;
                if (!metric) {
                  temperature = dht.toFahrenheit(temperature);
                }
                gw.send(msgTemp.set(temperature, 1));
                Serial.print("T: ");
                Serial.println(temperature);
              }
            }
          // etc....
          
          1 Reply Last reply
          0
          • YveauxY Offline
            YveauxY Offline
            Yveaux
            Mod
            wrote on last edited by
            #5

            @mfalkvidd :+1:
            I personally prefer to immediately correct the value when read from the dht:

            float temperature = dht.getTemperature() - 2.0;
            

            In case the dht returns a NaN value, this value will stay NaN even when 2.0 is substracted.
            But I didn't want to complicate things ;-)

            http://yveaux.blogspot.nl

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


            8

            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