NodeMCU ds18b20 decimals

Hi, im trying to connect 4 ds18b20 sensors to my NodeMCU 1.0 but im having problem with decimals. Its currently just displaying a whole number like 32°C. I have tried changing the sensors resolution but doesnt appear to make a difference. I have looked all over the forum but cant find a solution, what am i doing wrong here?

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2        // This is the ESP8266 pin
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress tempSensor1 = { 0x28, 0xFF, 0x34, 0x1C, 0x00, 0x16, 0x03, 0x5D }; // Temperature probe #1
DeviceAddress tempSensor2 = { 0x28, 0xFF, 0x02, 0x65, 0x00, 0x16, 0x03, 0x7E }; // Temperature probe #2
DeviceAddress tempSensor3 = { 0x28, 0xFF, 0x42, 0x1A, 0x00, 0x16, 0x03, 0xA5 }; // Temperature probe #2
DeviceAddress tempSensor4 = { 0x28, 0xFF, 0x92, 0x14, 0x00, 0x16, 0x03, 0xEE }; // Temperature probe #2

char auth[] = "0952dd6d3dd146e0a73c428b7d14d793";
char ssid[] = "ddd";
char pass[] = "ddd";

SimpleTimer timer;

int temperature1, temperature2, temperature3, temperature4;         // Variables for storing temperatures

void setup()
  Blynk.begin(auth, ssid, pass);

  while (Blynk.connect() == false) {
    // Wait until connected

  sensors.setResolution(tempSensor1, 10);   // More on resolutions:
  sensors.setResolution(tempSensor2, 10);
  sensors.setResolution(tempSensor3, 10);
  sensors.setResolution(tempSensor4, 10);

  // These timers are used to keep the loop() nice and leak... keeps Blynk from getting flooded.
  timer.setInterval(5000L, sendSensor1);
  timer.setInterval(15000L, sendSensor2);
  timer.setInterval(30000L, sendSensor3);
  timer.setInterval(50000L, sendSensor4);

void loop()

void sendSensor1() {
  sensors.requestTemperatures();                  // Polls the sensors
  temperature1 = sensors.getTempC(tempSensor1);   // Stores temp in F. Change getTempF to getTempC for celcius.
  Blynk.virtualWrite(1, temperature1();            // Send temp to Blynk virtual pin 1

void sendSensor2() {
  temperature2 = sensors.getTempC(tempSensor2);
  Blynk.virtualWrite(2, temperature2);

void sendSensor3() {
  temperature3 = sensors.getTempC(tempSensor3);
  Blynk.virtualWrite(3, temperature3);
void sendSensor4() {
  temperature4 = sensors.getTempC(tempSensor4);
  Blynk.virtualWrite(4, temperature4);
1 Like

change to float instead of int

1 Like

That did it! Thank you!

1 Like