Hi , could anyone help with the attached code.?
I feel like im close but not quite there , i can connect the Wemos D1 on the app and see a value on virtual pin 5 but it just climbs slowly , i can see the temps updates in the serial monitor ok and the connection to the blynk cloud so i must be missing something in the code in regards to the virtual pin.
Any help would be greatly appreciated.
Regards
Dave
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SPI.h>
char auth[] = "XXXXXXXXXXXXXXXX";
char ssid[] = "XXXXXXXXX";
char pass[] = "XXXXXXXX";
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.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
}
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = {0x28, 0xFF, 0x7D, 0x8B, 0xB5, 0x16, 0x05, 0x74 };;
void setup(void)
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
Serial.println("Dallas Temperature IC Control Library Demo");
Serial.print("Locating devices...");
sensors.begin();
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
Serial.print("Device 0 Address: ");
printAddress(insideThermometer);
Serial.println();
sensors.setResolution(insideThermometer, 9);
Serial.print("Device 0 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer), DEC);
Serial.println();
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp C: ");
Serial.print(tempC);
Serial.println(DallasTemperature::toFahrenheit(tempC));
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop(void)
{
timer.run(); // Initiates BlynkTimer
Blynk.run();
Serial.print("Requesting temperatures...");
sensors.requestTemperatures();
Serial.println("DONE");
printTemperature(insideThermometer);
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
if (deviceAddress[i] < 16) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}