Skip to content

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers. See [Wiki](https://github.com/zewelor/bt-mqtt-gateway/wiki) for more information.

License

Notifications You must be signed in to change notification settings

frankstolle/bt-mqtt-gateway

 
 

Repository files navigation

bt-mqtt-gateway

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers.
See Wiki for more information.

Features

  • Highly extensible via custom workers
  • Data publication via MQTT
  • Configurable topic and payload
  • MQTT authentication support
  • Systemd service
  • Reliable and intuitive
  • Tested on Raspberry Pi Zero W

Supported devices

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

  • python3 >= 3.5
  • pip3

Installation

On a modern Linux system, just a few steps are needed to get the gateway working. The following example shows the installation under Debian/Raspbian:

sudo apt-get install git python3 python3-pip bluetooth bluez
git clone https://github.com/zewelor/bt-mqtt-gateway.git
cd bt-mqtt-gateway
sudo pip3 install -r requirements.txt

Configuration

All worker configuration is done in the file config.yaml. This file needs to be created first:

cp config.yaml.example config.yaml
vim config.yaml
./gateway.py

Attention: You need to add at least one worker to your configuration. Scan for available Bluetooth devices in your proximity with the command:

sudo hcitool lescan

Execution

A test run is as easy as:

sudo ./gateway.py

Debug output can be displayed using the -d argument:

sudo ./gateway.py -d

Deployment

Continuous background execution can be done using the example Systemd service unit provided.

sudo cp bt-mqtt-gateway.service /etc/systemd/system/
sudo vim /etc/systemd/system/bt-mqtt-gateway.service
sudo systemctl daemon-reload
sudo systemctl start bt-mqtt-gateway
sudo systemctl status bt-mqtt-gateway
sudo systemctl enable bt-mqtt-gateway

Attention: You need to define the absolute path of gateway.py in bt-mqtt-gateway.service.

Custom worker development

Built With

  • Python - The high-level programming language for general-purpose programming

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers. See [Wiki](https://github.com/zewelor/bt-mqtt-gateway/wiki) for more information.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%