Skip to content

leahneukirchen/lywsd03mmc-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lywsd03mmc-exporter — a Prometheus exporter for the LYWSD03MMC BLE thermometer

lywsd03mmc-exporter is a small tool to scan and keep track of Bluetooth beacons the LYWSD03MMC BLE thermometer sends periodically. It can then be scraped by Prometheus, by default on :9265/metrics.

Exposed metrics

thermometer_temperature_celsius{mac="...",sensor="LYWSD03MMC"} 25.9
thermometer_humidity_ratio{mac="...",sensor="LYWSD03MMC"} 53
thermometer_battery_ratio{mac="...",sensor="LYWSD03MMC"} 91
thermometer_rssi_dbm{mac="...",sensor="LYWSD03MMC"} -35

Additionally, the ATC_MiThermometer custom firmware exposes:

thermometer_battery_volts{mac="...",sensor="LYWSD03MMC"} 3.005
thermometer_frame_current{mac="...",sensor="LYWSD03MMC"} 165

Modes of operation

Due to talking to lower levels of the Bluetooth stack, lywsd03mmc-exporter needs to be run as root or with CAP_NET_ADMIN.

Stock firmware

To use lywsd03mmc-exporter with the stock firmware, you need to activate your device and extract the Mi Bindkey. You can either use the Xiaomi Home software for that (requires an account and a HTTPS MITM attack on your phone), or more easily, use the TelinkFlasher provided by @atc1441.

You will need to create a keyfile in a format like this, and use -k file:

# format: MAC KEY, hex digits only
A4C138FFFFFF 00112233445566778899aabbccddeeff

This mode sends measurements every 10 minutes.

Note: Supposedly, the battery ratio is always 100% unless the battery is really empty.

Custom firmware

@atc1441 wrote a custom firmware for the LYWSD03MMC. It sends data unencrypted in beacons. Negative temperatures are supported.

You can flash it easily with above TelinkFlasher.

This mode sends measurements every 10 seconds.

Polling mode

This requires an active connection to the device. Pass the MAC addresses of the devices as arguments to lywsd03mmc-exporter. This is currently limited to one device (bug in go-ble?).

Copying

lywsd03mmc-exporter is licensed under the MIT license.

Thanks

This software would not be possible without the help of code and documentation in:

About

a Prometheus exporter for the LYWSD03MMC BLE thermometer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages