Advertisement
ossipee

2DHT22

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