Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include "DHT.h" // dodamo knjižnjico za DHT
  2.  
  3. #define DHTPIN D7 // ker pin je Data Pin -> kjer bomo prejemal podatke
  4. #define DHTTYPE DHT11 // nš DHT je tip 11 (maš še 22, 21)
  5. DHT dht(DHTPIN, DHTTYPE); // inicialzacija DHTja
  6.  
  7. void setup() {
  8. // put your setup code here, to run once:
  9. Serial.begin(115200);
  10. dht.begin();
  11. }
  12.  
  13. void loop() {
  14. float h = dht.readHumidity();
  15. // Read temperature as Celsius (the default)
  16. float t = dht.readTemperature();
  17.  
  18. if (isnan(h) || isnan(t)) {
  19. // če Humidity al pa Temperatura nista številki potem neki ni blo vredu in gremo v tole metodo
  20. Serial.println("Failed to read from DHT sensor!");
  21. return;
  22. }
  23.  
  24. // Izpišemo Humidity in Temperaturo
  25. Serial.print("Humidity: ");
  26. Serial.print(h);
  27. Serial.print(" %\t");
  28. Serial.print("Temperature: ");
  29. Serial.print(t);
  30. Serial.print(" *C ");
  31. Serial.println();
  32. delay(1000); // počakamo 1s do naslednjega zajema podatkov
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement