Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DHT.h" // dodamo knjižnjico za DHT
- #define DHTPIN D7 // ker pin je Data Pin -> kjer bomo prejemal podatke
- #define DHTTYPE DHT11 // nš DHT je tip 11 (maš še 22, 21)
- DHT dht(DHTPIN, DHTTYPE); // inicialzacija DHTja
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(115200);
- dht.begin();
- }
- void loop() {
- float h = dht.readHumidity();
- // Read temperature as Celsius (the default)
- float t = dht.readTemperature();
- if (isnan(h) || isnan(t)) {
- // če Humidity al pa Temperatura nista številki potem neki ni blo vredu in gremo v tole metodo
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- // Izpišemo Humidity in Temperaturo
- Serial.print("Humidity: ");
- Serial.print(h);
- Serial.print(" %\t");
- Serial.print("Temperature: ");
- Serial.print(t);
- Serial.print(" *C ");
- Serial.println();
- delay(1000); // počakamo 1s do naslednjega zajema podatkov
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement