-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode file
More file actions
51 lines (41 loc) · 920 Bytes
/
Code file
File metadata and controls
51 lines (41 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
lcd.init();
lcd.backlight();
// you can now interact with the LCD, e.g.:
lcd.println(F("DHTxx test!"));
dht.begin();
Serial.begin(9600);
}
void loop() {
delay(2000);
lcd.clear();
float h = dht.readHumidity();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(f)) {
lcd.println(F("Failed to read from DHT sensor!"));
return;
}
lcd.setCursor(0,1);
lcd.print("humid: ");
lcd.print(h);
lcd.print("%");
lcd.setCursor(0,0);
lcd.print("temp: ");
lcd.print(f);
lcd.write(223);
lcd.print("F");
serupdate(h,f);
}
void serupdate(float h, float f){
Serial.println(f);
Serial.println(h);
}