Help please with NODEMCU And DS18B20

Hello friends am new to the forum and new to Blynk.
So I wanted to ask for help to know if anyone knows where to find a source for NODEMCU code, and DS18B20, because I can not find something that works with Blynk.

Thank you very much :grinning:

There’s no such thing AFAIK, it’s just Arduino code.

Do you know how to use the DS18B20 i.e do you have Arduino code for it without Blynk and is it running fine ?

You just then incorporate Blynk’s ESP8266 Standalone sketch into your DS18B20 sketch but ensure you call the temperature requests at intervals with SimpleTimer and not in the main loop() as Blynk loop() should be limited to 2 lines as you will have seen in the decent examples.

Friend this is the sketch that I have, but does not work
everything is perfectly compiled without error but does not work.
so I need help figuring out if someone has a better draft.
I’ll be very greatful :slight_smile:

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

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char auth[] = “fromBlynkApp”;

SimpleTimer timer;

void setup()
Blynk.begin(auth, “ssid”, “password”);


timer.setInterval(5000L, sendTemps); // Temperature sensor polling interval (5000L = 5 seconds)

void sendTemps()
sensors.requestTemperatures(); // Polls the sensors

float tempBabyRoom = sensors.getTempFByIndex(0); // Gets first probe on wire in lieu of by address

Blynk.virtualWrite(4, tempBabyRoom);

void loop()

I think that you need to define on which pin you have connected DS18b20 data output. Keep in mind that pin number on NodeMCU does not correspond with GPIO numbers.

For example, if you connect your DS18b20 on pin D4, you must define it as

#define ONE_WIRE_BUS 2

because D4 is GPIO2.


Thank you friends for your answers, the problem was not arduino ide subia the draft, and that said error “espcomm_upload_mem failed” nodemcu solve it by connecting with flash button pressed, now everything works fine thank you very much everyone.

I still wonder why nodemcu was that mistake? because now I upload sketches with flash button pressed, before it was never necessary.