NODEMCU ds18b20 with leds

Hello I want some help for my proyect :slight_smile:

the problem is that the device disconect when you interact with the widgets.
a simply increase of the temperature makes it disconect
let me know what im doing wrong :confused:

define BLYNK_PRINT Serial
include DallasTemperature.h>
include OneWire.h>
include ESP8266WiFi.h>
include BlynkSimpleEsp8266.h>

char auth[] = "***";
char ssid[] = "***";
char pass[] = "***";

define DATO 2         // What digital pin we're connected to
OneWire ourWire (DATO);
DallasTemperature sensors (&ourWire);
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 sendSensor()
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V3, sensors.getTempCByIndex(0));
  Blynk.virtualWrite(V4, sensors.getTempCByIndex(0));
  int buttonState = param.asInt();
  int buttonState=param.asInt();

void setup()
  // Debug console
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, sendSensor);

void loop()

I tried editting your to make your code look nice. Use three backticks ` before and after it to make it look nice and readable.

Anyway, I think pins 2 and 4 are reserved on the ESP platform. Try using other pins. That may work better since, I think, pin 2 is used in firmware upload process.

this is the pin distribution of the nodemcu [details=Summary][/details]
but i cannot put the ds18b20 to other pin cause it doesnt work either :disappointed: doesnt even mesure the temperature

How do you have the probe wired? Did you include the pull-up resistor?

Additionally, as @Lichtsignaal stated, try not to use GPIO-2, along with GPIO-0 and GPIO-15, especially for inputs, as these pins are used for other tasks on the ESP. ( Try using GPIO-14 (D5) or GPIO-12 (D6).

As for the code, it looks correct to me; so it is probably a pin/wiring issue.

i drew my circuit. i changed pin d2 for d5 like you said. but keeps disconecting. i also tried with other pins for the led but interact with the led widget makes it disconect.