Now lets log temperature to Blynk
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "auth";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "TP-wifi";
char pass[] = "pass";
// Data wire is plugged into port D2 on the ESP8266
#define ONE_WIRE_BUS D2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
float tempSensor1;
uint8_t sensor1[8] = { 0x28, 0xDC, 0x8E, 0x5D, 0x05, 0x00, 0x00, 0xBE };
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
sensors.begin();
}
void loop()
{
Blynk.run();
logTime();
}
void logTime(){
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
sensors.requestTemperatures();
tempSensor1 = sensors.getTempC(sensor1);
Blynk.virtualWrite(V5,tempSensor1 );
}
else {
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}