ESP32-Fingerprint/Readme.md

3.7 KiB

ESP Fingerprint for FHEM

ESPHome based firmware for ESP32 or ESP8266 to manage and use a R503-RGB Fingerprint Reader over MQTT.

Supported features of my code:

  • Control R503 LED
    • LED colors: RED, BLUE, PURPLE, GREEN, YELLOW, CYAN and WHITE
    • LED effects: BREATHING, FLASHING, ALWAYS_ON, ALWAYS_OFF, GRADUAL_ON and GRADUAL_OFF
  • enroll a fingerprint to the reader
  • delete fingerprint

Getting started

Config pins and effects

Set correct GPIO Pins in fingerprintdoor.yaml

# -----------------------------
  # Config
  # -----------------------------
  devicename:           fingerprintdoor
  reader_rx_pin:        GPIO16
  reader_tx_pin:        GPIO17
  reader_sensor_pin:    GPIO5
  speed_flash:          "100"
  count_flash:          "4"
  speed_breath:         "75"
  count_breath:         "7"
  speed_gradual_off:    "200"
  speed_gradual_on:     "35"

Wifi and MQTT

Create a secrets.yamlfile in your project folder

wifi_ssid: "YourSSID"
wifi_password: "YourPASS"
ota_password: "OtaPass"
mqtt_ip: "192.168.1.1"
mqtt_user: ""
mqtt_password: ""

Flash to ESP

Follow this GUIDE to install ESPHome and flash it to your device with:

esphome run fingerprintdoor.yaml --device COM4

Note: COM Port may differ, change it to your COM port

FHEM MQTT2 device

defmod myFingerDevice MQTT2_DEVICE fingerprintdoor
attr myFingerDevice event-on-change-reading .*
attr myFingerDevice setList GREEN:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":120, "count":0}\
BLUE:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":120, "count":0}\
RED:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":120, "count":0}\
PURPLE:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":120, "count":0}\
WHITE:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":120, "count":0}\
CYAN:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":120, "count":0}\
YELLOW:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":120, "count":0}\
custom fingerprintdoor/led/command {"color":"$EVTPART1","effect":"$EVTPART2","speed":$EVTPART3, "count":$EVTPART4}\
cancel:noArg fingerprintdoor/cancel_enroll\
enroll fingerprintdoor/enroll $EVTPART1\
delete fingerprintdoor/delete $EVTPART1\
\

Usage in FHEM

Enroll new finger

Syntax:

set <fhem device name> enroll <finger ID>

Example:

set myFingerprint enroll 1

Note: Enrollment cancel ist possible with:

set myFingerprint cancel

Delete finger

Syntax:

set <fhem device name> delete <finger ID>

Example:

set myFingerprint delete 1

Set Led color and effect

Syntax:

set <fhem device name> <color> <effect> <speed> <count>

Example:

set myFingerprint blue flash 120 3

Note: If <count>=0 for effect "flashing" or "breathing" will run continously and can be interrupted

Credits

ESPHome project

Helpful ESPHome tutorials