ESP32-Fingerprint/Readme.md

4.8 KiB

ESP Fingerprint (r503) 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 myFingerprintReader MQTT2_DEVICE fingerprintdoor
attr myFingerprintReader comment ToDo neuer Finger:\
- enroll neue ID\
- ID in userreading speichern\
- ID in Hashtable im notify eintragen (Admin oder Standard User)
attr myFingerprintReader event-on-change-reading .*
attr myFingerprintReader event-on-update-reading msg
attr myFingerprintReader setList GREEN:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":150, "count":0}\
BLUE:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":150, "count":0}\
RED:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":150, "count":0}\
PURPLE:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":150, "count":0}\
WHITE:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":150, "count":0}\
CYAN:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":150, "count":0}\
YELLOW:ALWAYS_ON,ALWAYS_OFF,BREATHING,FLASHING,GRADUAL_ON,GRADUAL_OFF fingerprintdoor/led/command {"color":"$EVTPART0","effect":"$EVTPART1","speed":150, "count":0}\
purple_breath fingerprintdoor/led/command {"color":"purple","effect":"breathing","speed":90, "count":0}\
light_master:noArg fingerprintdoor/led/command {"color":"BLUE","effect":"BREATHING","speed":165, "count":0}\
light_master_off:noArg fingerprintdoor/led/command {"color":"BLUE","effect":"GRADUAL_OFF","speed":165, "count":0}\
ready4finger:noArg fingerprintdoor/led/command {"color":"PURPLE","effect":"BREATHING","speed":165, "count":0}\
ready4finger_off:noArg fingerprintdoor/led/command {"color":"PURPLE","effect":"ALWAYS_OFF","speed":165, "count":0}\
custom fingerprintdoor/led/command {"color":"$EVTPART1","effect":"$EVTPART2","speed":$EVTPART3, "count":$EVTPART4}\
off:noArg fingerprintdoor/led/command {"color":"RED","effect":"ALWAYS_OFF","speed":20, "count":0}\
cancel:noArg fingerprintdoor/cancel_enroll\
enroll fingerprintdoor/enroll $EVTPART1\
delete fingerprintdoor/delete $EVTPART1\
\

attr myFingerprintReader userReadings ID1 {"Person 1"},\
ID2	{"Person 2"},\
ID3	{"Person 3"}

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

Example

Device Readings

Setlist

Credits

ESPHome project

Helpful ESPHome tutorials