- Go to SSieb’s github link.
- Click down to the directory ssieb/custom_components/wiegand/
- Ignore the file README.md - that’s the web page text you’re seeing beneath the files list - it doesn’t compile
- Click on each of these three file links:
and save the files to your local PC/desktop/laptop/Mac/whatever. Then upload the files (if you’re on Windows, WinSCP is great for this) to your Home Assistant system, in the path /???/???/homeassistant/esphome/custom_components/wiegand/
Once the python, .h, and .cpp file are present on the Home Assistant system, edit your ESPHome device YAML file like so:
wiegand:
- id: reader
d0: 4
d1: 5
on_tag:
- lambda: ESP_LOGD("TEST", "received tag %s", x.c_str());
id is your ESPHome device name/id
d0: 4 indicates you’re using Pin 4 on your ESP for the Data0 line from the Wiegand reader (Green wire)
d1: 5 indicates you’re using Pin 5 on your ESP for the Data1 line from the Wiegand reader (White wire)
Don’t forget to connect your GND/COM black wire from the Wiegand device to the ESP8266 or ESP32 device, or your signals will never be seen.
On my Ai-Thinker clone ESP32-CAM, when adding the Wiegand custom component, the camera fails to initialize. I’ve designated GPIO 12 and GPIO 13 for the Wiegand data lines. I chose these because they are exposed on the ESP32-Cam device, and only used for the SD card, which isn’t used by ESPHome.
[15:36:01][I][logger:214]: Log initialized
[15:36:01][C][ota:461]: There have been 0 suspected unsuccessful boot attempts.
[15:36:01][D][esp32.preferences:114]: Saving preferences to flash...
[15:36:01][I][app:029]: Running through setup()...
[15:36:02][E][camera.c:1327] camera_init(): gpio_install_isr_service failed (105)
[15:36:02][E][camera.c:1406] esp_camera_init(): Camera init failed with error 0x105
[15:36:02][E][esp32_camera:024]: esp_camera_init failed: ESP_ERR_NOT_FOUND
[15:36:02][E][component:112]: Component esp32_camera was marked as failed.
Here’s the YAML output:
[15:36:06][C][logger:233]: Logger:
[15:36:06][C][logger:234]: Level: DEBUG
[15:36:06][C][logger:235]: Log Baud Rate: 115200
[15:36:06][C][logger:236]: Hardware UART: UART0
[15:36:06][C][wiegand.text_sensor:059]: Wiegand reader:
[15:36:06][C][wiegand.text_sensor:060]: D0 pin: GPIO12
[15:36:06][C][wiegand.text_sensor:061]: D1 pin: GPIO13
[15:36:06][C][esp32_camera:048]: ESP32 Camera:
[15:36:06][C][esp32_camera:049]: Name: esp32cam
[15:36:06][C][esp32_camera:050]: Internal: NO
[15:36:06][C][esp32_camera:052]: Data Pins: D0:5 D1:18 D2:19 D3:21 D4:36 D5:39 D6:34 D7:35
[15:36:06][C][esp32_camera:053]: VSYNC Pin: 25
[15:36:06][C][esp32_camera:054]: HREF Pin: 23
[15:36:06][C][esp32_camera:055]: Pixel Clock Pin: 22
[15:36:06][C][esp32_camera:056]: External Clock: Pin:0 Frequency:20000000
[15:36:06][C][esp32_camera:057]: I2C Pins: SDA:26 SCL:27
[15:36:06][C][esp32_camera:058]: Reset Pin: -1
[15:36:06][C][esp32_camera:088]: Resolution: 1600x1200 (UXGA)
[15:36:06][E][esp32_camera:095]: Setup Failed: ESP_ERR_NOT_FOUND
[15:36:06][C][psram:020]: PSRAM:
[15:36:06][C][psram:021]: Available: YES
and the actual ESPHome YAML code:
esphome:
name: esp32cam-wiegand
esp32:
board: esp32dev
framework:
type: arduino
version: recommended
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: **redacted**
wifi:
ssid: IOT
password: **redacted**
# Example configuration entry
esp32_camera:
name: esp32cam
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
resolution: UXGA
wiegand:
- id: reader
d0: 12
d1: 13
on_tag:
- lambda: ESP_LOGD("TEST", "received tag %s", x.c_str());