Greetings everybody. I have a problem displaying temp although loading example sketch from LiquidCrystal library is fine.
I'm trying to display my sensors in this manner;
CO : _ _ _ _ | T(temp) : _ _ Degree(can the lcd display degree symbol?)
02: _ _ _ _ | H(humidity) : _ _ percentage (can the lcd display degree symbol?)
hence i started off with trying to load temperature. however i can't view the temp.
I'm using sainsmart 20x04 lcd display module.
where did i go wrong?
/*-----( Import needed libraries )-----*/
#include <dht.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
dht DHT;
/*-----( Declare Constants, Pin Numbers )-----*/
#define DHT11_PIN 2
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600); //(Remove all 'Serial' commands if not needed)
lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight
lcd.backlight();
// Print a message to the LCD.
lcd.setCursor(0, 1);
lcd.print("DHT11 Temp/Humid");
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
// READ DATA
Serial.print("DHT11, \t");
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
case DHTLIB_ERROR_CONNECT:
Serial.print("Connect error,\t");
break;
case DHTLIB_ERROR_ACK_L:
Serial.print("Ack Low error,\t");
break;
case DHTLIB_ERROR_ACK_H:
Serial.print("Ack High error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
lcd.setCursor(0,2);
lcd.print((float)DHT.humidity, 0);
lcd.print("%");
delay(2000);
}/* --(end main loop )-- */