Bluetooth Monitor port for the ESP32

Overview

ESP32 BT Monitor

GitHub release (latest by date including pre-releases) ESP-IDF ESP32

What is it?

This is a (at the moment partial) port of andrewjfreyer/monitor for the popular and super cheap ESP32 boards. For a more detailed explanation of how it works, visit the link above. But as a short summary: this software allows you to scan for known Bluetooth devices by MAC address on demand, by requesting their name. The beauty of it is that you don't need any special software running on the devices you'd like to track!

Building the project from source

Prerequisites

In order to build this project, you need to have Visual Studio Code installed, with the C/C++ and PlatformIO IDE extensions.

Libraries

This project relies on the following libraries:

Build it

  1. Clone this repository
  2. Open the local repository directory in VSCode
  3. Open the PIO Projects & Configuration tab and create an existing project.
  4. Open this project from the PIO interface
  5. In the sidebar, open up the PIO Tab and under PROJECT TASKS / Default hit Build Note: The first time opening this project, PlatformIO will take some time to fetch all the required modules before the list under PROJECT TASKS shows up!!
  6. Once the build succeeds you can flash your ESP32 with the 'Monitor' compatible Bluetooth scanner.

Modifications: When building the project from sources, there are some things you may want to customize in platformio.ini.

  • AP_PASSWD: The AccessPoint password for when the ESP32 is not yet configured to connect to your home WiFi network.
  • HTTPD_USER: Username for authorization on the config portal when the ESP32 is connected to your home WiFi network.
  • HTTPD_PASSWD: Password for authorization on the config portal when the ESP32 is connected to your home WiFi network.
  • MAX_NUM_STORED_BLUETOOTH_DEVICES: Maximum number of known bluetooth devices that can be stored on the ESP32

By default PlatformIO is set up for flashing devices that are connected to your computer. If you wish to perform remote debugging or over the air updates using espota you'll need to uncomment the following section and fill in your device-ip:

monitor_port = socket://[device-ip]:23
upload_protocol = espota
upload_port = [device-ip]
upload_flags =
  --port=3232
  --auth=admin

Configuration

After flasing your ESP32 some initial configuration is required. To begin, connect your phone to the ESP32's WiFi hotspot. This will have a name starting with ESP32_bt, followed by unique characters based on the devices MAC address. The default firmware configuration requires the following credentials in order to connect to the AP: abc45678. When connected navigate with your browser of choice to 192.168.4.1 to open the configuration menu.

Now it's best to first enter the settings menu to start configuration there. Performing the WiFi configuration first will cause the device to restart and connect to your home network. You can still configure the device after this, it just requires some more steps to navigate to it's new IP again! The settings menu contains all settings related to the BT monitor application as shown below. The scan settings and BT devices can be skipped and configured later on. The important bits for now are the MQTT parameters to make sure the application can communicate.

In case you need to revisit the configuration pages you can do so by navigating to the ESP32's IP address on your home network. To prevent others from tinkering with your device any access to it's webpage once it's connected to your WiFi network is password protected! To log on, use username admin and password 1234.

Usage

web control

The ESP32 bluetooth scan status can be seen through the devices webpage by following the BT Monitor link in the main menu. This page will show you all configured devices by name and MAC address, as well as their away / present state. From this page you can also trigger various scans and update the page to load the new scan results.

Home assistant

Find some examples for sensors and automations in HomeAssistant here.

Features

Implemented:

  • andrewjfreyer/monitor compatible MQTT scan reporting
  • Arrival / Departure scan triggered by monitor/scan/arrive and monitor/scan/depart
    • 'Any' scan (scan for departure on present devices and arrival for away devices) triggered by monitor/scan/any
  • Periodic scanning
  • Setup known bluetooth devices through MQTT using monitor/setup/add known device and monitor/setup/delete known device
    • Send only MAC when deleting a device
    • Send MAC followed by its alias when adding devices
  • Over the air update
    • through web interface
    • Using espota
  • Setup through modified WiFiManager
    • Password protected web interface once connected to your home WiFi network
    • Bluetooth Scan status + scan controls webpage
  • Logging over serial and telnet
  • Monitor settings:
    • #Arrival scans
    • #Departure scans
    • seconds between scans within set
    • minimal time between scan sets
    • periodic scanning interval

ToDo

  • Add passive scanning as is available in monitor
  • Expand configuration options
  • Add BLE iBeacon scanning support for room by room presence detection
  • Strip away the core BT monitor logic to expose as a library
  • Make an ESPHome component for it
    • Currently blocked by incompatible IDF v4.2 support used by ESPHome Core
You might also like...
A port of the Uxn virtual machine to the ESP32

Uxn An assembler and emulator for the Uxn stack-machine, written in ANSI C. Build Linux To build the Uxn emulator, you must have SDL2. If you wish to

Firebase Arduino Client Library for ESP8266 and ESP32. The unified version of Firebase-ESP8266 and Firebase-ESP32 Realtime database libraries with Cloud Firestore, Firebase and Google Cloud Storage, Cloud messaging and Cloud Functions supports.
Allows for multiple SwitchBot buttons and curtains to be controlled via MQTT sent to ESP32. ESP32 will send BLE commands to switchbots and return MQTT responses to the broker. Also supports Meter/Temp Sensor

SwitchBot-MQTT-BLE-ESP32 Switchbot local control using ESP32. no switchbot hub used/required. works with any smarthub that supports MQTT https://githu

AnalogWrite for ESP32 and ESP32-S2 with LEDC PWM. Includes PWM Phase Control, DAC and Smart GPIO resource management.
AnalogWrite for ESP32 and ESP32-S2 with LEDC PWM. Includes PWM Phase Control, DAC and Smart GPIO resource management.

analogWrite() ESP32 Installation Instructions This library was tested using using the ESP32 Arduino IDE Boards Manager installation method. Stable rel

ESP32 + GitHub Actions + Husarnet. A boilerplate project for ESP32 allowing in-field firmware update using GitHub Actions workflow.

esp32-internet-ota ESP32 + GitHub Actions + Husarnet. A boilerplate project for ESP32 allowing in-field firmware update using GitHub Actions workflow.

🪴💧 A Bluetooth Low Energy (BLE) soil moisture sensor.
🪴💧 A Bluetooth Low Energy (BLE) soil moisture sensor.

b-parasite b-parasite is an open source Bluetooth Low Energy (BLE) soil moisture and ambient temperature/humidity sensor. Features Soil moisture senso

Dongle to connect a bluetooth PS3 controller to the Gamecube 🎮
Dongle to connect a bluetooth PS3 controller to the Gamecube 🎮

GamecubeBT An arduino based bridge to connect a bluetooth PS3 controller to the Gamecube. Homemade Wavebirds, because the TV is too far from the couch

Arduino Sketch and a Web Bluetooth API for loading models and running inference on the Nano Sense 33 BLE device.
Arduino Sketch and a Web Bluetooth API for loading models and running inference on the Nano Sense 33 BLE device.

TF4Micro Motion Kit This repo contains the Arduino Sketch and a Web Bluetooth API for loading models and running inference on the device. Install and

Heart Rate Monitor for FPV drones
Heart Rate Monitor for FPV drones

Heart Rate Monitor for FPV drones Watch your heart rate on Betaflight OSD 💓 See how excited you are while: Diving the highest skyscraper 🏙 Flying lo

Comments
  • Cannot respond to mqtt arrive/depart scan commands

    Cannot respond to mqtt arrive/depart scan commands

    运行时,网页端发出扫描命令,本程序能响应,并进行扫描工作,但是不响应mqtt扫描命令。查看mqtt服务器端,发现与monitor脚本相比,很长时间中mqtt连接次数有限,不知道是不是mqtt的问题。我使用树莓派安装monitor脚本,在mqtt服务器日志中查看到的信息显示脚本很频繁地以不同客户端名称连接/断开mqtt(192.168.1.54),但是在ESP32这个固件中,连接很少(192.168.1.166).下面是谷歌翻译的英文: Sorry i'm not proficient in english,The following is translated by Google:When it is running, the web page sends out a scan command, the program can respond and scan, but it does not respond to the mqtt scan command. Looking at the mqtt server side, it is found that compared with the monitor script, the number of mqtt connections is limited for a long time. I don't know if it is a problem with mqtt. I found in the log of the mqtt server using the Raspberry Pi to install the monitor script. The script frequently connects/disconnects mqtt with different client names, but in the ESP32 firmware, the connection Rarely .

    opened by pauldw1230 6
  • Formula for confidence calculation always return 0

    Formula for confidence calculation always return 0

    Noticed that the confidence value is never reported as anything else than 100 or 0

    So started comparing the formula to the original monitor script trying to understand what the intended behavior really was.

    There it looks like like this:

    $(echo "scale=1; ($repetitions - $repetition + 1) / $repetitions * 90" | bc )
    

    So for example doing that calculation for 3 repetitions would give you this:

    (3 - 1 + 1) / 3 * 90 => 3 / 3 * 90 => 1   * 90 => 90.0
    (3 - 2 + 1) / 3 * 90 => 2 / 3 * 90 => 0.6 * 90 => 54.0
    (3 - 3 + 1) / 3 * 90 => 1 / 3 * 90 => 0.3 * 90 => 27.0
    

    The odd part is the scale=1; that basically drops precision to just 1 decimal 🤔

    Only confirmed this by running echo "scale=1; (3 - 3 + 1) / 3 * 90" | bc manually. Not sure if there is any real intention behind using bc this way, or of it's just a fast way to get a reasonably good result in a shell script.

    Based on that it looks like the formula is a bit wrong now: https://github.com/RoboMagus/ESP32-MQTT-Bluetooth-Monitor/blob/d64281836b1edf6eb8dca4f87b6cbc18348b3746/src/BluetoothScanner.cpp#L939

    Changing it to this:

    min(100.0f, float(dev.scansLeft + 1) / float(num_departure_scans) * 90.0f)); 
    

    Yields somewhat the same result as the original script.

    (2 + 1) / 3 * 90 => 3.0 / 3.0 * 90 => 1        * 90 => 90.0
    (1 + 1) / 3 * 90 => 2.0 / 3.0 * 90 => 0.666... * 90 => 60.0
    (0 + 1) / 3 * 90 => 1.0 / 3.0 * 90 => 0.333... * 90 => 30.0
    

    (The last run is naturally dropped to 0 but the corresponding calculation would have been 30)

    Other than that I can confirm that things run quite nicely on a AZ-Delivery devkit board :+1:

    opened by edrik 2
Releases(v0.3.0)
  • v0.3.0(Oct 23, 2021)

    Initial implementation of passive ble background scanning that allows for presence monitoring using iBeacon devices. This also supports RSSI output on the presence message sent over MQTT. This will become usefull when distributing multiple ESP32 nodes for room by room presence detection. This feature is still a work in progress and thus subject to change!!

    Other changes: Code is restructured to more easily switch away from using the TelnetSerial serial interface. Parameter handling is restructured and the character count for MAC addresses is increased to also support 128bit iBeacon service UUIDs. (Which is also reflected in the settings page) Added an MQTT topic that provides the ESP32s IP address.

    Attached are binary files built as the stock configuration for the Wemos D1 Mini 32 and support storing 8 known BT devices (MAC or UUID).

    Source code(tar.gz)
    Source code(zip)
    firmware.bin(1.18 MB)
    firmware.elf(21.38 MB)
  • v0.2.0(Sep 4, 2021)

    This release includes some minor bugfixes and an overhaul of the way the persistent known bluetooth devices (MAC + Alias) are stored. This change makes it posible to let users determine the size of the known devices list at compile time.

    WARNING: Due to the change in the way the MACs and Aliases are stored now it is incompatible with the settings from the previous version!!! All other settings will remain intact, but you'll have to re-add the known bluetooth devices again.

    Attached are binary files built as the stock configuration for the Wemos D1 Mini 32 and support storing 8 known BT devices.

    Source code(tar.gz)
    Source code(zip)
    firmware.bin(1.18 MB)
    firmware.elf(21.22 MB)
  • v0.1.0(Aug 31, 2021)

Owner
Into home automation, 3d-printing, embedded systems, and dockerize all the things!
null
Exploits the Wii U's bluetooth stack to gain IOSU kernel access via bluetooth.

BluuBomb Exploits the Wii U's bluetooth stack to gain IOSU kernel access via bluetooth. For a more detailed write-up see WRITEUP.md. Not to be confuse

null 99 Dec 17, 2022
Serial Data Monitor is a multiplatform (Windows, Linux, Mac, ...) tool to interactively receive/edit/monitor data and send commands to an embedded system via the serial bus

See wiki for full documentation Serial Data Monitor Description Serial Data Monitor is a multiplatform (Windows, Linux, Mac, ...) tool to interactivel

monnoliv 4 Oct 29, 2021
Bluetooth Joystick : A wireless joystick with ESP-32 microcontroller and Dual Axis Joystick Module using the Bluetooth connectivity.

BluetoothJoystick Bluetooth Joystick : A wireless joystick with ESP-32 microcontroller and Dual Axis Joystick Module using the Bluetooth connectivity.

null 9 Feb 24, 2022
Port of my M5Stack Core 2 audio monitor project to generic ESP32s with TFT screens

ESP32 Audio Monitor This is a port of this project to work with any ESP32 device with a TFT display. You can watch a video explainer here (YouTube) wh

atomic14 47 Nov 9, 2022
ESP32-Skid-Steer - Bruder Catepillar Skid Steer model converted to RC, controlled by an ESP32 with 2 analog joysticks and a receiver that is an ESP32 on the model.

ESP32-Skid-Steer Bruder Catepillar Skid Steer model converted to RC, controlled by an ESP32 with 2 analog joysticks and a receiver that is an ESP32 on

null 6 Oct 27, 2022
Bluetooth low energy (BLE) tracker for ESP32

BLEcker Bluetooth low energy (BLE) tracker for ESP32 This software is written for ESP32 boards to track BLE devices. It can be used for your smart hom

Vörös Ákos 42 Jan 3, 2023
Bluetooth Gateway for Phantom Remote Control based on ESP32

Phantom remote control Bluetooth gateway An ESP3232 firmware for the gateway of Phantom remote control, which can push the temperature and humidity data of Phantom remote control through LAN, and also support to control Phantom remote control to send and receive IR data through LAN.

George Zhao 14 Nov 3, 2022
Gesture-Detecting-Macro-Keyboard - Glorified Bluetooth macro keyboard with machine learning (TensorFlow Lite for Microcontrollers) running on an ESP32.

Gesture detection tldr; Glorified Bluetooth macro keyboard with machine learning (TensorFlow Lite for Microcontrollers) running on an ESP32. Main feat

Jakob Krantz 68 Dec 1, 2022
Bluetooth LE Keyboard library for the ESP32 (Arduino IDE compatible)

ESP32 BLE Keyboard library This library allows you to make the ESP32 act as a Bluetooth Keyboard and control what it does. You might also be intereste

null 1.5k Jan 8, 2023
Trial port of the rtf_433 Library for use with OpenMQTTGateway on a ESP32 and a CC1101 Transceiver

This is an attempt at creating an Arduino library for use on ESP32 boards with a CC1101 transceiver with the device decoders from the rtl_433 package.

Northern Man 92 Jan 3, 2023