//pembuat program: Dian Ramadhan & Muhammad Iqbal Fauzi
//NIM : 20210130152 & 20200130050
#include "DHT.h" // Library untuk sensor DHT
#define dhtPin 12 // data pin
//#define dhtType DHT11 // tipe sensor: DHT 11
#define dhtType DHT22 // DHT 22 (AM2302), AM2321
//#define dhtType DHT21 // DHT 21 (AM2301)
DHT dht(dhtPin, dhtType); // Initialise the DHT library
float humidityVal; // humidity %
float tempValC; // temperature in degrees Celcius
void setup() {
Serial.begin(9600); // Initialise the serial monitor
dht.begin(); // start with reading the DHT sensor
}
void loop() {
humidityVal = dht.readHumidity(); // humidity
tempValC = dht.readTemperature(); // temperatur Celcius
// Print all values to the serial monitor, \t prints a tab character
Serial.print("Humidity: ");
Serial.print(humidityVal);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(tempValC);
Serial.println(" °C ");
delay(2000);
}