I ordered a couple of gadget for my pi a while ago, and they finally came in the mail ( only had to wait 2 months!) Anyways, I ordered a water-proof digital temperature sensor (DS18B20) and a ultrasonic range finder (HC-SR04) to play around with.
So firstly I wanted to get the temperature sensor going. I followed the adafruit tutorial, just to hook the temp sensor to the pi (https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/hardware)
Once it was physically connected, lets check if it works
There should be a listing under there that’s a whole bunch of numbers and letters (the devices ID). In my case it’s
28-0000056e9afb. cd into this folder and cat the file called w1_slave
You should get output like so:
The first like is the checksum, to make sure the device is working correctly, and the second line is the temperature, in degree’s celcius, and to 3 decimal places (13687 = 13.687C)
Now we know the temp sensor is working alright, we can make a nice python script to read it and log it. For this project, I used:
plot.ly. All you need to do it create a free account and your good to go!
weather underground You can create a free ‘dev’ account which gives you 500 API calls a day (This is what I use, the way I have set it up, it will only ever call 288 a day)
Bureau of Meteorology. I used this just so I could compare the temperature with wunderground
Both temperature gathering sites give out the data is JSON format, so it was easy enough to extract the data needed, and then pass it onto plot.ly.
Here’s two of my graphs:
https://plot.ly/~harrysibenaler/4 - this one uses wunderground’s temperature feed, and I’ve also added the temp of the CPU on the rpi
https://plot.ly/~harrysibenaler/5 - this uses BOM’s temperature feed
And here is the python script I used to do this! all you need to do is go through and add your API key for the various sites, and add your location (you may have to play around to find the correct location code for this one) I’ve also set it up to pull my plot.ly key and username out of a file called config.json. I did this because I have multiple scripts using it :)