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 7.8k 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.
  • S Offline
    S 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

    Y 1 Reply Last reply
    0
    • S 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

      Y Offline
      Y 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
      • S Offline
        S 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
          • Y Offline
            Y 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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            17

            Online

            12.0k

            Users

            11.2k

            Topics

            113.4k

            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