Grove DHT20 not working when following wiki

Hi there,

I have the Grove DHT20, I’m following the tutorial on connecting it to the seeeduino v4.2 (https://wiki.seeedstudio.com/Grove-Temperature-Humidity-Sensor-DH20/). I’ve followed it exactly, but when I use the serial monitor I see something like this

image

where it keeps printing out garbage. Sometimes it will print out normally, but will quickly go back to just printing out garbage. Here is the code I’m using

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "Wire.h"
#include "DHT.h"
#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.*/
DHT dht(DHTTYPE);         //   DHT10 DHT20 don't need to define Pin
 
#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);
}

thank you!

update: it seems to start printing out random characters after I first view the serial monitor. I let it run for a bit before viewing it and this was the output

image

This may be a small bug in the serial port transmission. Generally, this situation may be that the transmission speed of the serial port needs to be adjusted. You can try to change 115200 to 9600. Don’t forget to modify the serial monitor too.