Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6987

Automation, sensing and robotics • Getting Data From a Xiaomi Mijia LYWSD03MMC Temperature Humidity sensor

$
0
0
This on a Pi4B running Buster.

For several years now I've been using a simple shell script to get data from a Xiaomi Mijia LYWSD03MMC Temperature Humidity sensor. I got most of the code hints from here: Getting Data From a Xiaomi Mijia LYWSD03MMC

It works like this for my existing sensor:

Code:

pi@raspsky:~/webcam $ timeout 15 gatttool -b A4:C1:38:C5:33:3A --char-write-req --handle='0x0038' --value="0100" --listen | grep "Notification handle" -m 1Notification handle = 0x0036 value: 55 09 3c 62 09
It's pretty easy to parse the values to get the temperature, humidity and battery voltage.

I bought a new identical sensor, but get this error:

Code:

pi@raspsky:~/webcam $ timeout 15 gatttool -b A4:C1:38:00:FF:AD --char-write-req --handle='0x0038' --value="0100" --listen | grep "Notification handle" -m 1Characteristic Write Request failed: Attribute can't be writtenTerminated
I've searched around quite a bit to solve the problem. Apparently, Xkaomi has changed the firmware to encrypt the data, requiring a key. The only place I've found to get the key is here:

https://atc1441.github.io/TelinkFlasher.html which you're supposed to open on your phone. It doesn't work for me:

Code:

Log:11:28:18: Not connected11:28:49: Searching for devices11:30:02: Not connected11:55:58: Searching for devices11:56:15: Not connected11:57:19: Searching for devices
This seems odd to me as the device is easy to find from a Pi:

Code:

pi@raspsky:~/webcam $ sudo hcitool lescan | grep LYWSD03MMCA4:C1:38:C5:33:3A LYWSD03MMCA4:C1:38:00:FF:AD LYWSD03MMCA4:C1:38:00:FF:AD LYWSD03MMCA4:C1:38:C5:33:3A LYWSD03MMC
LYWSD03MMC is the device ID. Both the new and old sensor have the same ID and, of course, different MAC.

Similar link here: https://pvvx.github.io/ATC_MiThermomete ... asher.html. Also fails to connect.

Any idea on which rabbit hole I should fall down next?

Statistics: Posted by Ratsima — Thu Nov 27, 2025 5:31 am — Replies 2 — Views 86



Viewing all articles
Browse latest Browse all 6987

Trending Articles