Skip to content

Instantly share code, notes, and snippets.

@artms
artms / read.sh
Last active December 10, 2022 05:00
Reading from temper temperature sensor in bash only
#!/bin/bash
exec 5<> /dev/hidraw1
echo -e '\x00\x01\x80\x33\x01\x00\x00\x00\x00\c' >&5
OUT=$(dd count=1 bs=8 <&5 2>/dev/null | xxd -p)
HEX4=${OUT:4:4}
DVAL=$((16#$HEX4))
# handle negative temperatures
if [[ $DVAL -gt 32767 ]]; then
DVAL=$(($DVAL-65536))
fi