![]() |
Optware.DigiTemp HistoryHide minor edits - Show changes to markup June 03, 2008, at 09:36 PM
by -- body/html
Added lines 234-235:
</body> </html> June 03, 2008, at 09:34 PM
by -- RRD backup
Changed lines 140-142 from:
test -e /tmp/sensor-3.rrd || cp /opt/var/lib/rrd/digitemp/sensor-3.rrd /tmp to:
test -e /tmp/sensor-2.rrd || cp /opt/var/lib/rrd/digitemp/sensor-2.rrd /tmp Changed lines 180-181 from:
It should be noted that to:
It should be noted that
reboot() { cp /tmp/rssi-*.rrd /opt/var/lib/rrd/rssi;
cp /tmp/sensor-*.rrd /opt/var/lib/rrd/digitemp;
ifdown wan 2>&1 >/dev/null ; /sbin/reboot; }
June 03, 2008, at 09:18 PM
by -- Example scripts for client/server temperature graphig
Changed lines 14-232 from:
Details about 1-Wire RS-232 interface and general informations about 1-wire can be found on http://pdfserv.maxim-ic.com/en/an/tb1.pdf to:
Details about 1-Wire RS-232 interface and general informations about 1-wire can be found on http://pdfserv.maxim-ic.com/en/an/tb1.pdf Temperature graphing server and remote clientsOne can create http server without PHP support to display temperatures. Good alternative to PHP is to use shell CGI programs that can be executed by any http server including busybox_httpd. Server provides two functionalities:
ClientsClients can be other embeded routers with digitemp installed. Client can also be located on server. /opt/etc/init.d/S98digitemp client script that sends temperature by wget looks like:
#!/bin/sh
PIDFILE=/var/run/digitemp.pid
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin
exit 0
start ()
{
if [ -f $PIDFILE ]; then
echo "Warning : $PIDFILE still present. Unclean shutdown ?"
kill -9 `cat $PIDFILE` 2>/dev/null
rm -f $PIDFILE 2>/dev/null
killall digitemp
fi
cd /opt/etc
echo -n "Starting digitemp... "
if [ ! -f /opt/etc/.digitemprc ]; then
digitemp -i
fi
digitemp_DS2490 -a -q -o"%4.1C" -n 0 -d 300 | while true; do
read t3;
if [ "$t3" != "Found DS2490 device #1 at 003/002" ]; then
wget -q "http://192.168.1.1/cgi-bin/t.cgi?sensor=3;value=$t3" -O - >/dev/null 2>&1
fi
done &
echo $! > $PIDFILE
echo "done"
}
stop ()
{
if [ -f $PIDFILE ]; then
kill -9 `cat $PIDFILE` 2>/dev/null
rm -f $PIDFILE 2>/dev/null
killall digitemp
fi
echo "done"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
echo "Usage: $0 (start|stop|restart)"
exit 1
;;
esac
In this client script the following things can noted:
./digitemp -a -q -o"%4.1C" -n 0 -d 300 | while true; do
read t1;
wget -q "http://192.168.1.1/cgi-bin/t.cgi?sensor=2;value=$t1" -O - > /dev/null 2>&1
done &
RRDatabase? script for serving client callsThis script is located in
#!/bin/sh
#
# Expected sensor update every 5 minutes
#
echo "Content-type: text/plain"
echo ""
sensor="none"
eval ${QUERY_STRING}
if [ ${sensor} != 3 -a ${sensor} != 2 ]; then
echo "Invalid sensor number"
exit 2
else
echo "Accepted sensor ${sensor} with value ${value}"
fi
test -d /opt/var/lib/rrd/digitemp || mkdir -p /opt/var/lib/rrd/digitemp
if [ ! -e /opt/var/lib/rrd/digitemp/sensor-${sensor}.rrd ]; then
/opt/bin/rrdtool create /opt/var/lib/rrd/digitemp/sensor-${sensor}.rrd \
DS:temp:GAUGE:600:-40:100\
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797
fi
test -e /tmp/sensor-${sensor}.rrd || cp /opt/var/lib/rrd/digitemp/sensor-${sensor}.rrd /tmp
test -e /tmp/sensor-3.rrd || cp /opt/var/lib/rrd/digitemp/sensor-3.rrd /tmp
/opt/bin/rrdupdate /tmp/sensor-${sensor}.rrd N:${value}
end=$(/opt/bin/rrdtool last /tmp/sensor-${sensor}.rrd )
e=$((end/7200*7200))
s=$((e-86400))
min=$(/opt/bin/rrdtool fetch /tmp/sensor-${sensor}.rrd MIN -s $s -e $e -r 7200 |
awk '/[0-9]+: [-0-9.e+]+/ {if (!n) {min=$2; n++; next}; if ($2 < min){min =$2};}
END{printf("%.1f\n", min)}')
max=$(/opt/bin/rrdtool fetch /tmp/sensor-${sensor}.rrd MAX -s $s -e $e -r 7200 |
awk '/[0-9]+: [-0-9.e+]+/ {if (!n) {max=$2; n++; next}; if ($2 > max){max =$2};}
END{printf("%.1f\n", max)}')
echo -e "${value}\n${min}\n${max}" > /tmp/sensor-${sensor}.stat
[ $((end%86400)) = 0 ] && cp /tmp/sensor-${sensor}.rrd /opt/var/lib/rrd/digitemp/
if [ ${sensor} = 2 ] ; then
PREJETO=$(date +%H:%M)
echo "var prejeto='${PREJETO}';" > /tmp/temperatura.js
echo "var temperatura='${value}';" >> /tmp/temperatura.js
fi
#set > /tmp/digitemp.log
Script assumes that valid sensor numbers are 2 and 3. At the end of the script one can also notice
that this script after it updates a database it also creates files for 24h sensor statistics and saves if into /tmp
directory for fetching this
<script type="text/javascript" src="temperatura.js"> </script>
Temperature at <script type="text/javascript"> <!--
document.writeln(prejeto + " uri : ");
document.writeln( temperatura + "°C");
// -->
</script>
It should be noted that RRD graphing with rrdcgiThhe following
#!/opt/bin/rrdcgi
<html>
<head>
<title>Vreme v Begunjah</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link href="/vreme/default.css" rel="stylesheet" type="text/css">
<RRD::SETENV LANG sl_SI>
</head>
<body>
<h1>Potek temperature v Begunjah in Topolu</h2>
<form>
<button type=submit name=range value="">Danes</button>
<button type=submit name=range value="-1day">Dva dni</button>
<button type=submit name=range value="-1week">Zadnji teden</button>
<button type=submit name=range value="-1month">Zadnji mesec</button>
<button type=submit name=range value="-1year">Eno leto</button>
</form>
<RRD::GRAPH /tmp/digitemp.png --title="Temperatura"
--width 640 --height 200 --slope-mode --start -1day<RRD::CV range>
--imginfo '<IMG SRC=/vreme/%s WIDTH=%lu HEIGHT=%lu ALT="RRD prikaz">'
DEF:beg=/tmp/sensor-3.rrd:temp:AVERAGE
DEF:top=/tmp/sensor-2.rrd:temp:AVERAGE
COMMENT:" "
COMMENT:" Min Max Povp Zadnja\n"
LINE1:beg#00a000:"Begunje"
GPRINT:beg:MIN:" %5.2lf C"
GPRINT:beg:MAX:" %5.2lf C"
GPRINT:beg:AVERAGE:" %5.2lf C"
GPRINT:beg:LAST:" %5.2lf C\n"
LINE1:top#a000a0:"Topol "
GPRINT:top:MIN:" %5.2lf C"
GPRINT:top:MAX:" %5.2lf C"
GPRINT:top:AVERAGE:" %5.2lf C"
GPRINT:top:LAST:" %5.2lf C\n"
>
<p>Last temperature update at: <RRD::TIME::LAST /tmp/sensor-3.rrd "%A %e. %B %Y ob %H:%M"> </p>
<p>MIN, MAX and AVG temperatures shown are for displayed rande</p>
<p>Buttons does not work with Windows Internet Explorer 7, although they are correctly HTML coded.
Firefox works as intended!</p>
One can set local language for graphs created as shown with --- October 01, 2006, at 09:27 PM
by -- 1-Wire info
Added lines 13-14:
Details about 1-Wire RS-232 interface and general informations about 1-wire can be found on http://pdfserv.maxim-ic.com/en/an/tb1.pdf December 28, 2005, at 08:36 AM
by --
Changed line 12 from:
bus or search the Maxim website for the DS9490 USB to 1-wire adapter based on the DS2490 USB to 1-wire bridge chip. to:
bus or search the Maxim website for the DS9490 USB to 1-Wire adapter based on the DS2490 USB to 1-Wire bridge chip. December 28, 2005, at 08:36 AM
by --
Changed lines 1-29 from:
digitemp From a mail from Otmar Spoettel: i'll use my NSLU2 to read temperature sensors, they are connected on the serial interface from the NSLU2. There exists a project for a 1-Wire Temperature sensor PCB. (reads and store temperature from many temperature sensors in a file. Also you can display the temperatures in RRD) See http://www.digitemp.com/ Besides temperature there is also support for other sensors (humidity, counters, ...) DigiTemp supports the following devices:
See http://www.lecad.uni-lj.si/~leon/other/wlan/wrt54ow/ for building serial interface for 1-wire bus or search www.maxim-ic.com for DS9490 USB to 1-wire adapter based on DS2490? USB to 1-wire bridge. to:
DigiTemp is a Linux package for interfacing to Maxim/Dalsemi 1-Wire and iButton devices. It supports reading from the following devices:
See Leon Kos' page for building a serial interface for the 1-Wire bus or search the Maxim website for the DS9490 USB to 1-wire adapter based on the DS2490 USB to 1-wire bridge chip. December 28, 2005, at 06:30 AM
by --
Changed line 23 from:
See http://www.lecad.uni-lj.si/~leon/other/wlan/wrt54ow for building serial interface for 1-wire to:
See http://www.lecad.uni-lj.si/~leon/other/wlan/wrt54ow/ for building serial interface for 1-wire December 28, 2005, at 06:27 AM
by --
Changed lines 24-29 from:
to:
December 28, 2005, at 06:11 AM
by -- Added interface notes
Changed line 15 from:
to:
Changed lines 23-26 from:
to:
December 28, 2005, at 06:09 AM
by --
Changed line 5 from:
i'll use my NSLU2 to read temperature sensors, they are cnnected on the
to:
i'll use my NSLU2 to read temperature sensors, they are connected on the
Added lines 11-26:
Besides temperature there is also support for other sensors (humidity, counters, ...) DigiTemp supports the following devices: November 23, 2005, at 02:18 PM
by -- Added digitemp page
Added lines 1-10:
digitemp From a mail from Otmar Spoettel: i'll use my NSLU2 to read temperature sensors, they are cnnected on the serial interface from the NSLU2. There exists a project for a 1-Wire Temperature sensor PCB. (reads and store temperature from many temperature sensors in a file. Also you can display the temperatures in RRD) See http://www.digitemp.com/ |