/ESP-32-BLE-Scanner

ESP 32 BLE Scanner for Home Assistant to report Room Presence

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

ESP-32-BLE-Scanner

for Home Assistant. See thread at Home Assistant Board.

What does this program do?

This is basicly a room presence detector. Use it with Home Assistant to trigger automations when you enter a room, disarm your alarm etc. It reports the presence of known bluetooth (Beacon) devices and reports it (via MQTT) to Home Assistant. I designed the program to work together with the HA Android App (IOS not tested yet).

Please keep in mind

This is my first project on github, I am programming in my free time during my 9 to 5 job and I am not a professional programmer. I will try to support and fix errors as good and as fast as I can.

Features

  • Web UI to set everything up
  • MQTT Client to report state to Home Assistant
  • BLE Beacon Scanner for 3 different devices (more to come in the future)
  • Works fine with Android Home Assistant App
  • Easy Integration into Home Assistant
  • Raw distance calculation

Roadmap

  • provide bin for making first flash easier via ESP flash tool
  • improve MQTT and MQTT response
  • online status for the ESP32
  • make update via Web ui possible(binary upload)
  • better distance calculation
  • more network settings (fixed ip etc.)
  • add bluetooth scanner settings
  • add support for more bluetooth devices like smartwatches etc.
  • add support for more devices being saved

Settings:

How to install (via ESP Download Tool)

Click to expand
  1. Download and extract the program
  2. Download ESP32 Download Tool / Flash Download Tools
  3. Start the Download Tool (ESP32 and Developer Mode)
  4. Plug in your ESP32 and change Com Port according to it
  5. Set the following settings:
Address for bin: 0
SPI Speed: 40mhz
SPI Mode: DIO
Flash Size: 32Mbit
DoNotChgBin: Set to true
  1. Click start and the bin will be flashed

How to install (via Plattformio)

Click to expand
  1. For Plattformio installation (on Visual Studio Code or Atom.io) see here
  2. Download and extract the program
  3. Open the project folder in Plattformio
  4. Open Plattformio menue
  5. Plug in your ESP32
  6. (Optional) Open devices.json and settings.json located at /data and change your credentials (you can later change all settings over the web ui)
  7. Click Build Filesystem Image (Make sure there is no open serial connection to the ESP32 - you can close it with the little garbage can icon in the terminal)
  8. Click Upload Filesystem Image
  9. Click Upload and Monitor
  10. Check Serial Connections for errors

Set up the ESP32

Click to expand
  1. The ESP32 should start its own AP - look for a Wifi named "ESP32-BLE-Scanner" / If you changed settings.json you can jump to 5.
  2. Connect to the Wifi (it should not have a password)
  3. Go to http://192.168.4.1 Setup and change your Wifi and MQTT settings
  1. Wait for the ESP32 to restart and check for the IP adress with an scan tool or check the serial connection for the device ip
  2. Connect to the Scanner and fill your Bluetooth details under devices. (See Setup HA APP for how to get your UUID)

Setup HA App (Android) (Iphone is untested yet)

Click to expand

Open HA App go to App Configuration -> Manage Sensors -> Bluetooth Sensors -> BLE Transmitter

Enable Sensor (should be disabled from the start)

-> Copy and paste the UUID into the device adress in the ESP32 BLE Scanner under devices

!

Setup Home Assistant

Click to expand

Add to your config.yaml:

sensor:
- platform: mqtt_room
  device_id: 'Your BLE UUID'
  name: 'Name of your mobile device or your name not your room/hostname'
  state_topic: 'ESP32 BLE Scanner/Scan'
  timeout: 60
  away_timeout: 30

For more see HA Documentation