Skip to content

Instantly share code, notes, and snippets.

@georgebent
Last active March 15, 2019 22:27
Show Gist options
  • Save georgebent/671d0fab7f69abecd1c5c1f855854774 to your computer and use it in GitHub Desktop.
Save georgebent/671d0fab7f69abecd1c5c1f855854774 to your computer and use it in GitHub Desktop.
Arduino temperature humidity sensor
#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