Last active
March 15, 2019 22:27
-
-
Save georgebent/671d0fab7f69abecd1c5c1f855854774 to your computer and use it in GitHub Desktop.
Arduino temperature humidity sensor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "DHT.h" | |
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
#define DHTPIN 4 | |
LiquidCrystal_I2C lcd(0x3F, 16, 2); | |
DHT dht(DHTPIN, DHT11); | |
void setup() { | |
Serial.begin(9600); | |
dht.begin(); | |
lcd.init(); | |
lcd.backlight(); | |
} | |
void loop() { | |
delay(2000); | |
float h = dht.readHumidity(); | |
float t = dht.readTemperature(); | |
if (isnan(h) || isnan(t)) { | |
return; | |
} | |
lcd.setCursor(0,0); | |
lcd.print((String) "Temp: " + t + "C"); | |
lcd.setCursor(0,1); | |
lcd.print((String) "Hum: " + h + "%"); | |
Serial.print((String) "Вологість: " + h + "\n" + "Температура: " + t + " *C \n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment