Pulling Temperature and Humidity from Xiaomi Sensor (BLE)

The above is Xiaomi Mijia bluetooth Temperature Humidity Sensor LCD Screen Digital Thermometer Hygrometer Moisture Meter, powered by one unit of AAA battery.

As usual, I always will to get latest update to raspberry pi and follow by install git, python and other libraries too.

sudo apt-get update -y

sudo apt-get install git python3 python3-pip libglib2.0-dev -y

sudo pip3 install bluepy

Install python module for interfacing with BLE devices through Bluez

git clone https://github.com/ratcashdev/mitemp.git

Library for Xiaomi Mi Temperature and Humidity Sensor (v2) with Bleutooth LE and the LCD display

git clone https://github.com/ChristianKuehnel/btlewrap.git

Official bluepy repo https://github.com/IanHarvey/bluepy

mv /home/pi/btlewrap/btlewrap/ /home/pi/mitemp/

move btlewrap folder to the mitemp folder.

pi@raspberrypi:~ $ cd /home/pi/mitemp/
pi@raspberrypi:~/mitemp $ ./demo.py backends

List out the available BLE backends

execute command, you should about to scan and detect device name ‘MJ_HT_V1’

sudo blescan

take note of the MAC address of the Xiaomi temperature sensor.

you can pull the temperature and humidity using the below command

python3 /home/pi/mitemp/demo.py –backend bluepy poll 4c:65:a8:**:**:**

in case your mac address started with 58:2d:34:xx:xx:xx not recognised you need to edit demo.py to add 58:2d:34 into the suffix

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.