Thursday, August 1, 2013

Raspberry Pi Temperature Sensing.

Thanks to Adafruits Raspberry Pi tutorials on temperature sensing,
and this blog on Raspberry Pi temperature sensing to

I decided to do my own.
I also wanted to store the results locally, so I also saved it to a file.

I used a DS18B20 1-wire temperature sensor
Adafruit T-Cobbler
Breadboard and wires.

I wired it up just like they did in their diagrams.

Add one wire support.
In /boot/config.txt add
I subscribed to and in your profile you can find your API key.

After checking out their tutorials I then wrote a bash script to grab the the temperature, then use curl and JSON to upload it.

Here is the script replace SERIALNUMBERHERE with the serial number of your sensor.
API KEY HERE with your API key, and SENSEFEEDID with your feed id.


sudo modprobe w1-gpio

sudo modprobe w1-therm

cd /sys/bus/w1/devices/SERIALNUMBERHERE/



NOW=$(date +"%d_%m_%Y")

DATA=$(cat w1_slave)





echo $OUTPUT >> /root/output_$NOW.csv

curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"feed_id": SENSEFEEDID,"value": '$DATA3'}' $URL

I then use Cron to schedule a reading every few minutes.

Then back in you can graph it or manipulate it like you want.

No comments:

Post a Comment