3.1.2 • Published 1 year ago

@sebbo2002/ble2mqtt v3.1.2

Weekly downloads
45
License
MIT
Repository
github
Last release
1 year ago

ble2mqtt

License

🧐 What's this?

ble2mqtt is a small script that writes data from Bluetooth-LE devices to MQTT Topics. Unlike many other implementations it only listens to the broadcasts of the devices, there is no active polling. This has the advantage that it is more stable, the sensors consumes less energy and mostly the range is higher. The disadvantage is that, depending on the device, individual values may be missing if they are not transmitted by broadcast. If these values are required, they would still have to be retrieved by polling. However, the most important data is usually transmitted via broadcasts, so that less important data (e.g. the battery status of the device) can also be requested less frequently.

💾 Installation

This module is based on noble. Therefore the same requirements are necessary here as well.

  • for macOS: install Xcode
  • for Ubuntu/Debian/Raspbian: run sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
  • for Fedora / Other-RPM based: run sudo yum install bluez bluez-libs bluez-libs-devel
  • for Windows and other systems have a look at the noble project, they may already have some instructions for you

After you have met the requirements for noble, you can install bte2mqtt:

npm install -g @sebbo2002/ble2mqtt

🔧 Configuration

Environment VariableDefault ValueDescription
BROKER_URLmqtt://localhostMQTT-Broker URI
TOPIC_PREFIXble2mqttPrefix used to generate MQTT topics
CACHE_TTL5000Cache TTL in ms, set to 0 to disable cache and publish every single message it gets
RETAIN_FLAG0Set the retain flag for MQTT messages? Default is no, set to 1 to enable.
WHITELIST-Comma seperated list of device UUIDs or addresses. If set, all other devices are ignored.

⌨️ Usage

If you have ble2mqtt installed, you can start the tool. The best thing to do is to set --debug first, so you can see what happens. When the script reports Connections established it will start. If not make sure that no other programs access your Bluetooth adapter. This can cause problems.

ble2mqtt screenshot

ble2mqtt now collects data from devices that send it out via Bluetooth LE. This data is parsed and forwarded in MQTT topics. Besides the general attributes there are also devices that reveal more about themselves. These are mostly sensors. If they are implemented in ble2mqtt, these values are forwarded as well. A list with all supported devices can be found below.

General attributes

Event if there's no implementation for your device you can use this module to get some basic information. You can still use other implementations to poll values in parallel. These general attributes are:

  • name
  • address
  • uuid
  • lastSeen
  • rssi

Monitoring

ble2mqtt supports several topics that can be used to monitor the process. They are updated every times the script starts.

  • pid
  • version

Internal Cache

To avoid flooding the MQTT-Broker with a huge amount of messages, there is a limit of one update per topic per 5 seconds. The limit can be changed or deactivated with the environment variable CACHE_TTL.

📡 Supported Devices

Here's a list of devices which are supported. Other devices as listed here will most likely only support the basic attributes.

🤷 Frequently asked questions

How do I determine which Bluetooth adapter the script should use?

  • hcitool dev
  • NOBLE_HCI_DEVICE_ID=1 (hci1 used)

Something doesn't work. How can I get more information about what's going on inside the script?

  • ble2mqtt --debug

📚 Credits

👩‍⚖️ Copyright & License

Copyright (c) Sebastian Pekarek under the MIT license.

3.1.3-develop.1

1 year ago

3.1.2

2 years ago

3.1.2-develop.1

2 years ago

3.1.1-develop.1

2 years ago

3.1.0-develop.3

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

2.0.8

2 years ago

2.0.9-develop.1

2 years ago

2.0.9-develop.2

2 years ago

3.0.0

2 years ago

3.1.0-develop.2

2 years ago

2.0.8-develop.4

2 years ago

3.0.0-develop.4

2 years ago

3.0.0-develop.3

2 years ago

3.0.0-develop.2

2 years ago

3.0.0-develop.1

2 years ago

3.1.0-develop.1

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.8-develop.1

2 years ago

2.0.8-develop.3

2 years ago

2.0.8-develop.2

2 years ago

2.0.7-develop.2

2 years ago

2.0.7-develop.1

2 years ago

2.0.6-develop.4

2 years ago

2.0.6-develop.3

2 years ago

2.0.5-develop.3

2 years ago

2.0.5

2 years ago

2.0.5-develop.2

2 years ago

2.0.5-develop.1

2 years ago

2.0.6-develop.2

2 years ago

2.0.6-develop.1

2 years ago

2.0.4

2 years ago

2.0.4-develop.1

2 years ago

2.0.4-develop.2

2 years ago

2.0.3

2 years ago

2.0.3-develop.1

2 years ago

2.0.2-develop.1

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.1-develop.1

2 years ago

2.0.0

3 years ago

2.0.0-develop.3

3 years ago

2.0.0-develop.2

3 years ago

2.0.0-develop.1

3 years ago

1.1.2-develop.9

3 years ago

1.1.2-develop.8

3 years ago

1.1.2-develop.7

3 years ago

1.1.2-develop.6

3 years ago

1.1.2-develop.5

3 years ago

1.1.2-develop.4

3 years ago

1.1.2-develop.3

3 years ago

1.1.2-develop.2

3 years ago

1.1.2-develop.1

3 years ago

1.0.0-develop.35

3 years ago

1.0.0-develop.34

3 years ago

1.0.0-develop.33

3 years ago

1.0.0-develop.32

3 years ago

1.1.1

3 years ago

1.0.0-develop.30

3 years ago

1.0.0-develop.31

3 years ago

1.0.0-develop.29

3 years ago

1.0.0-develop.28

3 years ago

1.0.0-develop.27

3 years ago

1.0.0-develop.26

3 years ago

1.0.0-develop.25

3 years ago

1.0.0-develop.24

3 years ago

1.0.0-develop.23

3 years ago

1.0.0-develop.22

3 years ago

1.1.0

3 years ago

1.0.0-develop.21

3 years ago

1.0.0-develop.20

3 years ago

1.0.0-develop.19

3 years ago

1.0.0-develop.18

3 years ago

1.0.0-develop.16

3 years ago

1.0.0-develop.17

3 years ago

1.0.0-develop.15

3 years ago

1.0.2

3 years ago

1.0.0-develop.14

3 years ago

1.0.0-develop.13

4 years ago

1.0.0-develop.11

4 years ago

1.0.0-develop.12

4 years ago

1.0.0

4 years ago

1.0.0-develop.10

4 years ago

1.0.0-develop.8

4 years ago

1.0.0-develop.9

4 years ago

1.0.0-develop.7

4 years ago

1.0.0-develop.5

4 years ago

1.0.0-develop.6

4 years ago

1.0.0-develop.4

4 years ago

1.0.0-develop.3

4 years ago

1.0.0-develop.1

4 years ago

1.0.0-develop.2

4 years ago

0.0.0

4 years ago