Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <IRrecv.h>
- #include <IRremoteESP8266.h>
- #include <IRsend.h>
- const uint16_t kIrLed = 14; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
- IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
- #include <ESP8266mDNS.h>
- #include <WiFiUdp.h>
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- // SENZOR
- #define DHTPIN 12 // Temp sensor hardware pin on SD3/GPIO10
- #include "DHTesp.h"
- DHTesp dht;
- SimpleTimer timer;
- #include <TimeLib.h>
- #include <WidgetRTC.h>
- WidgetRTC rtc;
- String display_temp;
- String display_humid;
- String dispTempSet;
- int tempset; // tempset value from pin V13
- int tempset2; // lower treshold for triggering the heating
- float nastavljena; // nastavljena temp iz sliderja
- float h; //temperature value
- float t ; //humidity value
- // You should get Auth Token in the Blynk App.
- // Go to the Project Settings (nut icon).
- char auth[] = "77c28c13f6f24a3393510bd12c321cee";
- // Your WiFi credentials.
- // Set password to "" for open networks.
- char ssid[] = "HUAWEI-B315";
- char pass[] = "siol3210";
- //Using Static IP
- byte arduino_mac[] = { 0x2C, 0x3A, 0xE8, 0x0E, 0x5A, 0x36 };
- IPAddress arduino_ip ( 192, 168, 1, 200);
- //IPAddress dns_ip ( 8, 8, 8, 8);
- IPAddress gateway_ip ( 192, 168, 1, 1);
- IPAddress subnet_mask(255, 255, 255, 0);
- // sinhronizacija
- //BlynkTimer posljitemp;
- void posljitemp()
- {
- h = dht.getHumidity();
- t = dht.getTemperature();
- Blynk.virtualWrite(V10, t);
- Blynk.virtualWrite(V11, h);
- }
- // You can send any value at any time.
- // Please don't send more that 10 values per second.
- // Blynk.virtualWrite(V10, t); //temperature on virtual pin V5
- //Blynk.virtualWrite(V11, h); //humidity on virtual pin V6
- //------------------------------------------------------------
- // beri temp iz sliderja
- // This function will be called every time Slider Widget
- // in Blynk app writes values to the Virtual Pin V1
- void beritemp() {
- Blynk.syncVirtual(V13); // the value widget to check
- BLYNK_WRITE(V13); // read the value of V13
- Serial.println("bere v13");
- }
- void setup() {
- // put your setup code here, to run once:
- irsend.begin();
- Serial.begin(115200);
- pinMode (DHTPIN, INPUT);
- dht.setup(DHTPIN, DHTesp::DHT22); // Connect DHT sensor to GPIO 10
- delay(dht.getMinimumSamplingPeriod());
- h = dht.getHumidity();
- t = dht.getTemperature();
- if (isnan(h) || isnan(t)) {
- Serial.println("Failed to read from DHT sensor!");
- // return;
- }
- Blynk.begin(auth, ssid, pass);
- // You can also specify server:
- //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
- //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
- // Setup a function to be called every second
- // temperatura
- timer.setInterval(1000L, posljitemp);
- timer.setInterval(1000L, beritemp);
- Serial.println("temp");
- h = dht.getHumidity();
- t = dht.getTemperature();
- display_temp = t;
- display_humid = h;
- Serial.println(display_temp);
- Serial.println(display_humid);
- }
- // PRIZIG GRETJA
- BLYNK_WRITE(V0) {
- if (param.asInt())
- {
- irsend.sendNEC(0XF7C03F, 32);
- Serial.println("heatOn");
- Blynk.notify("Vklop peči");
- Blynk.virtualWrite(V6, 255); // status
- }
- }
- BLYNK_WRITE(V2) {
- if (param.asInt())
- {
- irsend.sendNEC(0XF740BF, 32);
- Serial.println("heatOff");
- Blynk.notify("Izklop peči");
- Blynk.virtualWrite(V6, 0); // status
- }
- }
- // Branje nastavljene
- BLYNK_WRITE(V13) {
- if (param.asInt())
- {
- int nastavljena = param.asInt(); // assigning incoming value from pin V1 to a variable
- Serial.println(nastavljena);
- // process received value
- }
- }
- void loop() {
- // put your main code here, to run repeatedly:
- Blynk.run();
- timer.run();
- // primerjava temp
- //Serial.println(nastavljena);
- if (t > (nastavljena + 4))
- Serial.println("je večje");
- if (t < (nastavljena - 3))
- Serial.println("je manjse");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement