Skip to main content

MicroPython driver for DFRobot SEN0359 ID809 capacitive fingerprint sensor

Project description

DFRobot ID809 MicroPython Driver

PyPI version License: MIT

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 machine viene 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 communication
  • LEDMode - LED mode constants
  • LEDColor - LED color constants
  • Error - 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sen0359-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sen0359-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file sen0359-0.1.0.tar.gz.

File metadata

  • Download URL: sen0359-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sen0359-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a5e126ec875bbf0fd73e0ba85e0d86a8b1a83b706b9e45d03a84b79d759af73d
MD5 abe8ea4b387a9b464f2a5c5bae9b6d72
BLAKE2b-256 01e819c63ab93360ea6432e741b1dccdb9f229a351a140fe6b79696354d01c16

See more details on using hashes here.

File details

Details for the file sen0359-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sen0359-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sen0359-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dabb2d64f17c9744addd3f9b50610bde471dc7b6f97dcce90041bb55549962af
MD5 5ce742c478f07ece439eb4e9ae84ea6a
BLAKE2b-256 27e201cdd4345a47a82d877784dce226d61bc8fd6356326591a0a3f361f6be2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page