PDA

Bekijk de volledige versie : Is it possible to install 1wire support on Oleg's firmware



zerg
26-04-2009, 23:09
Hello,
I just bought WL500gp V1 router. My initial idea was to use openwrt. I liked it becasue there are packages with OWFS to OpenWRT distribution. I want to use it for termal monitoring of my house - http://owfs.sourceforge.net/WRT54G.html#firmware.

do you know if this can be used also with Oleg's firmware ?

I have linux knowledge, but am not regular users, so I have to invest time in reading and setting the system. Before doing this I will appriciate advice deom your side to decide which firmware to use - Oleg's(becasue it seems to be easier) or openwrt(1wire packages and flexible). 1wire is very important for me ! So If there is a chance to make it work on Oleg's firmware, my choice will be easier !

Thanks in advance !

kscott9
27-07-2009, 18:44
Didn't find owfs packages perse but did successfully find DIGITEMP in the oleg respositories [http://www.digitemp.com/] and used it successfully to read from a single 1wire temp module and store data in a rrdtool data base. It takes nearly 10 seconds to read from the single sensor but you going to have to read from many sensors with much lower time resolution.
Obviously had to first install the rrdtool packages (Round Robin Database), perl, and Bash.
Hardware is a WL-HDD with a 6Gb harddrive configured to load ipkg packages onto the harddrive under /opt . I am using a USB to serial converter (pl2303 driver) and the serial 1wire master).

I used the following script:

#!/opt/bin/bash
#get current utc time and create a quick database
utc=`date +%s`
rrdtool create quick.rrd -s $utc --step 10 DS:quick:GAUGE:20:0:125 RRA:AVERAGE:0.5:6:60

#infinite loop
a=0
while [ "$a" == 0 ]; do
reply=`digitemp_DS9097U -a -s /dev/usb/tts/0 | grep Sensor`
# digitemp output is of form: Jul 26 16:55:19 Sensor 0 C: 28.06 F: 82.51
utctime=`date +%s`
temp=`echo $reply | awk '{print $9}'`
echo $reply $utctime $temp >> quick.txt
echo $reply $utctime $temp

# utc current time:temp
rrdtool update quick.rrd $utctime:$temp
# sleep until the next 10 sec
perl -e 'sleep 10 - time % 10'
done # end of while loop

zerg
26-09-2009, 19:25
Thanks for the reply kscott9.

I also am using DIGITEMP . I have 6 temperature sensors(DS18B20) and one USB to 1-Wire Adapter (DS9490R ). As part of the Digitemp package there is digitemp_DS2490 command, which can be used to query the sensors,when the 1-wire devices are connected with USB-1-wire adapter.
I have used cron, to schedule collection each minute. For 6 sensors it needs 5-10 seconds. The load on the router is negligible. After collection, I use rrd to store and graph ecah sensor. I create separate database for each sensor.
This is the script I run each minute to collect data from termo sensors.



#!/bin/sh

log="/tmp/var/log/temperature.log"
err_log="/tmp/var/log/digitemp.log"
home="/opt/var/lib/rrd/digitemp"
date=`date "+%Y-%m-%d %H:%M:%S"`

#Check if we have Digitemp configuration file. If not start "digitemp -i"
if [ ! -f ${home}/.digitemprc ]; then
/opt/bin/digitemp_DS2490 -i -c ${home}/.digitemprc
echo "$date Creating new Digitemp configuration file ($home/.digitemprc)" >>$err_log
fi

#Read the temperature and store it into a variable t
t=`/opt/bin/digitemp_DS2490 -q -a -o"%R %4.1C" -c ${home}/.digitemprc`

#Teake the number of sensore and assign it to varaible c
c=`echo "$t" | wc -l`

#Check if we have values from all sensors. Current number of sensors is 6
if [ $c -ne 6 ]; then
echo "$date ERROR ! Missing Value. Only $c values were detected ! Wrong number of sensors." >> $err_log
echo "$t" >> $err_log
fi

# Loop, read each valua and add it to the database. Odd values are sensor ID. Even values are temperatures
i=1
for LINE in $t ; do
let "odd = $i % 2"
if [ $odd -eq 1 ]; then
Sensor=$LINE
else
Temperature=$LINE

# hertbeat on every 60s ( 1min.)
# 1:1500 -> 1500 sample per every 1min -> 25h ( 1 day + 1 hour )
# 5:2160 -> 2100 sample per every 5min -> 180h ( 1 week + 0.5 day )
# 15:3024 -> 3024 sample per every 15min -> 756h ( 1 month + 0.5 day )
# 240:2190 -> 2190 sample per every 4h -> 8760h ( 365 days )
if [ ! -e ${home}/${Sensor}.rrd ]; then
echo "Creating new database for Sensor $Sensor " >> $err_log
/opt/bin/rrdtool create ${home}/${Sensor}.rrd \
--step 60 \
DS:temp:GAUGE:100:-40:100 \
RRA:AVERAGE:0.5:1:1500 \
RRA:AVERAGE:0.5:5:2160 \
RRA:AVERAGE:0.5:15:3024 \
RRA:AVERAGE:0.5:240:2190
fi
#Updating the temperature
/opt/bin/rrdupdate ${home}/${Sensor}.rrd N:${Temperature}
fi
let i=i+1
done


I have one problem, there are 10-20 times each 24 hours, when some of the sensors is not returning value, that is why I'm checking for number of sensors each time and log error for this in the error log file.

I read a little bit more regarding owfs support and it seems to need Fuse. There is a problem with fuse on Oleg's firmware. It seems to be the kernel version.
http://wl500g.info/showthread.php?t=19883&highlight=Fuse
http://wl500g.info/showthread.php?t=11081&highlight=Fuse

There is new version based on Oleg's firmware called 1.9.2.7-d from enthusiasts, but I haven't tested it yet. So it seems that with Oleg's latest version 1.9.2.7-10 we don't have any other option than using Digitemp.

wpte
27-09-2009, 21:36
For 6 sensors it needs 5-10 seconds. The load on the router is negligible.

that long?
requesting and getting the result from an AD conversion should only take a few microseconds:confused:

zerg
29-09-2009, 10:17
Hi,

I created short script to measuere the time needed for reading 6 temperature sensors:


date
digitemp_DS2490 -q -a
date


Output is :
Tue Sep 29 01:31:47 EETDST 2009
Sep 29 01:31:49 Sensor 0 C: 21.75 F: 71.15
Sep 29 01:31:50 Sensor 1 C: 13.75 F: 56.75
Sep 29 01:31:51 Sensor 2 C: 28.69 F: 83.64
Sep 29 01:31:53 Sensor 3 C: 22.63 F: 72.72
Sep 29 01:31:54 Sensor 4 C: 21.38 F: 70.47
Sep 29 01:31:55 Sensor 5 C: 20.25 F: 68.45
Tue Sep 29 01:31:55 EETDST 2009

As you can see it takes some time - average is 1 second per sensor. Total -8 seconds.