From 921f4897fcc86708684b85328496a74b2dc6349f Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 28 Jan 2023 09:06:15 +0100 Subject: [PATCH] decode battery voltage --- ble-mijia.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ble-mijia.sh b/ble-mijia.sh index 9659e29..908d63f 100755 --- a/ble-mijia.sh +++ b/ble-mijia.sh @@ -2,8 +2,11 @@ mac=A4:C1:38:90:DC:63 test ! -z "$1" && mac=$1 +# based on https://ndimension.design.blog/2021/12/16/reading-data-from-xiaomi-mi-temperature-and-humidity-monitor-2-lywsd03mmc/ +# find sensor with: sudo hcitool lescan +# A4:C1:38:D8:3F:9C LYWSD03MMC gatttool -b $mac --char-write-req --handle='0x0038' --value="0100" --listen | \ - awk 'BEGIN { OFS=","; ORS="\n" } /value:/ { print "temperature=" strtonum("0x"$7$6) / 100, "humidity=" strtonum("0x"$8), "a=" strtonum("0x"$9), "b="strtonum("0x"$10) ; fflush() }' | \ + awk 'BEGIN { OFS=","; ORS="\n" } /value:/ { print "temperature=" strtonum("0x"$7$6) / 100, "humidity=" strtonum("0x"$8), "battery=" strtonum("0x"$10$9) / 1000 ; fflush() }' | \ xargs -i curl --silent -XPOST 'http://10.60.0.92:8086/write?consistency=any&db=rot13' --data-binary "mijia,dc=trnjanska,mac=$mac {}" -- 2.20.1