twBLE2MQTT

A Bluetooth Low Energy (BLE) to MQTT gateway that discovers and decodes advertising packets from various sensors.

View on GitHub

twBLE2MQTT

Japanese (日本語)

twBLE2MQTT Infographic

A Bluetooth Low Energy (BLE) to MQTT gateway that discovers and decodes advertising packets from various sensors. Inspired by Zigbee2MQTT.

Features

Operating Environment

Installation / Build

Using Go Directly

To build the binary for your current platform:

  1. Clone the repository:
    git clone https://github.com/twsnmp/twBLE2MQTT.git
    cd twBLE2MQTT
    
  2. Build the binary:
    go build -o twble2mqtt
    

Using mise-en-place

This project supports mise for managing the Go toolchain and automated build tasks.

  1. Install mise if you haven’t already.
  2. Build for all supported platforms (Linux, macOS, Windows) and architectures (amd64, arm64, armv7):
    mise run build
    

    The resulting binaries will be located in the dist/ directory.

  3. To clean the build artifacts:
    mise run clean
    

Usage

Starting the Gateway

You must specify at least one destination (MQTT or Syslog).

./twble2mqtt -mqtt tcp://localhost:1883 -syslog 192.168.1.100:514

Command Line Flags

Flag Environment Variable Description Default
-mqtt TWBLUESCAN_MQTT MQTT broker destination (e.g., tcp://broker:1883) ””
-mqttUser TWBLUESCAN_MQTTUSER MQTT username ””
-mqttPassword TWBLUESCAN_MQTTPASSWORD MQTT password ””
-mqttClientID TWBLUESCAN_MQTTCLIENTID MQTT client ID twBlueScan
-mqttTopic TWBLUESCAN_MQTTTOPIC MQTT base topic twBlueScan
-syslog TWBLUESCAN_SYSLOG Comma-separated list of Syslog destinations ””
-interval TWBLUESCAN_INTERVAL Interval for sending periodic reports (seconds) 600
-all TWBLUESCAN_ALL Report all addresses (including private/random) false
-debug TWBLUESCAN_DEBUG Enable debug mode false

Environment Variables

All configuration flags can be overridden by environment variables prefixed with TWBLUESCAN_.

Monitoring

You can monitor the data collected by twBLE2MQTT using TWSNMP FK.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.