Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BLYNK_PRINT Serial
- #include "EEPROM.h"
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- #include <DHT.h>
- // You should get Auth Token in the Blynk App.
- // Go to the Project Settings (nut icon).
- float tE;
- int beallitE;
- int beallit; //beállít változó globális
- int count=1;
- BLYNK_WRITE(V1)
- {
- beallit = param.asInt(); // assigning incoming value from pin V1 to a variable
- }
- // You can also use:
- // String i = param.asStr();
- // double d = param.asDouble();
- char auth[] = "db1c8b0eb5354042b03bafea955cbe06";
- // Your WiFi credentials.
- // Set password to "" for open networks.
- char ssid[] = "DIGI-01061597";
- char pass[] = "PMzvSJDW";
- #define DHTPIN 2 // What digital pin we're connected to
- // Uncomment whatever type you're using!
- #define DHTTYPE DHT11 // DHT 11
- //#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
- //#define DHTTYPE DHT21 // DHT 21, AM2301
- DHT dht(DHTPIN, DHTTYPE);
- BlynkTimer timer;
- // This function sends Arduino's up time every second to Virtual Pin (5).
- // In the app, Widget's reading frequency should be set to PUSH. This means
- // that you define how often to send data to Blynk App.
- float h=20;
- float t=5;
- void sendSensor()
- {
- h = dht.readHumidity();
- t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
- if (isnan(h) || isnan(t)) {
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- // You can send any value at any time.
- // Please don't send more that 10 values per second.
- Blynk.virtualWrite(V5, h);
- Blynk.virtualWrite(V6, t);
- }
- //termosztát
- void termosz(){
- // Serial.print("V1 Slider value is: ");
- Serial.print("t ");
- Serial.println(t);
- delay(500);
- Serial.print("te ");
- Serial.println(tE);
- if (t == tE and beallit == beallitE)
- {
- valt_3();
- }
- else {
- if (t<beallit) {
- valt_1();
- delay(100);
- valt_3();
- }
- if (t>beallit){
- valt_2();
- delay(100);
- valt_3();
- }
- }
- }
- void valt_1() {
- digitalWrite(D8, HIGH);
- digitalWrite(D6, LOW);
- }
- void valt_2() {
- digitalWrite(D6, HIGH);
- digitalWrite(D8, LOW);
- }
- void valt_3() {
- digitalWrite(D6, LOW);
- digitalWrite(D8, LOW);
- }
- void setup()
- {
- pinMode(D6, OUTPUT);
- pinMode(D8, OUTPUT);
- pinMode(D5, OUTPUT);
- // Debug console
- Serial.begin(9600);
- 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);
- dht.begin();
- // Setup a function to be called every second
- timer.setInterval(1000L, sendSensor);
- }
- void loop()
- {
- tE=t;
- beallitE=beallit;
- Blynk.run();
- timer.run();
- termosz();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement