should be working now
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
# -*- sh -*-
|
||||
# -*- bash -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
433mhz - Plugin to capture readings from wireless sensors via serial
|
||||
1wire - Plugin to capture readings from 1wire sensors on raspberry pi
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
@@ -32,8 +32,7 @@ if [ "$1" = "autoconf" ]; then
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Wireless temperature sensor readings'
|
||||
echo 'graph_title 1wire sensor readings'
|
||||
echo 'graph_args --base 1 -l 0 '
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_vlabel °C'
|
||||
@@ -45,19 +44,22 @@ if [ "$1" = "config" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SENSORS=()
|
||||
|
||||
CMD="for f in $(find -L /sys/bus/w1/devices/ -maxdepth 2 -name temperature); do s=${f%/*}; s=${s##*-}; v=$(cat $f); echo "${s} ${v}"; done"
|
||||
FILES=$(find -L /sys/bus/w1/devices/ -maxdepth 2 -name temperature)
|
||||
for f in $FILES
|
||||
do
|
||||
s=${f%/*}
|
||||
s=${s##*-}
|
||||
v=$(cat $f)
|
||||
|
||||
SENSORS+=("${s} ${v}")
|
||||
done
|
||||
|
||||
IFS=$'\n'
|
||||
SENSORS=( $(eval $CMD) )
|
||||
|
||||
echo $SENSORS
|
||||
|
||||
IFS=' '
|
||||
for ROW in "${SENSORS[@]}"; do
|
||||
ENTRY=( $ROW )
|
||||
SENSOR=${ENTRY[0]}
|
||||
VALUE=${ENTRY[1]}
|
||||
VALUE=${ENTRY[1]/#[0-9][0-9]/&.}
|
||||
|
||||
# Overrides SENSOR - Example: env.sensor_0_0 Batterie
|
||||
ENV_SENSOR_VAR_NAME="alias_${SENSOR}"
|
||||
@@ -69,7 +71,3 @@ for ROW in "${SENSORS[@]}"; do
|
||||
echo "${SENSOR}.value ${VALUE}"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
#echo "Vorratskammer.value $TEMP"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# -*- sh -*-
|
||||
# -*- bash -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
#!/bin/bash
|
||||
# -*- bash -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
@@ -32,7 +32,6 @@ if [ "$1" = "autoconf" ]; then
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Power'
|
||||
echo 'graph_args --base 1 -l 0 '
|
||||
echo 'graph_scale no'
|
||||
@@ -45,22 +44,26 @@ if [ "$1" = "config" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ROUNDS=5
|
||||
ROUNDS=3
|
||||
|
||||
VOLTAGE=0
|
||||
CURRENT=0
|
||||
POWER=0
|
||||
|
||||
for i in $(seq ${ROUNDS}); do
|
||||
RESULT=$(/usr/bin/ina219)
|
||||
#ROW="12204mV 184.3mA"
|
||||
ROW=$(/usr/bin/ina219)
|
||||
ENTRY=( $ROW )
|
||||
|
||||
VOLTAGE_RAW=${ENTRY[0]%mV}
|
||||
CURRENT_RAW=${ENTRY[1]%mA}
|
||||
#echo "Voltage: ${VOLTAGE_RAW}"
|
||||
#echo "Current: ${CURRENT_RAW}"
|
||||
|
||||
VOLTAGE_RAW=$(echo $RESULT | /bin/sed 's/\([0-9]\+\)mV \+\([0-9\.]\+\)mA/\1/')
|
||||
VOLTAGE=$(echo "scale=3; $VOLTAGE+$VOLTAGE_RAW" | /usr/bin/bc)
|
||||
|
||||
CURRENT_RAW=$(echo $RESULT | /bin/sed 's/\([0-9]\+\)mV \+\([0-9\.]\+\)mA/\2/')
|
||||
CURRENT=$(echo "scale=3; $CURRENT+$CURRENT_RAW" | /usr/bin/bc)
|
||||
|
||||
done
|
||||
#exit 1
|
||||
|
||||
VOLTAGE=$(echo "scale=3; $VOLTAGE/$ROUNDS" | /usr/bin/bc)
|
||||
CURRENT=$(echo "scale=3; $CURRENT/$ROUNDS" | /usr/bin/bc)
|
||||
|
||||
Reference in New Issue
Block a user