In this project we use a 1 Wire DS18B20 Digital Thermometer and program our Raspberry Pi to read the Temperature.
It is a DS18B20 chip in Stainless steel tube.
The Raspberry Pi already has a driver for 1 Wire Bus. We need to load by booting.
Use the following command in Terminal window:
sudo modprobe w1-gpio
sudo modprobe w1-therm
It loads thermometer drivers on GPIO4.
Verify that the 1 Wire device is added
ls /sys/bus/w1/devices/
You should see a number that starts with 28- and w1_bus_master1
In Python code also we load the driver:
os.system(‘modprobe w1-gpio’)
os.system(‘modprobe w1-therm’)
Then we open the sensor driver.
temp_sensor = ‘sys/bus/w1/devices/28-000005e2fdc3/w1_slave’
make sure you change 28-000005e2fdc3 base what you read above after ls command.
and then read sensor data and close the driver.
- On Raspberry Pi Create a directory
- download Test_OneWire ,ThermometerLib , gaugelib then unzip them in that folder
- On Raspberry Pi under Menu Programming select Thonny Python IDE
- from menu file open file Test_OneWire.py
- Connect 1 Wire Device to Raspberry Pi
- run the Python file
download: Test_OneWire ThermometerLib DHT22_DS18b20_fritzing gaugelib