Project

General

Profile

Temperature sensor

If you are using the DHT22 sensor, visit Humidity_Sensor to learn how to setup.

The DS1820 and DS1820B are 1-wire equipped temperature sensors. There are two common forms for the Sensor. One is a single probe with three wires, the other comes in a transistor-like form.

You can enable the 1-wire interface by using the sudo rasbi-config utility and enabling it from interfacing options.

Connecting the sensor is easy, as 1-wire will function through any GPIO pin.
Note that you will need to use a 4.7kΩ resistor connected between data and Positive voltage.
Further, make sure you are delivering 5v to the device or it may not function properly.

Here is the wiring diagram for the Probe type device:

And this is for the transistor type:

Note that the pins here are oriented with the FLAT side of the transistor facing you.

Testing 1-wire devices

If you want to test to make sure the device works, run the following commands:

sudo modprobe w1-gpio
sudo modprobe w1-therm

This will setup GPIO pin 4 for data transfer, and setup a thermometer there so make sure it's connected like it is in the block diagrams.

Then go into the folder housing these devices:

cd /sys/bus/w1/devices/

Now, use the ls command to list devices connected to 1-wire. You should see something like this:

00-100000000000  28-04165af9d3ff  w1_bus_master1

This shows there is an active device. If you only see 0's for devices, like this:

00-600000000000  00-a00000000000  00-e00000000000  w1_bus_master1

The Pi cannot see your 1-wire device, check your wiring and try again!

Now go into the directory of your device, it may be unique from the one in the example.

cd 28-04165af9d3ff

Once in this directory, you can run cat w1_slave. The sensor writes to w1_slave file, and so this command will display it, you should see some output similar to this:

d2 01 4b 46 7f ff 0c 10 fc : crc=fc YES
d2 01 4b 46 7f ff 0c 10 fc t=29125

Adding the Device

Bring up your client, and tap the add new device button and select the host you are connected too.

![Select Temperature Sensor](DS1820_And_01.png

Select DS1820

Now select the device, it should automatically select one for you if you have a single device. Select polling interval, and give it a friendly name if you wish.
Tap submit and you will see the device showing you the current temperature.