DHT11 with LCD on Arduino Uno

I hacked this DHT11 together today to show the outside temp/humidity. I normally test output to the Serial port but this time I did LCD and serial.  The clear case is a case from Maker Shed. Eventually all this will fit inside the box but until I’m satisfied I’m gonna let it hang…

Below is the code. I added the Dew Point in F.


// include the library code:
#include <LiquidCrystal.h>
#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 6
double DPC;

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 2, 3, 5, 4);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);

Serial.println(“DHT11 TEST PROGRAM “);
Serial.print(“LIBRARY VERSION: “);

void loop() {

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;

Serial.print(“Humidity (%): “);
Serial.println((float)DHT11.humidity, DEC);

Serial.print(“Temperature ( C): “);
Serial.println((float)DHT11.temperature, DEC);

Serial.print(“Temperature ( F): “);
Serial.println(DHT11.fahrenheit(), DEC);

lcd.setCursor(0, 0);
lcd.print(DHT11.humidity, DEC);
lcd.print(” F:”);

lcd.setCursor(0, 1);
DPC= DHT11.dewPoint();

Serial.print(“Dew Point ( F): “);
Serial.println((DPC * 1.8) + 32);
lcd.print(“DP(F): “);
//lcd.print((1.8 * (DHT11.dewPoint(), DEC) + 32));
lcd.print((DPC * 1.8) + 32);

Serial.print(“Dew Point ( C): “);
Serial.println(DHT11.dewPoint(), DEC);

Serial.print(“Dew PointFast ( C): “);
Serial.println(DHT11.dewPointFast(), DEC);



void printDouble( double val, unsigned int precision){
// prints val with number of decimal places determine by precision
// NOTE: precision is 1 followed by the number of zeros for the desired number of decimial places
// example: printDouble( 3.1415, 100); // prints 3.14 (two decimal places)

Serial.print (int(val)); //prints the int part
Serial.print(“.”); // print the decimal point
unsigned int frac;
if(val >= 0)
frac = (val – int(val)) * precision;
frac = (int(val)- val ) * precision;

Serial.println(frac,DEC) ;
lcd.print(frac,DEC) ;

0 thoughts on “DHT11 with LCD on Arduino Uno

  1. I’m using PaleMoon (i.e. Firefox) and your sketch includes some HTML lines etc.

    Otherwise looks good, now if I can just get it working….

Leave a Reply

Your email address will not be published. Required fields are marked *