/BLE-Scanner

ESP32-based Bluetooth Low Energy (BLE) scanner to report presence of bluetooth devices into an MQTT service.

Primary LanguageC++GNU General Public License v3.0GPL-3.0

BLE-Scanner

ESP32-based Bluetooth Low Energy (BLE) scanner to report presence of bluetooth devices into an MQTT service.

Challenge

Nowadays more and more bluetooth devices are around for personal use, like smart phones or smart watches. Why not use these devices to check presence of tenants at home?

There are already some solutions around. So why add another one?

I was quite astonished how many devices are detected if you scan the air for bluetooth. Only a few of these report their name, so its hard to distinguish these. The Bluetooth list of manufacturers helps here.

Solution

I used an Espressif ESP32 device which has WiFi and Bluetooth on-board (e.g. the Mini D1). The bluetooth scan results are published to an MQTT server via WiFi.

The BLE scanning device is configured via a Web Frontend which is inspired by Tasmota.

The BLE-Scanner doesn't need any external circuit -- just flash the software on it and configure the device.

Prepare the build environment

To intall the ESP32 device support in the Arduino IDE, do as follows:

  • Open the preferences in the Arduino IDE and add the following URLs to the Additional Boards Manager URLs
  • Open the Boards Manager and search for esp32. Install the found library.
  • Under Tools
    • select the Board ESP32 Arduino and your matching variant which was WEMOS D1 MINI ESP32 in my case. This depends on the board you use.
    • select the hightest Upload Speed
    • select the right CPU Frequency for your board
    • select the Flash Frequencyof 80MHz
    • select the Partition Scheme of Minimal SPIFFS (Large APPS with OTA)
  • Under Tools - Manage Libraries install the following libraries, if not yet installed:

Update Procedure (OTA)

Once you have the ESP32 device flashed with the BLE-Scanner, and maybe distributed a few of these devices in your infrastructure, you can use the Firemware Upgrade procedure where a new build SW version can by flashed over the air (OTA). Select Export compiled Binary under the 'Sketch' menu and upload the resulting file in the sketchs home in the BLE-Scanner.

Initialization Procedure

Whenever the BLE-Scanner starts and is not able to connect to your WiFi (eg. because of a missing configuration due to a fresh installation), it enters the configuration mode. In configuration mode the BLE-Scanner opens an WiFi Access Point with the SSID BLE-Scanner-AP-XX:XX:XX. Connect to it with your smartphone or notebook and configure at lease the WiFi settings. Than restart the BLE-Scanner, and continue the configuration.

To flash, open the sketch, build and upload to a connected ESP32. Then follow the Initialization Procedure above.

What is in this respository?

This is the sketch for the ESP32 micro controller. Use the ArduinoIDE to compile and upload into the ESP32 micro controller.

Follow the section Prepare the build environtment above, then open the sketch in the Arduino IDE to build and upload to a connected ESP32. Then follow the Initialization Procedure above.

In this directory you will find a 3D model of an enclosure for the device. These models are designed with OpenSCAD. Use the latest version of OpenSCAD (nightly build). The lower and upper shells of the enclosure are simply snapped together -- without any screws.

Case

Thie directory holds the helper script to download and activate the bluetooth manufacturer list.

Thie directory holds some screenshots of the web interface.