DFRobot ID809 MicroPython Driver
MicroPython driver for the DFRobot SEN0359 capacitive fingerprint sensor (ID809).
This is a direct port of the official DFRobot_ID809 C++ library to MicroPython.
Features
- Full I2C communication support
- Fingerprint enrollment (up to 80 fingerprints)
- Fingerprint verification and search
- LED control (colors and modes)
- Device configuration (security level, duplicate check, self-learning)
- Low power sleep mode
- Comprehensive error handling
Hardware
- Sensor: DFRobot SEN0359
- Capacitive Fingerprint Sensor: 80
- Interface: I2C (default address: 0x1F)
- Voltage: 3.3V / 5V compatible
Installation
From PyPI (recomendado)
pip install SEN0359
Con dependencias de desarrollo (para PC)
# Incluye stubs para autocompletado en IDE + herramientas de testing
pip install SEN0359[dev]
# Solo stubs para ESP32
pip install SEN0359[stubs-esp32]
# Solo stubs para Raspberry Pi Pico (RP2)
pip install SEN0359[stubs-rp2]
Manual Installation (MicroPython)
Copy the dfrobot_id809 folder to your MicroPython device's lib directory.
Nota: El módulo
machineviene integrado en MicroPython y no necesita instalarse por separado.
Wiring
| Sensor Pin | ESP32 Pin | Description |
|---|---|---|
| VCC | 3.3V/5V | Power |
| GND | GND | Ground |
| SDA | GPIO21 | I2C Data |
| SCL | GPIO22 | I2C Clock |
Quick Start
from machine import I2C, Pin
from dfrobot_id809 import DFRobot_ID809_I2C, LEDColor, LEDMode
# Initialize I2C
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
# Create sensor instance
sensor = DFRobot_ID809_I2C(i2c)
# Initialize sensor
if sensor.begin():
print("Sensor initialized!")
# Turn on green LED
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.GREEN)
# Check connection
if sensor.is_connected():
print("Sensor connected!")
else:
print("Sensor initialization failed!")
Usage Examples
Enroll a Fingerprint
from dfrobot_id809 import DFRobot_ID809_I2C, LEDColor, LEDMode, DELALL
def enroll_fingerprint(sensor):
# Get first available ID
empty_id = sensor.get_empty_id()
if empty_id == 0:
print("No space available!")
return False
print(f"Enrolling fingerprint at ID: {empty_id}")
# Collect fingerprint 3 times
for i in range(3):
print(f"Place finger ({i+1}/3)...")
sensor.ctrl_led(LEDMode.BREATHING, LEDColor.BLUE)
# Wait for fingerprint
if sensor.collection_fingerprint(timeout=10000) == 0:
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.GREEN)
print("Captured!")
# Wait for finger removal
while sensor.detect_finger():
pass
else:
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.RED)
print(f"Error: {sensor.get_error_description()}")
return False
# Store fingerprint
if sensor.store_fingerprint(empty_id) == 0:
print(f"Fingerprint stored at ID {empty_id}")
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.GREEN)
return True
else:
print("Storage failed!")
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.RED)
return False
Verify a Fingerprint
def verify_fingerprint(sensor):
print("Place finger to verify...")
sensor.ctrl_led(LEDMode.BREATHING, LEDColor.BLUE)
# Capture fingerprint
if sensor.collection_fingerprint(timeout=10000) == 0:
# Search in database
result = sensor.search()
if result > 0:
print(f"Match found! ID: {result}")
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.GREEN)
return result
else:
print("No match found")
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.RED)
return 0
else:
print(f"Capture error: {sensor.get_error_description()}")
return -1
Delete Fingerprints
# Delete specific fingerprint
sensor.del_fingerprint(1) # Delete ID 1
# Delete all fingerprints
sensor.del_fingerprint(DELALL)
LED Control
from dfrobot_id809 import LEDColor, LEDMode
# Solid colors
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.GREEN)
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.RED)
sensor.ctrl_led(LEDMode.KEEPS_ON, LEDColor.BLUE)
# Breathing effect
sensor.ctrl_led(LEDMode.BREATHING, LEDColor.CYAN)
# Blinking (5 times)
sensor.ctrl_led(LEDMode.FAST_BLINK, LEDColor.YELLOW, blink_count=5)
# Turn off
sensor.ctrl_led(LEDMode.NORMAL_CLOSE, LEDColor.GREEN)
Device Information
# Get device info
info = sensor.get_device_info()
print(f"Device info: {info}")
# Get enrolled count
count = sensor.get_enroll_count()
print(f"Enrolled fingerprints: {count}")
# Check if ID is registered
status = sensor.get_status_id(1)
print(f"ID 1 status: {'registered' if status else 'empty'}")
# Get security level (1-5)
level = sensor.get_security_level()
print(f"Security level: {level}")
API Reference
Classes
DFRobot_ID809_I2C- Main sensor class for I2C communicationLEDMode- LED mode constantsLEDColor- LED color constantsError- Error code constants and descriptions
Main Methods
| Method | Description |
|---|---|
begin() |
Initialize sensor |
is_connected() |
Check connection |
detect_finger() |
Detect finger presence |
collection_fingerprint(timeout) |
Capture fingerprint |
store_fingerprint(id) |
Store captured fingerprint |
search() |
Search fingerprint in database |
verify(id) |
Verify against specific ID |
del_fingerprint(id) |
Delete fingerprint(s) |
ctrl_led(mode, color, blink_count) |
Control LED |
get_enroll_count() |
Get enrolled count |
get_empty_id() |
Get first available ID |
enter_sleep_state() |
Enter low power mode |
Error Codes
from dfrobot_id809 import Error
# Get error description
error_msg = Error.get_description(error_code)
License
MIT License - see LICENSE file.
Credits
- Original C++ library: DFRobot
Metadata
Release files for SEN0359 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sen0359-0.1.0.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sen0359-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.3 kB
Release files / sen0359-0.1.0.tar.gz
| Download URL | sen0359-0.1.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5e126ec875bbf0fd73e0ba85e0d86a8b1a83b706b9e45d03a84b79d759af73d
|
|
BLAKE2b-256 checksum How to use checksums |
01e819c63ab93360ea6432e741b1dccdb9f229a351a140fe6b79696354d01c16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / sen0359-0.1.0-py3-none-any.whl
| Download URL | sen0359-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dabb2d64f17c9744addd3f9b50610bde471dc7b6f97dcce90041bb55549962af
|
|
BLAKE2b-256 checksum How to use checksums |
27e201cdd4345a47a82d877784dce226d61bc8fd6356326591a0a3f361f6be2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|