Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. #include <IRrecv.h>
  2. #include <IRremoteESP8266.h>
  3. #include <IRsend.h>
  4. const uint16_t kIrLed = 14; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
  5. IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
  6.  
  7. #include <ESP8266mDNS.h>
  8. #include <WiFiUdp.h>
  9. #include <ESP8266WiFi.h>
  10. #include <BlynkSimpleEsp8266.h>
  11.  
  12. // SENZOR
  13. #define DHTPIN 12 // Temp sensor hardware pin on SD3/GPIO10
  14. #include "DHTesp.h"
  15. DHTesp dht;
  16. SimpleTimer timer;
  17.  
  18. #include <TimeLib.h>
  19. #include <WidgetRTC.h>
  20. WidgetRTC rtc;
  21.  
  22. String display_temp;
  23. String display_humid;
  24. String dispTempSet;
  25.  
  26. int tempset; // tempset value from pin V13
  27. int tempset2; // lower treshold for triggering the heating
  28. float nastavljena; // nastavljena temp iz sliderja
  29.  
  30. float h; //temperature value
  31. float t ; //humidity value
  32.  
  33. // You should get Auth Token in the Blynk App.
  34. // Go to the Project Settings (nut icon).
  35. char auth[] = "77c28c13f6f24a3393510bd12c321cee";
  36.  
  37. // Your WiFi credentials.
  38. // Set password to "" for open networks.
  39. char ssid[] = "HUAWEI-B315";
  40. char pass[] = "siol3210";
  41.  
  42. //Using Static IP
  43. byte arduino_mac[] = { 0x2C, 0x3A, 0xE8, 0x0E, 0x5A, 0x36 };
  44. IPAddress arduino_ip ( 192, 168, 1, 200);
  45. //IPAddress dns_ip ( 8, 8, 8, 8);
  46. IPAddress gateway_ip ( 192, 168, 1, 1);
  47. IPAddress subnet_mask(255, 255, 255, 0);
  48. // sinhronizacija
  49. //BlynkTimer posljitemp;
  50.  
  51. void posljitemp()
  52. {
  53. h = dht.getHumidity();
  54. t = dht.getTemperature();
  55. Blynk.virtualWrite(V10, t);
  56. Blynk.virtualWrite(V11, h);
  57. }
  58. // You can send any value at any time.
  59. // Please don't send more that 10 values per second.
  60. // Blynk.virtualWrite(V10, t); //temperature on virtual pin V5
  61. //Blynk.virtualWrite(V11, h); //humidity on virtual pin V6
  62. //------------------------------------------------------------
  63. // beri temp iz sliderja
  64. // This function will be called every time Slider Widget
  65. // in Blynk app writes values to the Virtual Pin V1
  66.  
  67. void beritemp() {
  68. Blynk.syncVirtual(V13); // the value widget to check
  69.  
  70.  
  71. BLYNK_WRITE(V13); // read the value of V13
  72. Serial.println("bere v13");
  73. }
  74.  
  75. void setup() {
  76. // put your setup code here, to run once:
  77. irsend.begin();
  78. Serial.begin(115200);
  79.  
  80. pinMode (DHTPIN, INPUT);
  81. dht.setup(DHTPIN, DHTesp::DHT22); // Connect DHT sensor to GPIO 10
  82. delay(dht.getMinimumSamplingPeriod());
  83.  
  84.  
  85. h = dht.getHumidity();
  86. t = dht.getTemperature();
  87. if (isnan(h) || isnan(t)) {
  88. Serial.println("Failed to read from DHT sensor!");
  89. // return;
  90. }
  91. Blynk.begin(auth, ssid, pass);
  92. // You can also specify server:
  93. //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  94. //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  95.  
  96. // Setup a function to be called every second
  97. // temperatura
  98. timer.setInterval(1000L, posljitemp);
  99. timer.setInterval(1000L, beritemp);
  100. Serial.println("temp");
  101. h = dht.getHumidity();
  102. t = dht.getTemperature();
  103.  
  104. display_temp = t;
  105. display_humid = h;
  106.  
  107. Serial.println(display_temp);
  108. Serial.println(display_humid);
  109. }
  110.  
  111. // PRIZIG GRETJA
  112. BLYNK_WRITE(V0) {
  113. if (param.asInt())
  114. {
  115. irsend.sendNEC(0XF7C03F, 32);
  116. Serial.println("heatOn");
  117. Blynk.notify("Vklop peči");
  118. Blynk.virtualWrite(V6, 255); // status
  119. }
  120. }
  121. BLYNK_WRITE(V2) {
  122. if (param.asInt())
  123. {
  124. irsend.sendNEC(0XF740BF, 32);
  125. Serial.println("heatOff");
  126. Blynk.notify("Izklop peči");
  127. Blynk.virtualWrite(V6, 0); // status
  128. }
  129. }
  130.  
  131. // Branje nastavljene
  132. BLYNK_WRITE(V13) {
  133. if (param.asInt())
  134. {
  135. int nastavljena = param.asInt(); // assigning incoming value from pin V1 to a variable
  136. Serial.println(nastavljena);
  137. // process received value
  138. }
  139. }
  140.  
  141. void loop() {
  142. // put your main code here, to run repeatedly:
  143. Blynk.run();
  144. timer.run();
  145. // primerjava temp
  146. //Serial.println(nastavljena);
  147. if (t > (nastavljena + 4))
  148. Serial.println("je večje");
  149.  
  150. if (t < (nastavljena - 3))
  151. Serial.println("je manjse");
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement