Ds18b20 / wemos d1

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.

#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)
  Blynk.begin(auth, ssid, pass);
  Serial.println("Dallas Temperature IC Control Library Demo");
  Serial.print("Locating devices...");
  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: ");

  sensors.setResolution(insideThermometer, 9);
  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC); 
    void printTemperature(DeviceAddress deviceAddress)
    float tempC = sensors.getTempC(deviceAddress);
    Serial.print("Temp C: ");
 // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
    void loop(void)
   timer.run(); // Initiates BlynkTimer
    Serial.print("Requesting temperatures...");
  // 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);

@marto61 read this thread Automatically turn on/off the boiler with the blynk application and NodeMCU

The value you see increasing is not temperature it is milliseconds since your MCU was rebooted.

Thanks Costas,
It seems every video or example only ever goes as far as setting up the DS18B20 to show read out in the serial monitor which i have done , but nothing how to send that value to the app , seems i need to combine a number of examples but have had only partial success.
i would of thought this kind of setup reading a temp on the blynk app would be quite common .
i can set it up easily using Cayenne but that has to be a Arduino UNO board .

It is, and very simple :wink:

So take that same variable, containing your temp data, and send it to the App with Blynk.virtualWrite(vPin, value), just like all other data sent to the App.

It is basically digital LEGO… only with coded commands and functions… assemble separate parts together for a whole.


Thanks Gunner , i will give it a try , i am aware that this is 100 % my lack of experience and do certainly appreciate the help provided in the forum.
Its going to be a good feeling when i finally get it to work .

Hi .would someone be able to show me how i would send my temp data to virtual pin V5 in my attached sketch , how would it look and on which line it should go ?

i still cant get this to work and im sure once i see where it goes and how it looks i will be able to use that technic in all my other projects.


As already directed… you would simply use a Blynk.virtualWrite(vPin, value); as you would a Serial.println(value); or digitalWrite(pin, value); command… only using virtual pins and seting the vPin to the same one you use in a Display Widget in the App.


As far as the rest… First, your code layout is not optimum for Blynk requirements, you also need to use timers instead of dumping everything in the void loop();… Blynk is constantly communicating between the App, Server and Devices, so proper code and time management is required.


Start reading from TOP to BOTTOM of the Docs and Help Center and then try out a few of the ready made examples in the Sketch Builder. Scroll up to the top of this page for all those links.