my ky-015 temp humidity sensor readings wrong

I have a duinotech sensor (identical to keyes ky-015 Temperature Humidity sensor module. Sitting on my desk is my enviromental DMM. the Multimeter is reporting 60%rh and 20.2degC, the weather station across the room is reporting 6%rh at 19.5 yet the duinotech/keyes module is giving me 42.1% humidity and flicking between 30.1 and 31.1deg C.

The code I got was from a github page for the sensor. I have the readings coming up on a oled screen.

Top of code:

//
//KY015 DHT11 Temperature and humidity sensor setup (code snippet from sample code)
int DHpin =8;
byte dat [5];
byte read_data (){
byte data;
for(int i =0;i < 8;i ++) {
if(digitalRead (DHpin)==LOW) {
while (digitalRead (DHpin)==LOW); // wait for 50us
delayMicroseconds (30);// determine the duration of the high level to determine the data is '0 'or '1'
if (digitalRead (DHpin)==HIGH)
data |= (1<< (7-i));// high front and low in the post
while (digitalRead (DHpin)==HIGH);// data '1 ', wait for the next one receiver
}
}
return data;
}

part of setup that deals with sensors:

// ******** config sensor pins
  pinMode (ldr,INPUT);
  pinMode (DHpin,OUTPUT);
 delay(20000); //  delay to alow all sensors to stabilise. this MUST be last line in setup AFTER pin configs

the part of the code that reads the sensor:

void temp_hum_read(){  // rerad digital temp and humidity sensor
  
digitalWrite (DHpin,LOW);// bus down, send start signal
delay (30);// delay greater than 18ms, so DHT11 start signal can be detected
digitalWrite (DHpin,HIGH);
delayMicroseconds (40); // Wait for DHT11 response

pinMode (DHpin,INPUT);
while(digitalRead (DHpin)==HIGH);
   delayMicroseconds (80); // DHT11 response, pulled the bus 80us
if(digitalRead (DHpin) ==LOW);
    
delayMicroseconds (80); // DHT11 80us after the bus pulled to start sending data
for(int i =0;i < 4;i ++) // receive temperature and humidity data, the parity bit is not considered
       dat[i] =read_data ();
pinMode (DHpin,OUTPUT);
digitalWrite (DHpin,HIGH);// send data once after releasing the bus, wait for the host to open the next Start signal

}

Try the library (found in library manager) for DHT11
Remember to uncomment the line for DHT11

testing the sensor with that library and the example code.
it's now telling me it's 614degc 819% humidity.

I have put the 10k resister between power and data as per instructions in the example code.
I guess i'd better get a new sensor and try that (have to be after work thursday as thats my friday).
It came as part of a pack of 37 differant sensors in a plastic parts box. Don't know if the summer heat has affected it at all (even our autum/fall has been warmer than usual sofar this year in New Zealand) as i brought the pack six months ago.

i just blew on it from 1" which pushed it up to 716degC and 921% humidity

..you har tried all..? DHT11/21/22 ?

There were two in the library management tool in the arduino IDE.
The Adafruit unified - when I tried to run the example included with the library just now I got a string of errors that were in the adafruit_sensor.h.

The other DHT sensor library was the on board I was trying yesterday (New Zealand time).

The code I posted above - the part that handles the sensor was from the example code from a third party site that had details of all the keyes sensors that were in the kit I brought last year. the only place I could find details of all the sensors in one place.

Note the commented sentences in the DHT library (to select type of sensor)

The DTH22 can be read every 2 seconds.. The DHT11 once a second

I was having the same readings of degrees in the hundreds range and when it should've decreased it actually increased and I found I was wiring the pins up in the wrong fashion. Not sure if this will help your problem but I think if you tried with the one you had the high readouts with that you will get the correct results.

Thanks.

With the sensor still set up exactly as it was yesterday (arduino nested in a hole surrounded by 2 white protoboards and vcc/gnd bus rails)

I redownloaded both the DHT sensor library and the Adafruit unified sensor library then for the latter had to get Adafruit_Sensor.h.

Both of these libraries examples are giving me 22degC at 33% humidity.
Beside the sensor my Enviromental Digital Multi Meter (Jaycar QM1594) is giving me 19.8 and 60% relative humidity and it's external probe 21degC. the weather station across the room is 21.4degC 59% relative humidity.

i held sensor 1" ocer a warm cuppa (59deg by temp probe) and it went up to 35% humidiry and 23degC

after 10 minutes after holding it over cuppa, I'm getting 22degC and 33% humidity.

It's only $10NZD for another module so will probably get another and compare readings between the two.. The humidity looks a bit sus

Just brought a new sensor module.

I am still getting only 29-30% humidity when my enviromental meter is 61% and weather box saying 60% indoors.

I might be completely mistaken :o :o :o , but I just calculated the "absurdity" of my ky-015 results and come to the conclusion (since I believed it was giving me a multiplier of some number, some malcalibration, since it was indeed reacting to the environment) that the number was squared! I will post my readings and results, comparing to my Casio (which gives me +-27 *C right now).

I humbly, humbly, accept any comments on the matter. I can imagine our friend with his ackward results 4 months ago.

Humidity (raw)	Temperature (raw)	sqrt(temp)	sqrt(hum)
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1612,80	716,80	26,77312085	40,15968127
1612,80	742,40	27,24701819	40,15968127
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1612,80	716,80	26,77312085	40,15968127
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1587,20	742,40	27,24701819	39,83967871
1612,80	716,80	26,77312085	40,15968127
1612,80	716,80	26,77312085	40,15968127
1612,80	716,80	26,77312085	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1612,80	742,40	27,24701819	40,15968127
1612,80	742,40	27,24701819	40,15968127
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405
1638,40	716,80	26,77312085	40,47715405

krazydarcy:
Just brought a new sensor module.

I am still getting only 29-30% humidity when my enviromental meter is 61% and weather box saying 60% indoors.

That's because you need to calibrate the sensor. Almost not a single guide about those sensors talk about calibration, but it's definitely needed. Every sensor I have for measuring humidity needs calibration.

It's really easy.

  1. Fill a shell with kitchen salt.
  2. Pour water in it and make a mixture of salt and water.
  3. Attach your sensor to the Arduino.
  4. Put your sensor together with a shell filled with salt into a plastic bag.
  5. Leave the sensor in the bag for 24 hours.
  6. After 24 hours the humidity is exactly 75%. Adjust your code to match the 75% humidity.

That's it, your sensor is now working properly.

Here is some more info:
https://www.stevejenkins.com/blog/2014/06/how-to-calibrate-a-hygrometer-humidity-sensor-using-the-salt-test/

In your case you can also just add +30% to the output in your code because you already have a reference point. But it would be more accurate to calibrate it yourself.