Temperature logging using DS18B20


10 posts
by ale36 » Sun Nov 04, 2012 5:15 pm
well i have finished wiring my 2 sensors to my break out board, i can see them from the terminal by:
Code: Select all
sudo modprobe w1-gpio
sudo modprobe w1-therm
cd /sys/bus/w1/devices/
ls

which shows up the two sensor, and can read them individually by:
Code: Select all
# replace xx-xxxxxxxxxxxx with the sensor Number
cd xx-xxxxxxxxxxxx
cat w1_slave


however this is as far as my knowledge goes in terms of scrip, what i want to do is read both sensors at the same time, i also want the temperature to be plotted to a graph through out the course of 12 hours, i want to be able to see real time data and graph from the sensors from my work place if my Raspi is @ home.

Can any one help me to do this i would greatly appreciate it!
Posts: 7
Joined: Tue Oct 30, 2012 11:28 am
by Tafkas » Sun Nov 04, 2012 5:23 pm
You could store the data in an RRDTool database. I do that with my temperature logging. The whole process is described at: http://blog.tafkas.net/2012/10/03/gathering-and-charting-temperatures-using-rrdtool-and-highcharts/
Last edited by Tafkas on Thu Nov 14, 2013 1:23 pm, edited 1 time in total.
Posts: 31
Joined: Sun Sep 16, 2012 11:15 pm
by ale36 » Mon Nov 05, 2012 8:35 am
Thanks i have come across your site before but how does that apply when you are connecting straight into the GPIO headers? i see you are using an USB adapter. :oops:
Posts: 7
Joined: Tue Oct 30, 2012 11:28 am
by malakai » Mon Nov 05, 2012 8:39 am
You could try http://learn.adafruit.com/send-raspberry-pi-data-to-cosm not sure how much code you have to change. Another option is to try the DHT22 tutorial to upload to google docs.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)
User avatar
Posts: 1383
Joined: Sat Sep 15, 2012 10:35 am
by anthonyUK » Mon Nov 05, 2012 9:23 am
The usual method when logging to an RRD is to run a script (containing the command you used for example) to query the values and store them as a variable then update the RRD from the variable.
I'm an absolute beginner with code but manage to use this method with a bit of help from examples people have provided.

E.g. http://ronin-tech.com/Content/pid=26.html
Posts: 27
Joined: Tue May 29, 2012 8:18 am
by ale36 » Mon Nov 05, 2012 1:17 pm
anthonyUK wrote:The usual method when logging to an RRD is to run a script (containing the command you used for example) to query the values and store them as a variable then update the RRD from the variable.
I'm an absolute beginner with code but manage to use this method with a bit of help from examples people have provided.

E.g. http://ronin-tech.com/Content/pid=26.html

are you using the DS18B20 sensors connected to the gpio headers? if so would you be able to show me your code? :roll:
Posts: 7
Joined: Tue Oct 30, 2012 11:28 am
by anthonyUK » Mon Nov 05, 2012 7:13 pm
No, I'm using a USB sensor but the process is the same.
I have just taken delivery of 10 DS18B20s so will be working with them shortly.
You are welcome to my code but it is far less comprehensive than what I linked to.

No one is going to do it for you so drop the attitude and :roll: then you might get some assistance.
Posts: 27
Joined: Tue May 29, 2012 8:18 am
by ale36 » Tue Nov 06, 2012 9:01 am
Thanks is just i haven't got the minimal of idea as where to start, i'll give that site a read once more with more time and see if i can make any sense from it.
Posts: 7
Joined: Tue Oct 30, 2012 11:28 am
by anthonyUK » Tue Nov 06, 2012 11:28 am
No probs Ale36.
You have already made a good start by querying the device and obtaining a reading :D
The code on the link is using Perl so is easier to read and pretty flexible.
It doesn't really matter what script 'language' you use though as they all achieve the same at the end of the day.
Posts: 27
Joined: Tue May 29, 2012 8:18 am
by ale36 » Tue Nov 06, 2012 11:58 am
anthonyUK wrote:No probs Ale36.
You have already made a good start by querying the device and obtaining a reading :D
The code on the link is using Perl so is easier to read and pretty flexible.
It doesn't really matter what script 'language' you use though as they all achieve the same at the end of the day.

so if i was to take parts of the script on the link and put it in Python would it still do the same? or are Perl and Python different all together?
Posts: 7
Joined: Tue Oct 30, 2012 11:28 am