//Nama : Rohmat Nugroho
//No absen :
//Kelas :
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht22(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
dht22.begin();
}
void loop() {
// put your main code here, to run repeatedly:
float suhu = dht22.readTemperature();
float lembab = dht22.readHumidity();
if (isnan(suhu) || isnan(lembab)) {
Serial.print("Gagal membaca sensor DHT22!!");
return;
}
Serial.print("Suhu : ");
Serial.print(suhu);
Serial.print(" °C | Kelembapan : ");
Serial.print(lembab);
Serial.println(" % ");
delay(2000);
}