Seeediuno 4.3 and DTH22

I connected Grove DTH22 sensor to Seeeduino 4.3 using a 12c connector, and got the message “Failed to get temeprature and humidity value.” It was because both RH and temperature were zero. How can I fix the issue? Thanks!

Hi there,
So can you use the code tags and post the code you are attempting to use unsuccessfully ?
Lots of smart folks here to help, give more info!
HTH
GL :slight_smile: PJ

I used the default code, which showed up after I added the library.
// Example testing sketch for various DHT humidity/temperature sensors

// Written by ladyada, public domain

#include “Grove_Temperature_And_Humidity_Sensor.h”

// Uncomment whatever type you’re using!

//#define DHTTYPE DHT11 // DHT 11

#define DHTTYPE DHT22 // DHT 22 (AM2302)

//#define DHTTYPE DHT21 // DHT 21 (AM2301)

//#define DHTTYPE DHT10 // DHT 10

//#define DHTTYPE DHT20 // DHT 20

/Notice: The DHT10 and DHT20 is different from other DHT sensor ,it uses i2c interface rather than one wire*/

/So it doesn’t require a pin./

#define DHTPIN 2 // what pin we’re connected to(DHT10 and DHT20 don’t need define it)

DHT dht(DHTPIN, DHTTYPE); // DHT11 DHT21 DHT22

//DHT dht(DHTTYPE); // DHT10 DHT20 don’t need to define Pin

// Connect pin 1 (on the left) of the sensor to +5V

// Connect pin 2 of the sensor to whatever your DHTPIN is

// Connect pin 4 (on the right) of the sensor to GROUND

// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

#if defined(ARDUINO_ARCH_AVR)

#define debug  Serial

#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)

#define debug  SerialUSB

#else

#define debug  Serial

#endif

void setup() {

debug.begin(115200);

debug.println("DHTxx test!");

Wire.begin();

/*if using WIO link,must pull up the power pin.*/

// pinMode(PIN_GROVE_POWER, OUTPUT);

// digitalWrite(PIN_GROVE_POWER, 1);

dht.begin();

}

void loop() {

float temp_hum_val[2] = {0};

// Reading temperature or humidity takes about 250 milliseconds!

// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

if (!dht.readTempAndHumidity(temp_hum_val)) {

    debug.print("Humidity: ");

    debug.print(temp_hum_val[0]);

    debug.print(" %\t");

    debug.print("Temperature: ");

    debug.print(temp_hum_val[1]);

    debug.println(" *C");

} else {

    debug.println("Failed to get temprature and humidity value.");

}

delay(1500);

}
Sean

Hi @seii
The DHT22 doesn’t use an I2C interface, it uses a digital interface. Please try the digital interface and change your choice of digital interface in the code. Like the wiki.


image

Hi @Seeed_Seraphina,

Where do you see that the DTH22 doesn’t use i2c? On its page in the Seeed store it lists i2c as its output signal (see table under Product Details near top of page).

I would like to get it to work over i2c too but so far, my results are consistent with “no i2c”. As you suggested, I am able to get it to work off a data pin like D2 or D4. The Adafruit library (Grove_Temperature_And_Humidity_Sensor.h) that the the OP references also doesn’t appear to use i2c. So I’m wondering if the product page is wrong. Several companies package the DHT22 sensor on their own PCB and whether or not i2c is supported is a function of the PCB itself, not the chip. Since Seeed lists i2c on the Grove implementation of this sensor and PCB, I assumed it was supported.

thanks…

This error can occur due to couple of reasons. such as-wrong I2C address, faulty connection, bad jumper wires, or a bad module itself. You can check your code with an Arduino UNO/NANO by a simple test code. If the sensor fails in other platforms too, maybe you got a bad sensor.

Here are some examples: