[nmglug] scripting locate question

a a at kaluta.us
Sat Nov 22 06:01:02 PST 2014


Good morning:

Where would I put "sensor_read.sh".


TERMINAL READING,ONE TIME TEMP:

a at a-laptop:/mnt/1-wire/10.BC0BE0010800$ printf "%s\n" `cat temperature`
16.5

TERMINAL READING REPEAT USING CRON.

./sensor_read.sh


information is referenced:
http://www.technotes.se/?p=26

THE SCRIPT AS FOUND REFERENCED ABOVE:

"sensor_read.sh

#!/bin/sh

DB_DIR=$1
SENSOR_FILE=$2

sensor_value=`cat $SENSOR_FILE | awk '{print $1; }'`
timestamp=`date +%H:%M`
date=`date +%Y-%m-%d`

echo "Time: $date $timestamp"
echo "Sensor value: $sensor_value"
echo "$timestamp $sensor_value" >> $DB_DIR/$date

Together with a cron job the PC can take samples every 5th minute every 
day of the year (five minute snapshots is probably enough resolution for 
most uses):

*/5 * * * *     /usr/bin/sensor_read.sh /var/sensors/indoor_temp /mnt/1-wire/26.946E8C000000/temperature
*/5 * * * *     /usr/bin/sensor_read.sh /var/sensors/hygrometer /mnt/1-wire/26.946E8C000000/humidity
*/5 * * * *     /usr/bin/sensor_read.sh /var/sensors/outdoor_temp /mnt/1-wire/10.D5A392010800/temperature "

Thanks, Anthony K


More information about the nmglug mailing list