DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.
Moderators: adafruit_support_bill, adafruit

DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.

by DennyP on Sat May 18, 2013 5:52 am

Hello There,

I'm currently using the library http://learn.adafruit.com/dht for my DHT22 and I'm using a Adrunio Uno.
Looking at the serial monitor, I'm not having any intellectual readings coming from it.

A sample:

"1ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Uˆ ˆ ¡ ¥1¡ !¡11ô ¥qñ;!¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1ó;
(%•ÿ ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨PˆüÊ õ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB¨Pˆ ˆ ¡ ¥1¡ !¡11ô ¥1¡ !¡11ô ¥1¡ !¡11ôB"

Both the Uno and the Sensor has the Pwr miniled on, and the Tx led flashing as it samples.

Would anybody know how to fix this?
Cheers,
Dennis
DennyP
 
Posts: 5
Joined: Sat May 18, 2013 5:41 am

Re: DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.

by adafruit_support_bill on Sat May 18, 2013 7:24 am

Looks like a baud-rate mismatch. Make sure that the baud rate setting of the serial monitor is the same as the baud-rate set in the sketch.
User avatar
adafruit_support_bill
 
Posts: 30083
Joined: Sat Feb 07, 2009 9:11 am

Re: DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.

by DennyP on Sat May 18, 2013 7:45 am

Hello adafruit_support_bill , Thank you for a prompt response.

The baud rate is set 9600 at serial monitor.

I wouldn't have a clue about the baud rate in the sketch, but maybe you can identify it, the sketch is as follows:

`// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2 // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(38400);
Serial.println("DHT test");

dht.begin();
}

void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();

// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}
}
DennyP
 
Posts: 5
Joined: Sat May 18, 2013 5:41 am

Re: DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.

by adafruit_support_bill on Sat May 18, 2013 7:54 am

The sketch is using 38400

It is specified in the Serial.begin statement:

Code: Select all | TOGGLE FULL SIZE
void setup() {
Serial.begin(38400);
Serial.println("DHT test");

dht.begin();
}
User avatar
adafruit_support_bill
 
Posts: 30083
Joined: Sat Feb 07, 2009 9:11 am

Re: DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.

by DennyP on Sat May 18, 2013 8:01 am

Worked a Charm!! Thank you so much!!

Out of curiosity and for the benefit of the people who are reading this post and don't know, what is the Baud rate
specifically?
DennyP
 
Posts: 5
Joined: Sat May 18, 2013 5:41 am

Re: DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.

by adafruit_support_bill on Sat May 18, 2013 8:26 am

baud rate is the rate at which individual bits are sent over the wire for serial communication. Typically, for each character transmitted, there are 8 data bits and one "stop bit". As a rough rule of thumb, the number of characters transmitted per second is about 1/10th the baud rate.
User avatar
adafruit_support_bill
 
Posts: 30083
Joined: Sat Feb 07, 2009 9:11 am

Re: DHT22 Temperature/Humidity spitting out gibberish using the ladyada DHT22 Library.

by DennyP on Sat May 25, 2013 8:19 am

Thank you heaps:)
DennyP
 
Posts: 5
Joined: Sat May 18, 2013 5:41 am