Home Chipkit Chipkit Uno and DHT11 readings on an LCD

Chipkit Uno and DHT11 readings on an LCD

by shedboy71

In a previous example we connected a DHt11 sensor and outputted the results via the serial connection, this is reasonable enough for testing purposes but a more practical example would be to display this information on an LCD display for example.

In this example we will display the temperature and humidity on a 16×2 LCD, in fact its a common Arduino shield called the LCD Keypad shield.

You will need the following parts

1 x Chipkit Uno
1 x LCD keypad shield (Arduino) – link below
1 x DHt11 sensor module – link below, you could use individual components but the module is easier
Some connecting cables (3)

Code

Code uses the same DHT11 library and the LiquidCrystal library, the code is also configured for the LCD keypad shield I have at hand, you may have a different one although most are based on commonly found open source schematics and board layouts

[codesyntax lang=”cpp”]

#include <LiquidCrystal.h>
#include "dht11.h" 
  
//define data pin
#define DHT11PIN 3 
dht11 DHT11; 

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 
void setup() 
{
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Temp : ");
  lcd.setCursor(0, 1);
  lcd.print("Humi : ");
}
 
void loop() 
{
  int chk = DHT11.read(DHT11PIN); 
  // set the cursor to column 0, line 1
  lcd.setCursor(7, 0);
  // print the number of seconds
  lcd.print(DHT11.temperature); 
  lcd.setCursor(7, 1);
  lcd.print(DHT11.humidity); 
  delay(2000); 
}

[/codesyntax]

 

Links

Temperature Humidity Sensor DHT11 Module for Arduino – Deep Blue (Works with Official Arduino Board) – $2.34

LCD Keypad Shield for Arduino Duemilanove & LCD 1602 (Works with Official Arduino Boards) – $5.99

Share

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More