Devices & Components
Arduino Uno Rev3
Breadboard (generic)
DHT11 Temperature & Humidity Sensor (4 pins)
Rotary potentiometer (generic)
Standard LCD - 16x2 White on Blue
Jumper wires (generic)
USB-A to B Cable
Software & Tools
Arduino IDE
Project description
Code
t
arduino
1/* 2 3 4 The circuit: 5 * LCD RS pin to digital pin 7 6 * LCD Enable pin to digital pin 8 7 * LCD D4 pin to digital pin 9 8 * LCD D5 pin to digital pin 10 9 * LCD D6 pin to digital pin 11 10 * LCD D7 pin to digital pin 12 11 * LCD R/W pin to ground 12 * LCD VSS pin to ground 13 * LCD VCC pin to 5V 14 * 10K resistor: 15 * ends to +5V and ground 16 * wiper to LCD VO pin (pin 3) 17 18 19 20// include the library code: 21#include <LiquidCrystal.h> 22#include <SimpleDHT.h> 23 24int pinDHT11 = 2; 25SimpleDHT11 dht11; 26 27// initialize the library with the numbers of the interface pins 28LiquidCrystal lcd(7, 8, 9, 10, 11, 12 ); 29 30void setup() { 31 // set up the LCD's number of columns and rows: 32 lcd.begin(16, 2); 33 // Print a message to the LCD. 34 //lcd.print("hello, world!"); 35} 36 37void loop() { 38 // set the cursor to column 0, line 1 39 // (note: line 1 is the second row, since counting begins with 0): 40 lcd.setCursor(0, 1); 41 // print the number of seconds since reset: 42 //lcd.print(millis() / 1000); 43 lcd.print("Sample DHT11..."); 44 lcd.clear(); 45 // read with raw sample data. 46 byte temperature = 0; 47 byte humidity = 0; 48 byte data[40] = {0}; 49 if (dht11.read(pinDHT11, &temperature, &humidity, data)) { 50 lcd.print("Read DHT11 failed"); 51 delay(1000); 52 lcd.clear(); 53 return; 54 } 55 //lcd.print("Sample OK: "); 56 lcd.print("TEMP = "); lcd.print((int)temperature); lcd.print(" *C"); 57 lcd.setCursor(0,2); 58 lcd.print("HUMD = "); lcd.print((int)humidity); lcd.print(" % "); 59 60 // DHT11 sampling rate is 1HZ. 61 delay(1000); 62 63 64} 65
t
arduino
1/* 2 3 4 The circuit: 5 * LCD RS pin to digital pin 7 6 * LCD 7 Enable pin to digital pin 8 8 * LCD D4 pin to digital pin 9 9 * LCD D5 pin to 10 digital pin 10 11 * LCD D6 pin to digital pin 11 12 * LCD D7 pin to digital pin 13 12 14 * LCD R/W pin to ground 15 * LCD VSS pin to ground 16 * LCD VCC pin to 17 5V 18 * 10K resistor: 19 * ends to +5V and ground 20 * wiper to LCD VO pin (pin 21 3) 22 23 24 25// include the library code: 26#include <LiquidCrystal.h> 27#include 28 <SimpleDHT.h> 29 30int pinDHT11 = 2; 31SimpleDHT11 dht11; 32 33// initialize 34 the library with the numbers of the interface pins 35LiquidCrystal lcd(7, 8, 9, 36 10, 11, 12 ); 37 38void setup() { 39 // set up the LCD's number of columns and 40 rows: 41 lcd.begin(16, 2); 42 // Print a message to the LCD. 43 //lcd.print("hello, 44 world!"); 45} 46 47void loop() { 48 // set the cursor to column 0, line 1 49 50 // (note: line 1 is the second row, since counting begins with 0): 51 lcd.setCursor(0, 52 1); 53 // print the number of seconds since reset: 54 //lcd.print(millis() / 55 1000); 56 lcd.print("Sample DHT11..."); 57 lcd.clear(); 58 // read with 59 raw sample data. 60 byte temperature = 0; 61 byte humidity = 0; 62 byte data[40] 63 = {0}; 64 if (dht11.read(pinDHT11, &temperature, &humidity, data)) { 65 lcd.print("Read 66 DHT11 failed"); 67 delay(1000); 68 lcd.clear(); 69 return; 70 } 71 72 //lcd.print("Sample OK: "); 73 lcd.print("TEMP = "); lcd.print((int)temperature); 74 lcd.print(" *C"); 75 lcd.setCursor(0,2); 76 lcd.print("HUMD = "); lcd.print((int)humidity); 77 lcd.print(" % "); 78 79 // DHT11 sampling rate is 1HZ. 80 delay(1000); 81 82 83 84} 85
Downloadable files
The schematic
This will help you to connect all the parts together as it wasn't obvious what went where in the cover picture.
The schematic

Comments
Only logged in users can leave comments