DHT11 giving wrong measurement data

Hey,

i'm currently working on a project. For this i need to measure humidity and temperature on two different places (one outside, one inside). I am doing this by using two DHT11-sensors with an Arduino Uno R3, I switch between the two sensors with an for-loop, which is switching through the pins (I use digital 2 and digital 3). Well, that far it's working out fine.

On the beginning i got the exact same values of both the sensors since they are directly next to each other (that means about 20°C and 40% hum).

After some time (and some restarts..) one of the two DHT11-sensors i use started giving crazy data. the first sensor was still giving the 20°C and 40% hum, but the second was giving out values about 20°C and 25% hum. The wrong data came from the sensor at the Pin 3 location.

I switched the sensors, now the wrong data came from Pin 2. I switched the wires on pin 2, no change at all.

Then I tested whether the wrong sensor is still measureing while taking them outside on a foggy day. The values from the right sensor changed to the real ones this day, but the wrong sensor was still measuring about 20% below the reality, the temperature readings were okay.

I exchanged the wrong sensor, and i got good values again. But the same now happend again.

Since I am pretty new into Arduino and programming at all, I am pretty sure i mismatched something, but i cant find the reason for that issue.

It would be nice if someone could help me, i am happy about anything, like suggestions about the code, ideas what could have went wrong, everything would be amazing.

mfg victore99

postscriptum: as you may have recognized, english is not a language i speak or write that often, and i am trying to improve. i know my current level is not good, i am really sorry for this.

You didn't provide the link to the library you're using for the communication with the DHT11s. I don't think that the sensor got bad because of a software error. Either the software does not communicate correctly with sensor and returning data that the sensor never sent or you simply got bad sensors. As the DHT11s are quite cheap sensors I can imagine the later is quite probable.

well, thank you! i got the problem solved, your idea about "returning data the sensor never sent" was completely right. it was some kind of a software bug which fixed itself after some flashing over some versions and some restarts. now the "bad sensor" is working fine again.. i dont know how that happend, but it worked out.

just to answer the questions, i used the SimpleDHT-libary, since it was delivered on the disk i got with my arduino-set.