Problem: The new raspbian kernel does not detect the DS18b20 sensor over the 1wire bus. This is due to the Device Tree that was added to Kernel 3.18.8

What hardware used:

  • Raspberry Pi 3b+ Kernel: 4.14.98-v7 +
  • DS18b20 intact tested on Arduino
  • The signal is pulled up + through a resistor 4.7k Ω (tested with 1k Ω)
  • Also tested on 3.3v and 5v

Photo of connection

Essence: To read sensor, you need to add dtoverlay=w1-gpio to /boot/config.txt And for the new kernel, is enough that a sensor is detected on GPIO4 and the modules wire, w1-gpio, w1-therm are loaded After that, in /sys/bus/w1/devices a directory appears whose name starts at 28-* this is the place where the readings are recorded in the w1_slave file. But not for my case.

Identical problem: "S18B20 no longer working"

Question: 1)Why doesn’t my Raspberi detect a sensor and not add it? 2) Can this sensor somehow be running without 1wire?

All topics related to this issue read and the last advice on the raspberry forum was to give up and leave the Raspberry ether sensor.

  • I agree that there is nothing we can do now, but forget it until someone has updated the dtoverlay thing. And what do you mean by "leave the Raspberry ether sensor" ? Do you mean DS18B20 is a ether gas sensor? I have read about using python to control DS18B20. Do you think it a good idea? DS18B20 Temperature Sensor With Rpi Python bigl.es/ds18b20-temperature-sensor-with-python-raspberry-pi
    – tlfong01
    Commented May 9, 2019 at 13:58
  • >> what do you mean by "leave the Raspberry ether sensor" ? I mean to stop use Raspberry for this task, and choose something like arduino =)
    – mrTall
    Commented May 13, 2019 at 10:24
  • Yes, often a MCU like Arduino can do the job better,
    – tlfong01
    Commented May 13, 2019 at 12:37

1 Answer 1



New raspbian kernel does not detect DS18B20 sensor


DS18B20 can be detected with the following configuration:

Raspbian stretch 2019apr08

Python 3.5.3

W1ThermSensor V0.3.0


Program and sample output

# DS18B20_test28 tlfong01 2019may10hkt2137 ***
# Raspbian stretch 2019apr08, Python 3.5.3
# W1ThermSensor V0.3.0

# dtoverlay=w1-gpio,gpiopin=14

from w1thermsensor import W1ThermSensor

def findSensor():
    for sensor in W1ThermSensor.get_available_sensors():
        print('  Sensor ID =', sensor.id)

def getTemperature():
    sensor = W1ThermSensor()
    temperature_in_celsius = sensor.get_temperature()
    print('  Temperature in Celsius =', temperature_in_celsius)

# *** Main Test ***

print('Begin Testing Ds18B20, ...')
print('End   Testing DS18B20, ...')

Sample Output - tlfong01 2019may10hkt2150
 RESTART: /home/pi/Python Programs/Python_Programs/test1198/ds18b20_test27_2019may1001.py 
Begin Testing Ds18B20, ...
  Sensor ID = 021312ca3baa
  Temperature in Celsius = 25.562
End   Testing DS18B20, ...


# *** End of program ***


DS18B20 datasheet

AdaFruit DS18B20 Temperature Sensor - US$9.95


This is a pre-wired and waterproofed version of the DS18B20 sensor. Handy for when you need to measure something far away, or in wet conditions. While the sensor is good up to 125°C the cable is jacketed in PVC so we suggest keeping it under 100°C. Because they are digital, you don't get any signal degradation even over long distances!

These 1-wire digital temperature sensors are fairly precise (±0.5°C over much of the range) and can give up to 12 bits of precision from the onboard digital-to-analog converter. They work great with any microcontroller using a single digital pin, and you can even connect multiple ones to the same pin, each one has a unique 64-bit ID burned in at the factory to differentiate them. Usable with 3.0-5.0V systems.

The only downside is they use the Dallas 1-Wire protocol, which is somewhat complex, and requires a bunch of code to parse out the communication. If you want something really simple, and you have an analog input pin, the TMP36 is trivial to get going.

We toss in a 4.7k resistor, which is required as a pullup from the DATA to VCC line when using the sensor. We don't have a detailed tutorial up yet but you can get started by using the Dallas Temperature Control Arduino library which requires also the OneWire Library.

Technical Details

Not for use in salt water or other corrosive environments.

Cable specs:

Stainless steel tube 6mm diameter by 30mm long

Cable is 36" long / 91cm, 4mm diameter

Contains DS18B20 temperature sensor

If your sensor has four wires - Red connects to 3-5V, Black connects to ground and White is data. The copper wire is soldered to the wire shielding

If your sensor has three wires - Red connects to 3-5V, Blue/Black connects to ground and Yellow/White is data

DS18B20 Technical specs:

Usable temperature range: -55 to 125°C (-67°F to +257°F)

9 to 12 bit selectable resolution

Uses 1-Wire interface- requires only one digital pin for communication

Unique 64 bit ID burned into chip

Multiple sensors can share one pin

±0.5°C Accuracy from -10°C to +85°C

Temperature-limit alarm system

Query time is less than 750ms

Usable with 3.0V to 5.5V power/data

  • 1
    So many hours I spent to archive this... Thank you, this is a working way to get this sensor work!
    – mrTall
    Commented May 13, 2019 at 11:00
  • You are welcome. Have a nice project.
    – tlfong01
    Commented May 13, 2019 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.