Advertisement
ossipee

CloserDHT22

Aug 8th, 2014
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "DHT.h"  //includes lib for the humdity sensor
  2. #include <LiquidCrystal.h> //lcd lib
  3.  
  4. #define DHTPIN 2 //pin that DHT is connected to
  5. #define DHTPIN 3 //pin that second DHT is connected to
  6. #define DHTTYPE DHT22 //Sensor we are using
  7. #define DHTTYPE3 DHT22 // Second sensor we are using
  8.  
  9. DHT dht(DHTPIN, DHTTYPE); //defines location for DHT
  10. DHT dht3(DHTPIN, DHTTYPE); //defines location for second DHT
  11.  
  12. LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  13.  
  14. void setup() {
  15.   // set up the LCD's number of rows and columns:
  16.   lcd.begin(16, 2);
  17.  
  18.  }
  19.  
  20.  
  21. void loop() {
  22.   float h = dht.readHumidity(); //defines the variable for humidity
  23.   float t = dht.readTemperature(); //defines the variable for temperature
  24.   float f = (t * 9.0)/5.0 + 32.0;
  25.   // set the cursor to column 0, line 0
  26.   lcd.setCursor(0,0);
  27.   // print the humidity
  28.   lcd.print("Humidity ");
  29.   lcd.print(h);
  30.   lcd.print(" % ");
  31.   //move line down
  32.   lcd.setCursor(0,1);
  33.   lcd.print("Temp ");
  34.   lcd.print(f);
  35.   lcd.print(" *F");
  36.  
  37.   delay(2000); //wait two sec. before taking another reading.
  38.  
  39.   float h3 = dht3.readHumidity(); //defines the variable for humidity
  40.   float t3 = dht3.readTemperature(); //defines the variable for temperature
  41.   float f3 = (t3 * 9.0)/5.0 + 32.0;
  42.   // set the cursor to column 0, line 0
  43.   lcd.setCursor(0,0);
  44.   // print the humidity
  45.   lcd.print("Humidity ");
  46.   lcd.print(h3);
  47.   lcd.print(" % ");
  48.   //move line down
  49.   lcd.setCursor(0,1);
  50.   lcd.print("Temp ");
  51.   lcd.print(f3);
  52.   lcd.print(" *F");
  53.  
  54.   delay(2000); //wait two sec. before taking another reading.
  55.  
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement