Temperature sensor - DS18B20

I am having a strange behavior with the temperature sensor DS18B20.

When I have two sensors, it works just fine, as expected. It detects both sensors and I can read both temperatures.

If I disconnect one sensor, then I detect 0 sensors.

The wiring that I have is like this:

The pull-up resistance that I am using is: 4.7kΩ.

I connected VCC to VIN in the ESP8266.

I am pretty sure the issue is electrical not related to programming. In setup I have the following line:

  Serial.print( sensorDS18B20.getDeviceCount() );

That shows 2 or 0 depending on having one sensor disconnected or not.

Any clue of what am I doing wrong?

Not posting your full sketch for a start

Try using something in the 3K range and do post your code following forum rules.

I would expect the issue is software unless there is more to the remove one sensor story.

Does your library have any other examples? Perhaps an example for only one sensor. This will verify the hardware is working or not.

The data sheet of the sensor requires minimum of 3 V on the data pin. I use a 220 Ohm instead of the 4.7k, which is often recommended because of the OneWire library, and it works just fine.

With the 4.7k my sensors used to work for some time(2-3 on/off switches) and then I couldn't get any readings. The lower resistor fixes this.

tested a single DS18B20 on a NodeMCU V1 ESP-12E first using pin D1 (GPIO5) then pin D2 (GPIO4) all worked OK - pullup is 4.7K
I only have one DS18B20 therefore cannot test two devices
which GPIOx were you having problems with?

That's over the safety limit of the DS18B20.
Absolute max sink current is 4mA according to the datasheet.
I wouldn't go lower than 1k.
(3volt/1kohm = 3mA)
Leo..

Read the data sheet again, its min sink current (the opposite of "Absolute max") of 4mA @ Vio = 0.4 V. As I said earlier you need a min of +3.0 V on Vpu, which will not happen if you power with an esp and use a 4.7k.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.