BARRAUX Arthur
2 years ago
1 changed files with 15 additions and 4 deletions
@ -1,6 +1,17 @@ |
|||
#!/bin/bash |
|||
|
|||
response = `i2cget -y 1 0x18 0x05 w` |
|||
upper_byte = $(($response & 0x00FF)) |
|||
echo $response |
|||
echo $upper_byte |
|||
response=`i2cget -y 1 0x18 0x05 w` |
|||
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 |
|||
printf %.2f "$(($temperature))e-2" |
|||
echo |
|||
|
Loading…
Reference in new issue