Initial fork + minor fixes for BMP085 (mBar output) + shell scripts for ADS1115 and...
[i2c-telemetry.git] / i2cget_bmp180.example
1 #!/bin/sh
2 #
3 # More info: http://cyber-place.ru/showpost.php?p=7797&postcount=82
4
5 RAWTEMP=$(i2cget -y 0 0x40 0xe3 w)
6 RAWHUMI=$(i2cget -y 0 0x40 0xe5 w)
7
8 if (echo "$RAWTEMP"| grep -Eq '0x[0-9a-f]{4}'); then
9    HEXORDERED=$(echo "$RAWTEMP"|sed -r 's/0x([0-9a-f]{2})([0-9a-f]{2})/0x\2\1/')
10    DECRAW=$(($HEXORDERED))
11    echo $DECRAW | awk -v tem=${DECRAW} '{ printf "%.2f stC\n", -46.85+((tem*175.72)/65536)}'
12 fi
13 if (echo "$RAWHUMI"| grep -Eq '0x[0-9a-f]{4}'); then
14    HEXORDERED=$(echo "$RAWHUMI"|sed -r 's/0x([0-9a-f]{2})([0-9a-f]{2})/0x\2\1/')
15    DECRAW=$(($HEXORDERED))
16    echo $DECRAW | awk -v hum=${DECRAW} '{ printf "%.2f %%RH\n", -6+((hum*125)/65536)}'
17 fi