Home... Help... Search... Computers... OurHouse... Science...
Home Temperature Monitoring Using Maxim-Dallas DS18S20 1-Wire Sensors
November 2013 - disabled as I have a "new" server (an old laptop) that does not have a serial port. I have an Arduino Nano setup to send data to the server via USB, with a trial DHT11 sensor, soon to be 3 x DHT22s (for inside, outside and subfloor temperature and humidity). You can see it here
Being a retired engineer with a long interest in matters scientific and in low energy housing, I have finally begun what I long wanted to do, to set up a temperature monitoing system in my house.
This is a temporary arrangement till I find time for more sensors, and a permanent interface to my server PC.
So far there is are just three temperature sensors:
The outdoor sensor, just on the end of a bit of phone cable, secured with heat-shrink tubing and a stick on clip to the underside of my electrical meter and fuse box. |
.. and a close up of the sensor |
Here you can see the sub-floor sensor on the solderless breadboard that I used to trial the serial/RS232 interface. |
There are a number of circuit pages out there; I used this one from the Martybugs web-site
I used the non-parasitic power version, as it allows the sensors to deliver better accuracy.
Scripts:
The monitoring is done as part of the power plotting master script, plotPower1.sh shell script, called from cron every 10 minutes
m h dom mon dow command /10 * * * * ~/monitor/plotPower1.sh >> ~/monitor/plotPower1.log 2>&1
Here is plotPower1.sh (edited to remove security bits;)
#!/bin/sh # get the latest house power Kw figures and use it to plot with mrtg # also add to a history file for any desired later processing (just in case!) # altered 6 March 2012 to use direct ENVI pickup from this linux machine # data is now in the powercurr.txt file cd ~/monitor #check to see if the CurrentCost ENVI data receiving script is running if [ ! $(pidof -x cc6.pl) ]; then echo "cc6 is NOT running" echo "starting cc6.pl" nohup ./cc6.pl > ./cc6.log 2>&1 & else echo "cc6 is running" cat powercurr.txt | tr '<>' ' ' > powercurr.dat awk -f getAverage.awk powercurr.dat > latestHousePower.txt tail -1 latestHousePower.txt > latestHousePower.dat echo `date` "latestHousePower.dat file just written" awk '{print strftime(systime()),$0}' latestHousePower.dat >> latestHousePower.hist now get current power so we can keep a running total of cost CURRPOWER=`awk '{print $4}' latestHousePower.dat` # not inc. HWS awk -f calcPowerCost.awk -v currpower=$CURRPOWER TOUhours.lis > latestCosts.dat cost for past 10 minute period is now in latestCosts.dat for flat rate and time of use rates tail -1 latestCosts.dat >> latestCosts.hist # we might need a history file now work out the cumulative costs (flat and tou) cat accumCosts.dat latestCosts.dat > accumCosts.tmp awk -f accumCosts.awk accumCosts.tmp > accumCosts.dat awk -f accumCosts.awk accumCosts.tmp >> accumCosts.hist reset the input file from the ENVI CC128 echo "lines in powercurr.txt: " `wc -l powercurr.txt` cat powercurr.txt >> powercurr.hist cat /dev/null > powercurr.txt cat latestHousePower.txt >> housePower.hist echo `date` "===========================" >> housePower.hist get digitemp data for plotting; configs in housepower.cfg as temp digitemp_DS9097 -s /dev/ttyS0 -a -l ~/monitor/digitemp.log plot using MRTG env LANG=C mrtg housepower.cfg fi exit
Here are the MRTG config files
Interval: 10 WorkDir: /home/steve/monitor/mrtg/ Target[envi-t]: `~/monitor/temperature2mrtg.sh` Options[envi-t]: growright,integer,gauge Colours[envi-t]: springgreen#00ee76,color2#000000,Color3#121212,Color4#191970 MaxBytes[envi-t]: 30 AbsMax[envi-t]: 40 WithPeak[envi-t]: ymw UnScaled[envi-t]: ymwd YLegend[envi-t]: DegC ShortLegend[envi-t]: C Legend1[envi-t]: T LegendI[envi-t]: Indoor Temperature LegendO[envi-t]: Subfloor Temperature Title[envi-t]: Room Temperature at the CurrentCost ENVI CC128 Monitor Station PageTop[envi-t]: <h1>Room Temperature at the CurrentCost ENVI CC128 Monitor Station</h1> Note: time is Australian Eastern Standard Time<br> Target[envi-O]: `~/monitor/temperatureIO2mrtg.sh` Options[envi-O]: growright,integer,gauge Colours[envi-O]: springgreen#00ee76,color2#000000,Color3#121212,Color4#191970 MaxBytes[envi-O]: 40 AbsMax[envi-O]: 60 WithPeak[envi-O]: ymw UnScaled[envi-O]: ymwd YLegend[envi-O]: DegC ShortLegend[envi-O]: C Legend1[envi-O]: T LegendI[envi-O]: Indoor Temperature LegendO[envi-O]: Outdoor Temperature Title[envi-O]: Room Temperature at the CurrentCost ENVI CC128 Monitor Station PageTop[envi-O]: <h1>Room Temperature at the CurrentCost ENVI CC128 Monitor Station</h1> Note: time is Australian Eastern Standard Time<br> ================ #!/bin/sh # extracts temperature at the ENVI monitor from single rate tariff file and prepares for MRTG # added experimental temperature collection of subfloor via digitemp - 10/11/12 TEMP=`awk '{print int($3+0.5)}' ~/monitor/latestHousePower.dat` UPTIME=0 LABEL="Room Temperature - Degrees C" SUBTEMP=`fgrep "Sensor 1" ~/monitor/digitemp.log |tail -1 | awk '{print int($7+0.5)}'` echo $TEMP echo $SUBTEMP echo $UPTIME echo $LABEL ========== #!/bin/sh # extracts temperature at the ENVI monitor from single rate tariff file and prepares for MRTG # added experimental temperature collection of outdoor via digitemp - 17/11/12 TEMP=`awk '{print int($3+0.5)}' ~/monitor/latestHousePower.dat` UPTIME=0 LABEL="Room Temperature - Degrees C" OUTTEMP=`fgrep "Sensor 0" ~/monitor/digitemp.log |tail -1 | awk '{print int($7+0.5)}'` echo $TEMP echo $OUTTEMP echo $UPTIME echo $LABEL ============= #digitemp.log Mar 29 18:30:08 Sensor 0 C: 18.50 F: 65.30 Mar 29 18:30:09 Sensor 1 C: 20.25 F: 68.45 Mar 29 18:40:08 Sensor 0 C: 18.44 F: 65.19 Mar 29 18:40:09 Sensor 1 C: 20.19 F: 68.34 Mar 29 18:50:09 Sensor 0 C: 18.62 F: 65.53 Mar 29 18:50:10 Sensor 1 C: 20.19 F: 68.34 Mar 29 19:00:08 Sensor 0 C: 18.50 F: 65.30 Mar 29 19:00:09 Sensor 1 C: 20.19 F: 68.34 Mar 29 19:10:08 Sensor 0 C: 18.44 F: 65.19 Mar 29 19:10:09 Sensor 1 C: 20.19 F: 68.34 ========== #powercurr.txt <msg><src>CC128-v1.18</src><dsb>00911</dsb><time>16:40:33</time><tmpr>21.3</tmpr> <sensor>0</sensor><id>02882</id><type>1</type><ch1><watts>00556</watts></ch1> <ch2><watts>00004</watts></ch2></msg>
Home... Help... Search... Computers... OurHouse... Science...
This page tardus.net/temperatureMonitor.html Last refreshed: 04 Oct 2023
Contact me, "Tardus" Copyright powered by txt2tags