Skip to content

Instantly share code, notes, and snippets.

@cbuctok
Created April 20, 2020 15:21
Show Gist options
  • Save cbuctok/54cbced2d15e57a9e0e647b7c2b1f4b0 to your computer and use it in GitHub Desktop.
Save cbuctok/54cbced2d15e57a9e0e647b7c2b1f4b0 to your computer and use it in GitHub Desktop.
#!/bin/bash
data=$(timeout 20 gatttool -b $SENSOR_ADDRESS --char-write-req --handle=0x10 -n 0100 --listen 2>/dev/null | grep "Notification handle" -m 2)
temperature=$(echo $data | awk '{print $7$6}')
humidity=$(echo $data | awk '{print $8}')
temperature=$((16#$temperature))
temperature=$(echo "scale=2; $temperature/100" | bc -l)
humidity=$((16#$humidity))
echo $temperature
echo $humidity
curl -q -i -XPOST "$INFLUXDB/write?db=home_temperature" --data-binary "salon temperature=$temperature,humidity=$humidity"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment