The DS18B20 is a digital thermometer provides 9bit to 12bit Celsius temperature measurement, this device has an alarm function with nonvolatile that user can program upper and lower trigger points. DS18B20 communicates over one wire bus or one data line and ground for temperature data acquisition with a central microprocessor. These device operates on a temperate range of -55 degree Celsius to +125 degree Celsius and it’s accurate to ±0.5 degree Celsius over the range of -10 degree Celsius to +85 degree Celsius. In addition, the DS18B20 can derive power directly from the data line or PARASITE POWER, eliminating the need for an external power supply.
Each DS18B20 has its own unique 64bit serial code, which allows to implement multiple DS19B20 to work on the same 1 wire bus. This device is very simple to use requires only one microcontroller or microprocessor to control 1 or more DS18B20 distributed over a large area. This device is mostly use in HVAC environment control, temperature monitoring system inside the building, equipment’s or machinery, and process monitoring and control system.
As you can see the illustration below we connected the DS18B20 to Raspberry Pi and coded on Python, this is just a demonstration how to control and get the data from the sensor.
- Raspberry Pi 1,2,3
- DS18b20 One wire temperature sensor Module
- Jumper wire / DuPont Wire
- Solder Less Breadboard
Python Source Code
# NOTE: DS18B20 Signal/Data Pin should be connected to RPI Pin7 GPIO04
tfile = open("/sys/bus/w1/devices/28-00145232cfff/w1_slave")
text = tfile.read()
secondline = text.split("\n")
temperaturedata = secondline.split(" ")
temperature = float(temperaturedata[2:])
temperature = temperature / 1000
print "14CORE | DS18B20 TEST w/d RPI"
print "Current temperature : %0.3f C" % temperature