This script was made using typical Linux applications to get Temperature and Humidify data from Xiaomi Mijia Bluetooth Temperature humidity version 2 a.k.a. LYWSD03MMC
This script is a modification from the original version with support to use mosquitto_pub to send data over MQTT to a broker. Thanks to the author.
This version works fine in a Raspberry Pi 3+.
Use crontab to scheduler an execution every minute.
- gatttool (to work with BLE)
- awk
- bc
- mosquitto_pub
Use the command below to find the device mac address
sudo hcitool lescan
Grant execution permissions
chmod +x readSensor.sh
running..
./readSensor.sh
Sometimes the devices get blocked. Try to reset the Bluetooth interface with the following commands:
sudo hciconfig hci0 down
sudo hciconfig hci0 up