shell doesn't support floats so use int values for test
[rpi-ds18b20] / w1-ds18b20-influx.sh
index 37c134e..9908150 100755 (executable)
@@ -6,8 +6,9 @@ influx=/dev/shm/temp.influx
 :> $influx
 
 ls /sys/bus/w1/devices/w1_bus_master*/*-*/w1_slave | while read path ; do
-       temp=$( cat $path | grep t= | cut -d= -f2  | awk '{ printf "%.3f\n", $1 / 1000 }' )
-       if [ $temp != 85 ] ; then # 85 is error
+       temp=$( cat $path | grep t= | cut -d= -f2 )
+       if [ $temp -ne 85000 ] ; then # 85 is error
+               temp=$( echo $temp | awk '{ printf "%.3f\n", $1 / 1000 }' )
                id=$( echo $path | cut -d/ -f 7 )
                echo "ac_temp,dc=a125,sensor=$id temperature=$temp" >> $influx
                echo $temp > /dev/shm/ds18b20.$id