Siklosi_Csapda

Untitled

Dec 12th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. /*************************************************************
  2. Download latest Blynk library here:
  3. https://github.com/blynkkk/blynk-library/releases/latest
  4.  
  5. Blynk is a platform with iOS and Android apps to control
  6. Arduino, Raspberry Pi and the likes over the Internet.
  7. You can easily build graphic interfaces for all your
  8. projects by simply dragging and dropping widgets.
  9.  
  10. Downloads, docs, tutorials: http://www.blynk.cc
  11. Sketch generator: http://examples.blynk.cc
  12. Blynk community: http://community.blynk.cc
  13. Follow us: http://www.fb.com/blynkapp
  14. http://twitter.com/blynk_app
  15.  
  16. Blynk library is licensed under MIT license
  17. This example code is in public domain.
  18.  
  19. *************************************************************
  20.  
  21. This example shows how value can be pushed from Arduino to
  22. the Blynk App.
  23.  
  24. WARNING :
  25. For this example you'll need Adafruit DHT sensor libraries:
  26. https://github.com/adafruit/Adafruit_Sensor
  27. https://github.com/adafruit/DHT-sensor-library
  28.  
  29. App project setup:
  30. Value Display widget attached to V5
  31. Value Display widget attached to V6
  32. *************************************************************/
  33.  
  34. /* Comment this out to disable prints and save space */
  35. #define BLYNK_PRINT Serial
  36.  
  37.  
  38.  
  39. #include <ESP8266WiFi.h>
  40. #include <BlynkSimpleEsp8266.h>
  41. #include <DHT.h>
  42.  
  43.  
  44. // You should get Auth Token in the Blynk App.
  45. // Go to the Project Settings (nut icon).
  46. char auth[] = "db1c8b0eb5354042b03bafea955cbe06";
  47.  
  48. // Your WiFi credentials.
  49. // Set password to "" for open networks.
  50. char ssid[] = "DIGI-01061597";
  51. char pass[] = "PMzvSJDW";
  52.  
  53. // Ezzel a függvénnyel hívom meg a slidert, és veszem felk az
  54. // értéket a változóba
  55.  
  56.  
  57. BLYNK_WRITE(V1)
  58. {
  59. int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  60. // You can also use:
  61. // String i = param.asStr();
  62. // double d = param.asDouble();
  63. Serial.print("V1 Slider value is: ");
  64. Serial.println(pinValue);
  65. }
  66.  
  67. #define DHTPIN 2 // What digital pin we're connected to
  68.  
  69. // Uncomment whatever type you're using!
  70. #define DHTTYPE DHT11 // DHT 11
  71. //#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
  72. //#define DHTTYPE DHT21 // DHT 21, AM2301
  73.  
  74. DHT dht(DHTPIN, DHTTYPE);
  75. BlynkTimer timer;
  76.  
  77. // This function sends Arduino's up time every second to Virtual Pin (5).
  78. // In the app, Widget's reading frequency should be set to PUSH. This means
  79. // that you define how often to send data to Blynk App.
  80. void sendSensor()
  81. {
  82.  
  83. float h = dht.readHumidity();
  84. float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  85.  
  86. if (isnan(h) || isnan(t)) {
  87. Serial.println("Failed to read from DHT sensor!");
  88. return;
  89. }
  90. // You can send any value at any time.
  91. // Please don't send more that 10 values per second.
  92. Blynk.virtualWrite(V5, h);
  93. Blynk.virtualWrite(V6, t);
  94.  
  95. //termosztát funkció
  96. if (t>23){
  97. digitalWrite(D5,HIGH);
  98. }
  99. else {
  100. digitalWrite(D5, LOW);
  101. }
  102.  
  103. }
  104.  
  105.  
  106.  
  107.  
  108. void setup()
  109. {
  110. pinMode(D5, OUTPUT);
  111. // Debug console
  112. Serial.begin(9600);
  113.  
  114. Blynk.begin(auth, ssid, pass);
  115. // You can also specify server:
  116. //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  117. //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  118.  
  119. dht.begin();
  120.  
  121. // Setup a function to be called every second
  122. timer.setInterval(1000L, sendSensor);
  123. }
  124.  
  125. void loop()
  126. {
  127. Blynk.run();
  128. timer.run();
  129. }
Add Comment
Please, Sign In to add comment