DHT22 - switched sensor types?

  • Hi,

    i am trying to set up a DHT22 node. This is my first step with mysensors ever. After figuring out some hardware issues, all connection is working, at least for a distance of around 1 meters.

    However, i'd like to ask how big can a temperature offset of a DHT22 sensor be? I have a room temperature of around 22°C, however, this sensor shows around 28°C - and a humiditiy of 23%. So, either the measurement tolerance is quite big, or i have somehow switched both readings.

    This is the code i have flashed on the node: https://pastebin.com/E2XWu3F3
    And this is how it appears in Home Assistant: https://pastebin.com/rLWn91ws

    Is my code correct? I think i have some weird errors, e.g. only increasing temperature is registered, when decreasing temperature, the value isn't decreasing as well.

  • Hero Member

    @simonszu Looks like you have the temp and humidity swapped around in the send message part

    here is a direct copy of your sketch. you are sending the temperature in the humidity message and humidity in the temp message

      send(msgHum.set(temperature, 1));    // this should be humidity
      #ifdef My_DEBUG
      Serial.print("T: ")
      send(msgTemp.set(humidity, 1));   // this should be temperature

  • Ah. Yeah. Thanks. Sometimes one can be really blind when debugging own code. 😄

  • Hero Member

    @simonszu Yes I know the feeling well !! Hope it all works as expected now

  • Mod

    dht sensors are not very accurate anyway 😅

Log in to reply

Suggested Topics

  • 7
  • 38
  • 10
  • 182
  • 186
  • 10
  • 4
  • 5