Check Sum Error DHT22
Posted: Sat Aug 26, 2017 11:06 pm
Hello,
I am having limited success working with a DHT22 Temperature and Humidity Sensor. At ambient temperature and humidity if reads fine using one of the many example sketches for this sensor, but when I pick it up or breath on it the sensor fails. I have activated debug in the DHT.h file and the check sum fails. I have 3 sensors, 2 running on a ATmega and 1 on the ESP32. No issues on the Mega and I have interchanged many times so are fairly sure the sensors are fine. I have some evidence that any sensor attached to the ESP32 reads about 0.5 degree C higher than on the ATMega, but as I write this for the first time in a couple of days they all match so this may not be an issue and more related to environment.
Below is the code I have used (from a ESP32 example, but have tried other versions). I have tried multiple libraries sourced from different places but with no success and always the same behavior. I did read that the sensor is better run on 5V so have used a level shifter to allow it to connect to the ESP32. The behavior is just the same as when it is run from the ESP32 3.3V supply.
Example of output change when breathing on the sensor connected to the ESP32. The other 2 (sitting next to this one) continue to read fine. Often going to 100% humidity or near.
Received:
2, 3A, 0, B7, F3 =? F3
Humidity: 57.00 % Temperature: 18.30 *C
Received:
3, 67, 0, B7, A1 =? 21
Checksum failure!
Failed to read from DHT sensor!
Received:
3, 67, 0, BA, A4 =? 24
Checksum failure!
Failed to read from DHT sensor!
The readings normally stop failing within 2-10 minutes. I did experience another type of fault with the debugging turned on once:
Timeout waiting for start signal low pulse.
Failed to read from DHT sensor!
I am fairly green at coding so would be very grateful for any advice.
Regards Blair
I am having limited success working with a DHT22 Temperature and Humidity Sensor. At ambient temperature and humidity if reads fine using one of the many example sketches for this sensor, but when I pick it up or breath on it the sensor fails. I have activated debug in the DHT.h file and the check sum fails. I have 3 sensors, 2 running on a ATmega and 1 on the ESP32. No issues on the Mega and I have interchanged many times so are fairly sure the sensors are fine. I have some evidence that any sensor attached to the ESP32 reads about 0.5 degree C higher than on the ATMega, but as I write this for the first time in a couple of days they all match so this may not be an issue and more related to environment.
Below is the code I have used (from a ESP32 example, but have tried other versions). I have tried multiple libraries sourced from different places but with no success and always the same behavior. I did read that the sensor is better run on 5V so have used a level shifter to allow it to connect to the ESP32. The behavior is just the same as when it is run from the ESP32 3.3V supply.
Code: Select all
//here we use pin IO14 of ESP32 to read data
#define DHTPIN 14
//our sensor is DHT22 type
#define DHTTYPE DHT22
//create an instance of DHT sensor
DHT dht(DHTPIN, DHTTYPE,100);
void setup() {
Serial.begin(115200);
Serial.println("DHT22 sensor!");
//call begin to start sensor
dht.begin();
}
void loop() {
//we delay a little bit for next read
delay(2500);
//use the functions which are supplied by library.
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
// print the result to Terminal
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
}
Example of output change when breathing on the sensor connected to the ESP32. The other 2 (sitting next to this one) continue to read fine. Often going to 100% humidity or near.
Received:
2, 3A, 0, B7, F3 =? F3
Humidity: 57.00 % Temperature: 18.30 *C
Received:
3, 67, 0, B7, A1 =? 21
Checksum failure!
Failed to read from DHT sensor!
Received:
3, 67, 0, BA, A4 =? 24
Checksum failure!
Failed to read from DHT sensor!
The readings normally stop failing within 2-10 minutes. I did experience another type of fault with the debugging turned on once:
Timeout waiting for start signal low pulse.
Failed to read from DHT sensor!
I am fairly green at coding so would be very grateful for any advice.
Regards Blair