Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. [code]
  2.  
  3. #define BLYNK_PRINT Serial
  4.  
  5.  
  6. #include <ESP8266WiFi.h>
  7. #include <BlynkSimpleEsp8266.h>
  8. #include <DHT.h>
  9. #include <DHT_U.h>
  10.  
  11. char auth[] = "90591c5251634b68a8eb964c322b3423";
  12.  
  13. char ssid[] = "Remik";
  14. char pass[] = "19740726";
  15.  
  16. #define DHTPIN D5
  17. #define DHTTYPE DHT22
  18.  
  19.  
  20. DHT dht(DHTPIN, DHTTYPE);
  21. BlynkTimer timer;
  22.  
  23. // This function sends Arduino's up time every second to Virtual Pin (5).
  24. // In the app, Widget's reading frequency should be set to PUSH. This means
  25. // that you define how often to send data to Blynk App.
  26. void sendSensor()
  27. {
  28. float h = dht.readHumidity();
  29. float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  30.  
  31.  
  32. if (isnan(h) || isnan(t)) {
  33. Serial.println("Failed to read from DHT sensor!");
  34. return;
  35.  
  36. }
  37.  
  38. // You can send any value at any time.
  39. // Please don't send more that 10 values per second.
  40. Blynk.virtualWrite(V5, h);
  41. Blynk.virtualWrite(V6, t);
  42. }
  43.  
  44. void setup()
  45. {
  46. // Debug console
  47. Serial.begin(9600);
  48.  
  49. Blynk.begin(auth, ssid, pass);
  50. // You can also specify server:
  51. //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  52. //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  53.  
  54. dht.begin();
  55.  
  56. // Setup a function to be called every second
  57. timer.setInterval(1000L, sendSensor);
  58. }
  59.  
  60. void loop()
  61. {
  62. Blynk.run();
  63. timer.run();
  64. }
  65.  
  66. [/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement