2018-05-14 21:15:49 +02:00
|
|
|
ESP32 Bluetooth Low Energy Device
|
|
|
|
=================================
|
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
.. seo::
|
|
|
|
:description: Instructions for setting up BLE binary sensors for the ESP32.
|
2021-11-16 03:19:33 +01:00
|
|
|
:image: bluetooth.svg
|
2018-11-14 22:12:27 +01:00
|
|
|
|
2019-05-12 22:44:59 +02:00
|
|
|
The ``ble_presence`` binary sensor platform lets you track the presence of a
|
2020-05-10 21:27:59 +02:00
|
|
|
Bluetooth Low Energy device.
|
2018-05-14 21:15:49 +02:00
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
.. figure:: images/esp32_ble-ui.png
|
|
|
|
:align: center
|
|
|
|
:width: 80.0%
|
2018-05-14 21:15:49 +02:00
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
.. code-block:: yaml
|
2018-05-14 21:15:49 +02:00
|
|
|
|
|
|
|
# Example configuration entry
|
2018-06-13 22:38:49 +02:00
|
|
|
esp32_ble_tracker:
|
2018-05-14 21:15:49 +02:00
|
|
|
|
|
|
|
binary_sensor:
|
2019-10-31 15:34:28 +01:00
|
|
|
# Presence based on MAC address
|
2019-05-12 22:44:59 +02:00
|
|
|
- platform: ble_presence
|
2018-05-14 21:15:49 +02:00
|
|
|
mac_address: AC:37:43:77:5F:4C
|
|
|
|
name: "ESP32 BLE Tracker Google Home Mini"
|
2023-05-11 18:28:30 +02:00
|
|
|
min_rssi: -80dB
|
2019-10-31 15:34:28 +01:00
|
|
|
# Presence based on BLE Service UUID
|
|
|
|
- platform: ble_presence
|
|
|
|
service_uuid: '11aa'
|
|
|
|
name: "ESP32 BLE Tracker Test Service 16 bit"
|
2021-09-02 01:50:31 +02:00
|
|
|
# Presence based on iBeacon UUID
|
|
|
|
- platform: ble_presence
|
|
|
|
ibeacon_uuid: '68586f1e-89c2-11eb-8dcd-0242ac130003'
|
|
|
|
name: "ESP32 BLE Tracker Test Service iBeacon"
|
2019-10-31 15:34:28 +01:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
Service UUID can be 16 bit long, as in the example, but it can also be 32 bit long
|
|
|
|
like ``1122aaff``, or 128 bit long like ``11223344-5566-7788-99aa-bbccddeeff00``.
|
|
|
|
|
|
|
|
|
2018-05-14 21:15:49 +02:00
|
|
|
|
|
|
|
Configuration variables:
|
2018-08-24 22:44:01 +02:00
|
|
|
------------------------
|
2018-05-14 21:15:49 +02:00
|
|
|
|
|
|
|
- **name** (**Required**, string): The name of the binary sensor.
|
2019-10-31 15:34:28 +01:00
|
|
|
- **mac_address** (*Optional*, MAC Address): The MAC address to track for this
|
2021-09-02 01:50:31 +02:00
|
|
|
binary sensor. Note that exactly one of ``mac_address``, ``service_uuid`` or ``ibeacon_uuid``
|
|
|
|
must be present.
|
2021-02-20 22:02:46 +01:00
|
|
|
- **service_uuid** (*Optional*, string): 16 bit, 32 bit, or 128 bit BLE Service UUID
|
2021-09-02 01:50:31 +02:00
|
|
|
which can be tracked if the device randomizes the MAC address. Note that exactly one of
|
|
|
|
``mac_address``, ``service_uuid`` or ``ibeacon_uuid`` must be present.
|
|
|
|
- **ibeacon_uuid** (*Optional*, string): The `universally unique identifier <https://en.wikipedia.org/wiki/Universally_unique_identifier>`__
|
|
|
|
to identify the beacon that needs to be tracked. Note that exactly one of ``mac_address``,
|
|
|
|
``service_uuid`` or ``ibeacon_uuid`` must be present.
|
2021-11-28 19:57:01 +01:00
|
|
|
- **ibeacon_major** (*Optional*, int): The iBeacon major identifier of the beacon that needs
|
2021-09-02 01:50:31 +02:00
|
|
|
to be tracked. Usually used to group beacons, for example for grouping all beacons in the
|
|
|
|
same building.
|
2021-11-28 19:57:01 +01:00
|
|
|
- **ibeacon_minor** (*Optional*, int): The iBeacon minor identifier of the beacon that needs
|
2021-09-02 01:50:31 +02:00
|
|
|
to be tracked. Usually used to identify beacons within an iBeacon group.
|
2018-06-01 18:10:00 +02:00
|
|
|
- **id** (*Optional*, :ref:`config-id`): Manually specify
|
2018-05-14 21:15:49 +02:00
|
|
|
the ID used for code generation.
|
2023-05-11 18:28:30 +02:00
|
|
|
- **min_rssi** (*Optional*, int): at which minimum RSSI level would the component report the device be precent
|
2019-02-17 12:28:17 +01:00
|
|
|
- All other options from :ref:`Binary Sensor <config-binary_sensor>`.
|
2018-05-14 21:15:49 +02:00
|
|
|
|
2018-08-22 22:05:28 +02:00
|
|
|
.. _esp32_ble_tracker-setting_up_devices:
|
|
|
|
|
2018-05-14 21:15:49 +02:00
|
|
|
Setting Up Devices
|
2018-08-24 22:44:01 +02:00
|
|
|
------------------
|
2018-05-14 21:15:49 +02:00
|
|
|
|
|
|
|
To set up binary sensors for specific BLE beacons you first have to know which MAC address
|
|
|
|
to track. Most devices show this screen in some setting menu. If you don't know the MAC address,
|
2018-06-13 22:38:49 +02:00
|
|
|
however, you can use the ``esp32_ble_tracker`` hub without any binary sensors attached and read through
|
2018-05-14 21:15:49 +02:00
|
|
|
the logs to see discovered Bluetooth Low Energy devices.
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
.. code-block:: yaml
|
2018-05-14 21:15:49 +02:00
|
|
|
|
|
|
|
# Example configuration entry for finding MAC addresses
|
2018-08-22 22:05:28 +02:00
|
|
|
esp32_ble_tracker:
|
2018-05-14 21:15:49 +02:00
|
|
|
|
2018-11-23 12:33:59 +01:00
|
|
|
Using the configuration above, first you should see a ``Starting scan...`` debug message at
|
2018-05-14 21:15:49 +02:00
|
|
|
boot-up. Then, when a BLE device is discovered, you should see messages like
|
2018-08-22 22:05:28 +02:00
|
|
|
``Found device AC:37:43:77:5F:4C`` together with some information about their
|
2018-05-14 21:15:49 +02:00
|
|
|
address type and advertised name. If you don't see these messages, your device is unfortunately
|
|
|
|
currently not supported.
|
|
|
|
|
2021-09-02 01:50:31 +02:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry for finding
|
|
|
|
# Service UUIDs and iBeacon UUIDs and identifiers
|
|
|
|
esp32_ble_tracker:
|
|
|
|
|
|
|
|
logger:
|
|
|
|
level: VERY_VERBOSE
|
|
|
|
|
|
|
|
You can increase the :ref:`log level <logger-log_levels>` to ``VERY_VERBOSE`` to review detailed
|
|
|
|
data for each discovered BLE device. This will make ESPHome print Service UUIDs, iBeacon UUIDs,
|
|
|
|
iBeacon major and minor identifiers, BLE manufacturer data, RSSI and other data useful for
|
|
|
|
debugging purposes. Note that this is useful only during set-up and a less verbose log level
|
|
|
|
should be specified afterwards.
|
|
|
|
|
2018-05-14 21:15:49 +02:00
|
|
|
Please note that devices that show a ``RANDOM`` address type in the logs cannot be used for
|
2021-09-02 01:50:31 +02:00
|
|
|
MAC address based tracking, since their MAC-address periodically changes. Instead you can:
|
|
|
|
|
|
|
|
- Create a BLE beacon, set a unique 16 bit, 32 bit or 128 bit Service UUID and track your device
|
|
|
|
based on that. Make sure you don't pick a `GATT Service UUID
|
|
|
|
<https://www.bluetooth.com/specifications/gatt/services/>`__, otherwise generic services
|
|
|
|
might give you incorrect tracking results.
|
|
|
|
|
|
|
|
- Create an iBeacon and track it based on its iBeacon UUID. You can also optionally specify
|
|
|
|
major and minor numbers to match if additional filtering is required. ESPHome offers this
|
|
|
|
functionality via the :doc:`ESP32 Bluetooth Low Energy Beacon </components/esp32_ble_beacon>`
|
|
|
|
component. Several iOS and Android applications, including the open source Home Assistant
|
|
|
|
mobile application also provide means to create iBeacons.
|
2019-10-31 15:34:28 +01:00
|
|
|
|
2018-05-14 21:15:49 +02:00
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
See Also
|
2018-08-24 22:44:01 +02:00
|
|
|
--------
|
2018-06-01 18:10:00 +02:00
|
|
|
|
2019-02-07 13:54:45 +01:00
|
|
|
- :doc:`/components/esp32_ble_tracker`
|
2021-09-02 01:50:31 +02:00
|
|
|
- :doc:`/components/esp32_ble_beacon`
|
2019-02-07 13:54:45 +01:00
|
|
|
- :doc:`/components/binary_sensor/index`
|
2019-05-12 22:44:59 +02:00
|
|
|
- :apiref:`ble_presence/ble_presence.h`
|
2018-08-24 22:44:01 +02:00
|
|
|
- `ESP32 BLE for Arduino <https://github.com/nkolban/ESP32_BLE_Arduino>`__ by `Neil Kolban <https://github.com/nkolban>`__.
|
2019-02-07 13:54:45 +01:00
|
|
|
- :ghedit:`Edit`
|