Git Product home page Git Product logo

xiaomi-ble-mqtt's Introduction

About

This is simple python script, which scans Xiaomi BLE Temperature and Humidity sensors and publishes measurements to MQTT.

Installation

1.Install required packages:

sudo pip3 install bluepy
sudo pip3 install paho-mqtt
sudo pip3 install mitemp_bt

2.Clone code:

git clone https://github.com/algirdasc/xiaomi-ble-mqtt.git
cd xiaomi-ble-mqtt

3.Add crontab task. Task will be run every 5 minutes:

crontab -e
# Add row
*/5 * * * * /usr/bin/python3.5 <path to xiaomi-ble-mqtt>/data-read.py >> <path to xiaomi-ble-mqtt>/xiaomi-ble.log 2>&1

4.Rename mqtt.ini.sample to mqtt.ini and configure MQTT broker by editing mqtt.ini file.

5.Scan for available Xiaomi BLE devices:

 sudo hcitool lescan

Look for line which looks like this:

4C:65:A8:D4:A3:1D MJ_HT_V1

5.Rename devices.ini.sample to devices.ini and configure Xiaomi devices by editing devices.ini file:

[room1]
device_mac=4C:65:A8:XX:XX:XX
topic=sensors/room1
availability_topic=sensors/room1/availability
average=3
retain=1
timeout=10

[room2]
device_mac=4C:65:A8:XX:XX:XX
topic=sensors/room2

etc...

MQTT Payload example:

{"temperature": 25.7, "humidity": 42.0, "battery": 100}

xiaomi-ble-mqtt's People

Contributors

algirdasc avatar apat183 avatar tayfunulu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.