This is not updated anymore
Recent updates:
http://<raspberry pi IP>:8083/temperature_sensor/api/
It will not work on RPI 1/zero due to architecture. It probably only works with older sensor - using AAA battery. I tested it on RPI 3B+, on fresh raspbian 10 buster install (full).
It works with "Mi Bluetooth Temperature & Humidity Monitor":
It can also work with flashed (custom firmware: https://github.com/atc1441/ATC_MiThermometer ) small square sensor LYWSD03MMC. Custom firmware advantage: reading data is simple and won't affect battery life, but it won't work with xiaomi system anymore.
Project consists of 2 parts:
INSTRUCTIONS:
1.Install docker:
sudo curl -sSL https://get.docker.com | sh
sudo apt-get install libffi-dev
sudo pip3 install docker-compose
sudo usermod -aG docker pi
logout
Re-login to rpi and download project folder:
git clone https://github.com/jarekj9/mitempjj.git
cd mitempjj
Create image and run container:
docker-compose up -d
Check with command 'docker ps' if container is running.
Install additional python3 packages:
sudo pip3 install -r requirements.txt
Check xiaomi sensor MACs addresses and add it to file:
sudo blescan
(The MAC should have description like: Complete Local Name: 'MJ_HT_V1'
Edit this mac in file:
mac-address.txt
Simple example:
firewall-cmd --add-port=8083/tcp --permanent
systemctl restart firewalld
#OR:
sudo ufw allow 8083/tcp comment "sensor page"
(crontab -l 2>/dev/null; echo "*/10 * * * * cd /your_path && python3 /your_path/poll_sensor.py") | sudo crontab -
After some minutes view data on http://<raspberry pi IP>:8083/temperature_sensor/
To remove data, delete file: database/mitempjj.db
and to re-create everything:
cd mitempjj
docker-compose down
rm database/mitempjj.db
docker-compose up -d --build
Simple Schema:
+--------------+ +----------------------+
| | | |
| MI SENSOR | | PC with www browser |
| | | |
+-------+------+ +------------+---------+
| |
| |
| |
| |
| |192.168.X.X:8083
+------------------+Raspberry PI+--------------------+
| | | |
| v ++docker container+------+ |
| +-----+----+ | | | |
| | polling | | +--------------+----+ | |
| | script | | | www server(django)| | |
| | | | | port 8083 | | |
| +---------++ | | | | |
| | | +-----+-------------+ | |
| | | | | |
| | | | | |
| v | v | |
| ++------------+--------+--+ | |
| | shared volume: | | |
| | database/mitepjjj.db | | |
| | (sqlite) | | |
| +-------------+-----------+ | |
| | | |
| +------------------------+ |
+----------------------------------------------------+