#include #define BLYNK_PRINT Serial // Comment this out to disable prints and save space #include #include #include #include #include LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); #define BACKLIGHT_PIN 3 #define ONE_WIRE_BUS 2 // This is the ESP8266 pin OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); DeviceAddress tempSensor1 = { 0x28, 0xFF, 0xD5, 0x1B, 0x80, 0x16, 0x05, 0x73 }; // Adres temperatury #1 DeviceAddress tempSensor2 = { 0x28, 0xFF, 0x72, 0x55, 0x80, 0x16, 0x05, 0xE4 }; // Adres temperatury #2 char auth[] = "xxxx"; // Kod BLYNK char ssid[] = "xxxx"; // Login WIFI char pass[] = ""; // Hasło WIFI SimpleTimer timer; int pin = D2; // Pin cyfrowy krancówka WidgetLED led1(V3); // Pin wirtualny krancowy int pin2 = D3; // Pin cyfrowy krancówka WidgetLED led2(V4); // Pin wirtualny krancowy int pin3 = D4; // Pin cyfrowy krancówka WidgetLED led3(V5); // Pin wirtualny krancowy int tempC1, tempC2; // Variables for storing temperatures BLYNK_CONNECTED() { Blynk.syncAll(); } void setup() { Serial.begin(9600); Blynk.begin(auth, ssid, pass); while (Blynk.connect() == false) { // Wait until connected lcd.begin (16,2); lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE); lcd.setBacklight(HIGH); lcd.setCursor(0, 0); lcd.print("Temp:"); lcd.setCursor(11, 0); lcd.print(" "); lcd.write(0xDF); // Znak stopnia lcd.print("C "); } sensors.begin(); timer.setInterval(1000L, brama1); //Sprawdzanie stanu timer.setInterval(1000L, brama2); //Sprawdzanie stanu timer.setInterval(1000L, brama3); //Sprawdzanie stanu sensors.setResolution(tempSensor1, 9); // More on resolutions: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/ sensors.setResolution(tempSensor2, 9); // These timers are used so that data does not flood Blynk timer.setInterval(5000L, sendSensor1); // Czas pomiaru temperatury #1 timer.setInterval(5000L, sendSensor2); // Czas pomiaru temperatury #2 } void loop() { Blynk.run(); timer.run(); } void sendSensor1() { sensors.requestTemperatures(); // Polls the sensors tempC1 = sensors.getTempC(tempSensor1); // C - celsjusza / F - fahrenheita Blynk.virtualWrite(1, tempC1); // 1 Pin wirtualny } void sendSensor2() { sensors.requestTemperatures(); tempC2 = sensors.getTempC(tempSensor2); Blynk.virtualWrite(2, tempC2); // 2 Pin wirtualny } void brama1() { if(digitalRead(pin) == 1){ led1.on(); } else{ led1.off(); } } void brama2() { if(digitalRead(pin2) == 1){ led2.on(); } else{ led2.off(); } } void brama3() { if(digitalRead(pin3) == 1){ led3.on(); } else{ led3.off(); } } void temperatura() { float temperature = getTemp(); Serial.println(temperature); lcd.setCursor(6, 0); lcd.print(temperature); delay(1000); //just here to slow down the output so it is easier to read } >