I'm working on a small demo project for a College where I work and have run into a problem in the transition from breadboard to soldered up project. I'm using the Adafruit clear enclosure, the RGB LCD, the logger shield, and a Diavolino and I have checked the components individually and they are working.
When I hook things up, the LCD works great except for a flicker of the backlight every time through the processing loop and
I get a time-out with the DHT-11.
In case it helps, I've attached shots of this project. DHt-11 pin 1 is to 3.3v; DHT pin 2 goes to the logger shield pin 2; and pin 4 goes to ground.
Any ideas?
Data Logger shield and DHT-11
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- alaxsxaq
- Posts: 7
- Joined: Wed Oct 12, 2011 10:48 am
Data Logger shield and DHT-11
- Attachments
-
- DSC_7939.jpg (72.15 KiB) Viewed 3475 times
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: Data Logger shield and DHT-11
Just to make sure, it looks like you have a pullup between the data pin and 3.3v. Is that 10K?
Can you post the code you are using?
Can you post the code you are using?
- alaxsxaq
- Posts: 7
- Joined: Wed Oct 12, 2011 10:48 am
Re: Data Logger shield and DHT-11
Yes, that is a 10k resistor. The schematics I've seen for using the DHT11 said to use a 10k resistor like that. I did test the DHT11 at 3.3v on a breadboard and got relatively accurate temperature readings - not sure about the humidity, but the readings were very close to the readings at 5v.
I'm using the 5v connection on the data logger board to power a LGB LCD display (thanks, btw, for the quick replacement of the defective board).
Here is the code:
[Edit - moderator - use code block]
I'm using the 5v connection on the data logger board to power a LGB LCD display (thanks, btw, for the quick replacement of the defective board).
Here is the code:
[Edit - moderator - use code block]
Code: Select all
/* YourDuino.com Example Software Sketch
DHT11 Humidity and Temperature Sensor test
Displayed on I2C LCD Display
Credits: Rob Tillaart
http://arduino-info.wikispaces.com/PROJECT-Temp-Humidity-Display
[email protected] */
/*-----( Import needed libraries )-----*/
#include <dht11.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#define REDLITE 3
#define GREENLITE 5
#define BLUELITE 6
/*-----( Declare objects )-----*/
LiquidCrystal lcd(7,8,9,10,11,12); // set the LCD address to 0x27
dht11 DHT11;
int brightness = 255;
/*-----( Declare Constants, Pin Numbers )-----*/
#define DHT11PIN 2
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600); //(Remove all 'Serial' commands if not needed)
lcd.begin(16,2); // initialize the lcd
// Print a message to the LCD.
//lcd.setCursor(0, 1);
lcd.print(" Temp/Humidity");
setBacklight(0,255,0);
brightness = 100;
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
int chk = DHT11.read(DHT11PIN);
Serial.print("Read sensor: ");
switch (chk)
{
case 0: Serial.println("OK"); break;
case -1: Serial.println("Checksum error"); break;
case -2: Serial.println("Time out error"); break;
default: Serial.println("Unknown error"); break;
}
lcd.setCursor(0, 1);
lcd.print(" C=");
lcd.print((float)DHT11.temperature, 0);
Serial.print("Temperature (oC): ");
Serial.println((float)DHT11.temperature, 2);
lcd.print(" F=");
lcd.print(Fahrenheit(DHT11.temperature), 0);
Serial.print("Temperature (oF): ");
Serial.println(Fahrenheit(DHT11.temperature), 2);
lcd.print(" H=");
lcd.print((float)DHT11.humidity, 0);
lcd.print("%");
Serial.print("Humidity (%): ");
Serial.println((float)DHT11.humidity, 2);
Serial.print("Temperature (K): ");
Serial.println(Kelvin(DHT11.temperature), 2);
Serial.print("Dew Point (oC): ");
Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));
Serial.print("Dew PointFast (oC): ");
Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));
delay(2000);
}/* --(end main loop )-- */
/*-----( Declare User-written Functions )-----*/
//
//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
}
//Celsius to Kelvin conversion
double Kelvin(double celsius)
{
return celsius + 273.15;
}
// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558-T);
}
// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a - temp);
return Td;
}
void setBacklight(uint8_t r, uint8_t g, uint8_t b) {
r = map(r, 0, 255, 0, 100);
g = map(g, 0, 255, 0, 150);
r = map(r, 0, 255, 0, brightness);
g = map(g, 0, 255, 0, brightness);
b = map(b, 0, 255, 0, brightness);
r = map(r, 0, 255, 255, 0);
g = map(g, 0, 255, 255, 0);
b = map(b, 0, 255, 255, 0);
Serial.print("R = "); Serial.print(r, DEC);
Serial.print(" G = "); Serial.print(g, DEC);
Serial.print(" B = "); Serial.print(b, DEC);
analogWrite(REDLITE, r);
analogWrite(GREENLITE, g);
analogWrite(BLUELITE, b);
}
/* ( THE END ) */
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: Data Logger shield and DHT-11
Have you tried the Adafruit library and example code for the DHT sensors?
Your sketch does not define DHTTYPE or call dht.begin() as in the example.
Your sketch does not define DHTTYPE or call dht.begin() as in the example.
Code: Select all
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// 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
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
}
- alaxsxaq
- Posts: 7
- Joined: Wed Oct 12, 2011 10:48 am
Re: Data Logger shield and DHT-11
I tried the example code and I'm still getting a failure to read from DHT error:
Read failFailed to read from DHT
Humidity: 0.00 % Temperature: 0.00 *C
Humidity: 0.00 % Temperature: 0.00 *C
Humidity: 0.00 % Temperature: 0.00 *C
- alaxsxaq
- Posts: 7
- Joined: Wed Oct 12, 2011 10:48 am
Re: Data Logger shield and DHT-11
Just to follow-up on this. I checked the data logger shield and DHT11 using an Arduino Uno and I still cannot get a reading from the DHT11 - same failure as I see with the Diavolino I'm using for my project.
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: Data Logger shield and DHT-11
Are you sure you have the right sensor? All the DHT-11's I've seen are blue. From what I can see, yours looks more like a DHT-22.
- alaxsxaq
- Posts: 7
- Joined: Wed Oct 12, 2011 10:48 am
Re: Data Logger shield and DHT-11
Sorry for the confusion. The white thing you see there is a 4-pin connector from a laser printer that I am using to relocate the DHT11 external to the adafruit clear enclosure that I am using for this project. I would suspect the connector, but tested it on a breadboard after desoldering it from an old HP laser printer that I stripped for parts. I have also tested the DHT11 after soldering the connector wires to it - those wires are about 1 foot in length.
Since I may just have to desolder everything and start over, I do have a few questions that you might be able to help answer. Is it OK to use the 3v connection that I'm using for the DHT11? Does the general layout of the wiring look OK? And should I be using the 10k ohm resistor that I'm using or something else?
I just want to make sure that it isn't my wiring that is messed up and I don't end up re-doing everything and end up right where I am now.
To complete this project, I have two 2xAAA battery cases to add as well as an on-off switch. There is one other thing I am thinking about and that is to add another switch - either a momentary button or a toggle - to control the LCD display, so it isn't constantly drawing current from the batteries.
Since I may just have to desolder everything and start over, I do have a few questions that you might be able to help answer. Is it OK to use the 3v connection that I'm using for the DHT11? Does the general layout of the wiring look OK? And should I be using the 10k ohm resistor that I'm using or something else?
I just want to make sure that it isn't my wiring that is messed up and I don't end up re-doing everything and end up right where I am now.
To complete this project, I have two 2xAAA battery cases to add as well as an on-off switch. There is one other thing I am thinking about and that is to add another switch - either a momentary button or a toggle - to control the LCD display, so it isn't constantly drawing current from the batteries.
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: Data Logger shield and DHT-11
From what I can see, the wiring looks alright. 3.3v should work, but the data sheet indicates that it is designed for 5v. (min: 3.3v, typ: 5v, max: 5.5v)
The long leads could be picking up noise too. You might consider twisted-pair or shielded wiring.
The long leads could be picking up noise too. You might consider twisted-pair or shielded wiring.
Please be positive and constructive with your questions and comments.