Home Learning Connect a DS18b20 temperature sensor

Connect a DS18b20 temperature sensor

by shedboy71

Connect a DS18b20 temperature sensor to your Raspberry PI as follows. I used a breakout for this. In this example we will just be using terminal commands

pi and ds18b20 and led_schem

pi and ds18b20 and led_schem

Now you need to enter the following at the command prompt:

sudo nano /boot/config.txt

to open the /boot/config.txt file for editing. Then scroll down to the bottom of the file, and add the line:

dtoverlay=w1-gpio

save the amended file and reboot the Raspberry Pi so that the changes take effect.

Enter the following at a command prompt

 

sudo modprobe w1-gpio
sudo modprobe w1_therm
 
cd /sys/bus/w1/devices/
ls
cat /sys/bus/w1/devices/28-0000027a4334/w1_slave

 

You will see something like the following, the t=20347 is the temperature reading, in this example that is 20.347 celsius

ds18b20 console

ds18b20 console

 

Links
5PCS/LOT DALLAS DS18B20 Temperature Sensor

1Pcs DS18B20 Digital DIY Temperature Sensor Module

You may also like