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()
{
  sensors.requestTemperatures();
  // 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));
}
BLYNK_WRITE(V1)
{
  int buttonState = param.asInt();
  digitalWrite(4,buttonState);
  }
BLYNK_WRITE(V2){
  int buttonState=param.asInt();
  analogWrite(3,buttonState);
  }

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  sensors.begin();
  timer.setInterval(1000L, sendSensor);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
}


void loop()
{
  Blynk.run();
  timer.run();
} 

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.

THANKS
this is the pin distribution of the nodemcu [details=Summary][/details]http://panamahitek.com/wp-content/uploads/2016/10/nodemcu_pins.png
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. (http://www.instructables.com/id/ESP8266-Using-GPIO0-GPIO2-as-inputs/) 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.