User talk:Emil
Changes to hive.sh
Changes to hive.sh
Have found some changes that should be done in hive.sh
1. Set "LC_NUMERIC" so it works in other country settings than US, the only error is printf output to hivetool.log file 2. Get TEMPER2 to work 3. Check for wrong readings specially from DHT22
- Set LC_NUMERIC to US so printf works
export LC_NUMERIC="en_US.UTF-8"
- Get the date and time
DATE=`date +"%Y-%m-%d %H:%M:%S"`
Get TEMPER2 to work
case "$HIVE_TEMP_SENSOR" in
TEMPerHUM) TEMPerHUM=$(/home/hivetool/temperhum.sh -d $HIVE_TEMP_DEV) set -- junk $TEMPerHUM shift HIVE_TEMP=$1 HIVE_HUMIDITY=$2 if [ -z "$HIVE_TEMP" ] then HIVE_TEMP="NULL" HIVE_HUMIDITY="NULL" fi # Check TEMPer2 /home/downloads/hidapi/hidtest/hidtest-hidraw | grep TEMPer2 > /dev/null if [ "$?" = "0" ] then AMBIENT_TEMP_SENSOR=TEMPER2 TEMPER2_TEMP=$HIVE_HUMIDITY HIVE_HUMIDITY="NULL" fi
;; DHT22) TEMPerHUM=$(nice --20 /usr/local/bin/Seeed_DHT22 $HIVE_TEMP_DEV S) set -- junk $TEMPerHUM shift HIVE_TEMP=$1 HIVE_HUMIDITY=$2 ;; *) HIVE_TEMP="NULL" HIVE_HUMIDITY="NULL" ;;
esac
Check for wrong temp readings
if [ $HIVE_TEMP != "NULL" ] then
HIVE_TEMP=`echo "scale=2; (($HIVE_TEMP*$HIVE_TEMP_SLOPE)+$HIVE_TEMP_INTERCEPT)" | bc`
fi if [ $HIVE_HUMIDITY != "NULL" ] then
HIVE_HUMIDITY=`echo "scale=2; (($HIVE_HUMIDITY*$HIVE_HUMIDITY_SLOPE)+$HIVE_HUMIDITY_INTERCEPT)" | bc`
fi
- Check for totally wrong temp
if [ `echo $HIVE_TEMP | cut -d. -f1` -lt -50 ] then
HIVE_TEMP="NULL"
elif [ `echo $HIVE_TEMP | cut -d. -f1` -gt 100 ] then
HIVE_TEMP="NULL"
fi
- Check for totally wrong Humidity
if [ `echo $HIVE_HUMIDITY | cut -d. -f1` -lt -50 ] then
HIVE_HUMIDITY="NULL"
elif [ `echo $HIVE_HUMIDITY | cut -d. -f1` -gt 150 ] then
HIVE_HUMIDITY="NULL"
fi
TEMPER2 outside settings
- Read outside temp and humidity
case "$AMBIENT_TEMP_SENSOR" in
TEMPerHUM) TEMPerHUM=$(/home/hivetool/temperhum.sh -d $AMBIENT_TEMP_DEV) set -- junk $TEMPerHUM shift AMBIENT_TEMP=$1 AMBIENT_HUMIDITY=$2 if [ -z "$AMBIENT_TEMP" ] then AMBIENT_TEMP="NULL" AMBIENT_HUMIDITY="NULL" fi ;; DHT22) TEMPerHUM=$(nice --20 /usr/local/bin/Seeed_DHT22 $AMBIENT_TEMP_DEV S) set -- junk $TEMPerHUM shift AMBIENT_TEMP=$1 AMBIENT_HUMIDITY=$2 ;; TEMPER2) AMBIENT_TEMP=$TEMPER2_TEMP AMBIENT_HUMIDITY="NULL" ;;
*) AMBIENT_TEMP="NULL" AMBIENT_HUMIDITY="NULL" ;;
esac
Ambient temp checking
if [ "$AMBIENT_TEMP" != "NULL" ]
then
AMBIENT_TEMP=`echo "scale=2; (($AMBIENT_TEMP*$AMBIENT_TEMP_SLOPE)+$AMBIENT_TEMP_INTERCEPT)" | bc`
fi
if [ $AMBIENT_HUMIDITY != "NULL" ] then
AMBIENT_HUMIDITY=`echo "scale=2; (($AMBIENT_HUMIDITY*$AMBIENT_HUMIDITY_SLOPE)+$AMBIENT_HUMIDITY_INTERCEPT)" | bc`
fi
- Check for totally wrong temp
if [ `echo $AMBIENT_TEMP | cut -d. -f1` -lt -50 ] then
AMBIENT_TEMP="NULL"
elif [ `echo $AMBIENT_TEMP | cut -d. -f1` -gt 100 ] then
AMBIENT_TEMP="NULL"
fi
- Check for totally wrong Humidity
if [ `echo $AMBIENT_HUMIDITY | cut -d. -f1` -lt -50 ] then
AMBIENT_HUMIDITY="NULL"
elif [ `echo $AMBIENT_HUMIDITY | cut -d. -f1` -gt 150 ] then
AMBIENT_HUMIDITY="NULL"
fi