twBlueScan

BlueTooth Device Sensor for TWSNMP series.

View on GitHub

twBlueScan

twBlueScan is a sensor program for Linux that monitors surrounding Bluetooth Low Energy (BLE) devices and environmental sensors. It supports popular smart home devices like SwitchBot and Omron, sending real-time data to TWSNMP FC or other IoT platforms via Syslog and MQTT.

日本語の説明

Godoc Reference Go Report Card

Overview

A sensor program for Linux machines that collects information from nearby Bluetooth devices and sends it to TWSNMP FC or other systems via syslog or MQTT.

The collected information includes:

Status

Build

You can build the project using GoReleaser or Make.

Build with GoReleaser

goreleaser release --snapshot --clean

Build with Make

$ make

Available targets:

Executables will be created in the dist directory.

Usage

Command Line Flags

Usage of ./twBlueScan:
  -active
        Active scan mode
  -adapter string
        Monitor Bluetooth adapter (default "hci0")
  -addr string
        Make address to vendor map
  -all
        Report all details (including private addresses)
  -code string
        Make company code to vendor map
  -debug
        Debug mode
  -interval int
        Syslog send interval (sec) (default 600)
  -mqtt string
        MQTT broker destination (e.g., tcp://192.168.1.1:1883)
  -mqttClientID string
        MQTT client ID (default "twBlueScan")
  -mqttPassword string
        MQTT password
  -mqttTopic string
        MQTT topic (default "twBlueScan")
  -mqttUser string
        MQTT user name
  -syslog string
        Syslog destination list (comma-separated, e.g., 192.168.1.1:514)

Configuration via Environment Variables

Each flag can also be set via environment variables prefixed with TWBLUESCAN_ (e.g., TWBLUESCAN_SYSLOG).

Requirements

The bluez package is required on Linux.

$ sudo apt update
$ sudo apt install bluez

Verify that the Bluetooth device is available:

# hcitool dev
Devices:
	hci0	00:E9:3A:89:8D:FE

Execution Examples

# Sending to syslog
./twBlueScan -adapter hci0 -syslog 192.168.1.1

# Sending to MQTT (with active scan enabled)
./twBlueScan -active -mqtt tcp://192.168.1.1:1883 -mqttTopic myhome/ble

See ./LICENSE.

Copyright 2021-2026 Masayuki Yamai