DS18B20 Always Reports -127.00 degrees

Hi,

Another esp-01 question, mainly around the use of GPIO-0 for the DS18B20 one wire data line.

I have the following code:

#include <OneWire.h>
#include <DallasTemperature.h>

// esp8266 GPIO Table
// http://www.seeedstudio.com/recipe/img/recipe/2015-05/55582b9962fb5.JPG

#define ONE_WIRE_BUS 0

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  Serial.println("");
  Serial.println("Setup..");

  // Start up the library
  sensors.begin();  
}

// the loop function runs over and over again forever
void loop() {
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0));  
  delay(2000);
}

Noting that the http link in the code comments mentions GPIO-0 is IO index of 3, I also tried the following but still I only get -127.00 on the data line:

#define ONE_WIRE_BUS 3

I have the VCC and GND lines on the temp sensor to ground.

So next for the data line I have the following in the breadboard:

I have a 4.7k resistor from the 3.3v breadboard rail to "a" on the breadboard.

I have the DS18B20 plugged into "b" on same line next to the 4.7k resistor.

I have the ESP-01 GPIO-0 into "c" next to the DS18B20 which is plugged into "b".

Is this wiring accurate?

Any other ideas?

Thx

9 times out of 10, a verbal description hides a mistake. So please post a diagram or a photo.

Image attached.

have you tried 5v instead of 3.3v

You show a breadboard where the supply is shorted to ground and an unconnected pullup resistor.

Hi,

The red wire is VCC for the temperature sensor.
The black wire is GND for the temperature sensor.
The yellow wire is the data line for the temperature sensor.
The yellow wire going downwards is the ESP-01 GPIO 0 line.

If I'm reading the data sheet right, I need to have VCC and GND to ground then have a pull-up resistor between 3.3v and the data line. So pretty much this:

http://sq9nje.pl/wp-content/uploads/2014/02/ds18b20_parasite-power_bb.png

Can someone please guide me on how to properly wire this up on the breadboard?

i had the same problem with the temp reading -127, i had the sensor in the wrong way around. I found out the hard way....... touched it, it was red hot.

http://sq9nje.pl/wp-content/uploads/2014/02/ds18b20_parasite-power_bb.png

your picture said you connected to 5v line and you are talking 3.3v..

so which line have you tried.

my work well with the 4.7k connected to 5v as in the picture

The datasheet says I can use either 5v or 3.3v.

This photo is just a sample of what I'm trying to achieve: http://sq9nje.pl/wp-content/uploads/2014/02/ds18b20_parasite-power_bb.png

This really was to show parasitic mode for the DS18B20, whereby VCC and GND on the sensor is to ground and there's a pull up for the data line.

I'm struggling to get this working on a breadboard.

Can anyone explain or show a photo of how I need to wire it up?

Thx

The second part of this picture shows how the strips of a breadboard are connected underneath.

The black and red wires in your picture are shorted, because they are plugged into the same strip.
Leo..

I think he mean to connected like that Leo ... that the red and the black wires from the ds18b20 both to ground..

cant see the colour but are you sure it is a 4.7k resistor?
also try another ds18b20

oh if you look at the diagram. they use pin 2 ..the data line
http://sq9nje.pl/wp-content/uploads/2014/02/ds18b20_parasite-power_bb.png

you said you tried digital pin 3 already ?

change to pin 3 on the sketch .. and plug the data pin of ds18b20 to pin 3 on your arduino

#define ONE_WIRE_BUS 3

I believe that the reason is that GPIO0 must be High for starting the module.

You can read this

It talks about I2C but you can use only GPIO-0 or GPIO-2