Note: This project replaces an older tutorial that used the alarm.py program to poll only one sensor. You can still use alarm.py to do this but you will be restricted to one temperature sensor.
This tutorial you will build one or more digital temperature gauges linked to your Raspberry Pi that can be viewed on the WWW or your smart phone.
At the end of the project you will have a WWW dashboard that looks similar to this:
What you need:
Step 1: Build and test the Electronics:
Parts can be purchased from our store: https://ha.privateeyepi.com/store
Figure 1. DS18B20 temperature sensor circuit diagram
If you want to add multiple sensors daisy chain the middle pin of the sensors. This will work because every DS18B20 sensor has a unique ID that is used to differentiate the signals coming from the sensors See Figure 2 below.
Figure 2. Multiple DS18B20 temperature sensor circuit diagram
Once built, follow the following steps to test that it is working:
Log in to your Raspberry Pi
At the prompt pi@raspberrypi / $
sudo modprobe w1-gpio
sudo modprobe w1-therm
09/02/2015 - The recent move to kernel 3.18 that supports Raspberry Pi 2 has caused a number of issues, one of which affects the working on the one wire interface used by this sensor. If you see an empty directory after the above ls command then you need to edit the boot config file and insert some lines, and then re-boot your Rpi.
sudo nano /boot/config.txt
Page down to the bottom of the file and paste or type in these two lines
# 1-wire settings
Press CTRL-X Y ENTER to save exit.
Reboot your Pi
Repeat steps above this red section.
You will see a listing of the current directory. There should be a directory that is the serial number of your temperature gauge. The serial number of my thermometer 28-0000040be5b6, but every one will be unique. Make a note of yours as you will need it later in step 4. If you have multiple sensors there will be multiple directories listed.
If you don't see a directory with lots of numbers and letters like the one above then:
If you do see the directory then type cd followed by the directory name:
You will now see a dump of the w1_slave file that contains the temperature data in celcius (refer Figure 3). 20812 is 20.812 degrees celcius. The dashboard does support a Fahrenheit setting that we will cover later if that is your preference.
Step 2: Register user and password
If you have not yet registered a user and password with PrivateEyePi follow the following steps, otherwise proceed to Step 3. Note this is a completely free service and has no trial period.
Step 3: Configure GPIO 4
This configuration tells the system that you have connected a temperature gauge to GPIO 4 and to display it on your dashboard.
If you have multiple sensors then repeat this step and add other GPIO and Locations settings for each sensor. In Figure 6 I have configured three sensors, one for basement, ground floor and first floor. At least one must have a Number of 7, and the others can have any number you choose. Choose a number that does not conflict with any of the GPIO number of the Raspberry Pi. I have used 88 and 89. In step 4 you will use these numbers to associate the sensors on the Raspberry Pi with the temperature gauges on the dashboard.
Figure 6. Multiple temperature gauge settings
Step 4: Install/Upgrade your PrivateEyePi software
Follow the following link to the tutorial -> Install PrivateEyePi Software
Step 4: Configure the program
sudo nano globals.py
Page down until you see the DallasSensorNumber settings (as per Figure 8). You need to place the GPIO number that you configured in step 3 (Figure 5) in between the brackets (e.g. DallasSensorNumber(7) ), replacing the numbers you see in the file with your own numbers. If you have multiple sensors then repeat the line with the other GPIO numbers (as per Figure 8). Then do the same for the directory name replacing the directory names you see with your directory names that you made a note of in step 1.
If you want your temperature to be display in Fahrenheit instead of Celsius then find the line that says Farenheit=False and change it to Farenheit=True (refer the top two lines of Figure 8).
Then press Y to save the file
Step 5: Run dallas.py program
pi@raspberrypi / $
sudo python dallas.py
If you are getting errors or problems see here for diagnostic steps.
Step 6: View your dashboard