You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
449 B

2 years ago
#!/bin/bash
2 years ago
response=`/usr/sbin/i2cget -y 1 0x18 0x05 w`
2 years ago
upper_byte=$(($response & 0x00FF))
lower_byte=$(($response & 0xFF00))
let "sign=0"
# test the sign
if [ $(($upper_byte & 0x10)) = 0x10 ]
then
upper_byte=$(($upper_byte & 0x0F))
let "temperature = 256 - (upper_byte * 16 + lower_byte / 4096)"
else
upper_byte=$((upper_byte & 0x0F))
let "temperature = ($upper_byte*100 * 16 + $lower_byte*100 / 4096)"
fi
2 years ago
printf %.2f "$(($temperature))e-2"