Part 1: Bluetooth proxy
What it does: the proxy forwards BLE advertisements, and optionally active connections, from any room to Home Assistant, which aggregates all proxies with any local USB adapter. Only BLE is supported. The ESPHome docs describe the following recommended Wi-Fi configuration (add your own secrets). The esp-idf framework is recommended over Arduino because it uses less memory.
Code: Select all
substitutions:
name: my-bluetooth-proxy
esphome:
name: ${name}
name_add_mac_suffix: true
esp32:
variant: esp32
framework:
type: esp-idf
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
api:
encryption:
key: !secret my_bluetooth_proxy_api_key
ota:
platform: esphome
esp32_ble_tracker:
bluetooth_proxy:
active: true
Tips from the docs:
- Active connections default to on for ESP32, with 3 connection slots by default. Devices that stay connected all the time (some locks and thermostats) hold one slot permanently. Passive broadcast sensors, such as many BTHome ones, do not use slots.
- More slots use RAM. The docs recommend no more than 5 on ESP32 for stability, and say Ethernet-connected proxies handle 4 reliably.
- If your board overheats, try passive scanning (scan_parameters: active: false under esp32_ble_tracker) if your devices do not need active scans.
- Keep it away from your router and switches, at least about 3 metres, and close to the BLE devices.
- Not every BLE device works. Search the Home Assistant integration list for yours.
Part 2: PN532 NFC/RFID reader (I2C)
Parts: an ESP32 board and a PN532 module. These modules have DIP switches for SPI or I2C. The ESPHome page says I2C is usually switch 1 ON, switch 2 OFF, and SPI the reverse, and you should follow the table printed on your board. Wire power (check your module's voltage), GND, SDA and SCL.
Code: Select all
i2c:
sda: GPIO21
scl: GPIO22
pn532_i2c:
update_interval: 1s
on_tag:
then:
- homeassistant.tag_scanned: !lambda 'return x;'
In Home Assistant:
- Open the Tags panel and scan a tag. The tag appears and you can name it. A tag ID is also a trigger you can use in automations.
- Create an automation with a Tag trigger for that tag, then an action such as turning on a scene or starting a playlist.
- The Tags docs include an RFID jukebox example that maps tag IDs to media content. Copy that pattern for a kids' music player.
- Use this for convenience tasks. As noted in the overview thread, UIDs are not strong credentials. Do not use this reader to unlock a door or disarm an alarm.
- Mount the reader indoors, and give the ESP32 a unique API encryption key.
- Put ESPHome devices on a network segment that can reach Home Assistant. Note that mDNS discovery does not cross VLANs.
- Check that your PN532 module's voltage and logic levels match your ESP32 board's before connecting.
Question for the group: where have you placed your Bluetooth proxies, and how many BLE devices does each one handle? Has anyone built a reliable NFC scan point (jukebox, scenes) with ESPHome?