Hi all.
I know that this has cropped up many times before, no matter what i do i cannot get rid of the error, i have tried many of the so called DHT22 libraries, but to no avail, i am assuming that this is a library problem, can any one help me solve this error?
//Sketch for Atmosphere Controlled Guitar Cabinet
#include <Wire.h>
#include <LCD.h>
#define DHT1PIN 4 // what pin we're connected to
#define DHT2PIN 5
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN,DHTTYPE);
#define I2C_ADDR 0x27 //ALWAYS USE THIS WITH LCD I2C and Address 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature();
float h2 = dht2.readHumidity();
float t2 = dht2.readTemperature();
void setup()
{
Serial.begin(9600);
Serial.println("DHTxx test!");
lcd.begin(20,4);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
dht1.begin();
dht2.begin();
}
void loop()
{
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t1) || isnan(h1)) {
Serial.println("Failed to read from DHT #1");
} else {
Serial.print("Humidity 1: ");
Serial.print(h1);
Serial.print(" %\t");
Serial.print("Temperature 1: ");
Serial.print(t1);
Serial.println(" *C");
}
if (isnan(t2) || isnan(h2)) {
Serial.println("Failed to read from DHT #2");
} else {
Serial.print("Humidity 2: ");
Serial.print(h2);
Serial.print(" %\t");
Serial.print("Temperature 2: ");
Serial.print(t2);
Serial.println(" *C");
}
Serial.println();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Room Temp : ");
lcd.print(temp);
lcd.print(" ");
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Room Hum : ");
lcd.print(hum);
lcd.print(" %");
lcd.setCursor(0,2);
lcd.print("Cab Temp : ");
lcd.print(temp);
lcd.print(" ");
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,3);
lcd.print("Cab Hum : ");
lcd.print(hum);
lcd.print(" %");
delay (2000);
}