ESP32 Bluetooth Low Energy Beacon¶
esp32_ble_beacon component creates a Bluetooth Low Energy Beacon with your ESP32 device.
Beacons are BLE devices that repeatedly just send out a pre-defined packet of data. This packet
can then be received by devices like smartphones and can then be used to track a phone’s location.
The BLE software stack on the ESP32 consumes a significant amount of RAM on the device.
Crashes are likely to occur if you include too many additional components in your device’s configuration. Memory-intensive components such as Voice Assistant and other audio components are most likely to cause issues.
# Example configuration entry esp32_ble_beacon: type: iBeacon uuid: 'c29ce823-e67a-4e71-bff2-abaa32e77a98'
type (Required): The type of beacon to create, currently only supports
uuid (Required): The universally unique identifier to identify the beacon.
id (Optional, ID): Manually specify the ID for code generation.
major (Optional, int): The iBeacon major identifier of this beacon. Usually used to group beacons, for example for grouping all beacons in the same building, but has no effect if the BLE receiver doesn’t use it. Defaults to
minor (Optional, int): The iBeacon minor identifier of this beacon. Usually used to identify beacons within an iBeacon group. Defaults to
min_interval (Optional, Time): The iBeacon minimum transmit interval in milliseconds from 20 to 10240. Setting this less than
max_intervalgives the BLE hardware a better chance to avoid collisions with other BLE transmissions. Defaults to the iBeacon specification’s defined interval:
max_interval (Optional, Time): The iBeacon maximum transmit interval in milliseconds from 20 to 10240. Setting this greater than
min_intervalgives the BLE hardware a better chance to avoid collisions with other BLE transmissions. Defaults to the iBeacon specification’s defined interval:
measured_power (Optional, int): The RSSI of the iBeacon as measured 1 meter from the device. This is used to calibrate the ranging calculations in iOS. The procedure for setting this value can be found in Apple’s Getting Started with iBeacon PDF under the heading Calibrating iBeacon. Between -128 to 0. Defaults to
tx_power (Optional, int): The transmit power of the iBeacon in dBm. One of -12, -9, -6, -3, 0, 3, 6, 9. Defaults to
First, you’ll need to set up the configuration for ESPHome. Just copy the configuration above and change the UUID to something unique. For example, you can copy this randomly generated UUID:
Then, just compile and flash the ESP32.
When everything is set up correctly, you should see a show up using your iBeacon scanner of choice. On iPhones, this should already work from the Bluetooth screen (not tested), on Android, you will need to use an app like “Beacon Scanner” by Nicolas Bridoux.
For using these beacons to track the location of your phone, you will need to use another app. For example, I used this guide by the owntracks app to let my Home Automation system know when I’m home or away. Another nice Android app is Beacon MQTT. It can work with multiple beacons simultaneously.