DS18B20 – Digital Temperature Sensor

DS proto

The DS18B20 to quote the manufacture MAXIM  ‘provides 9-bit to 12-bit Celsius temperature measurements. It has an operating temperature range of -55°C to +125°C and is accurate to ±0.5°C over the range of -10°C to +85°C. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply’ . [you will also see it listed in some places as a ‘Dallas’ part – Dallas Semiconductor was purchased by MAXIM in 2001].

The DS18B20 communicates over a 1-Wire bus, so needs just 3 connections to the Raspberry pi and a single 4.7k resistor. Maxim’s 1-Wire bus protocol also allows multiple devices to be connected on the same data-line with no additional components.mult_DS_Rpi

The only downside as far as the RaspberryPi is concerned is that the 1-Wire interface is only available on GPIO4.

There are loads other blogs with simple guides showing how to connect the DS18B20 to the RaspberryPi, so I will not repeat here, but have included a link to an easy to follow example on the RasPi Mart site.


This also includes example Python code and how to enable to the ‘w1-gpio’ and ‘w1-therm’ elements automatically at start-up. If you are doing anything odd on you RaspberryPi you might want to check the following forum post to see for more information on this.


As configured using the ‘w1-therm’ setup the DS18B20 provides a temperature readout in 1000th of a degC, which I think is not bad at all for something that only costs around £1.50 each [or cheaper in quantity]. Remember however that while the on-screen display may be to a 1000th °C the devices accuracy is specified at ±0.5°C.

ds screen dump

You can see here the affect of me holding my finger on the sensor for a few seconds.

I certainly think for next winter I will be moving over to these to control our chicken water heater, as the current analogue system using lm35’s does suffer a bit from noise. Also as DS18B20-WP-0-250x250you can get a pre-wired water proof version of the sensor, I can put a sensor directly in the water.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.