# Khoa AS608 Component Example
This example demonstrates how to use the `khoa_as608` component for ESP-IDF to integrate with the AS608 fingerprint sensor.
## Features Demonstrated
- UART communication with AS608 sensor
- Fingerprint enrollment and verification
- Template storage in NVS (Non-Volatile Storage)
- Button controls for mode switching and clearing data
- State machine for handling sensor operations
- Persistent storage of fingerprint templates
## Hardware Requirements
- ESP32 or ESP32-S3 development board
- AS608 fingerprint sensor module
- Push button connected to GPIO 0 (BOOT button)
- UART connection:
- AS608 TX → ESP32 GPIO 16 (RX)
- AS608 RX → ESP32 GPIO 17 (TX)
- AS608 GND → ESP32 GND
- AS608 VCC → ESP32 3.3V
## Software Setup
1. **Install ESP-IDF** (version 5.0 or later)
2. **Create a new project**:
```bash
idf.py create-project khoa_as608_example
cd khoa_as608_example
```
3. **Copy example files** or use this example directory
4. **Configure the project**:
```bash
idf.py menuconfig
```
- Set serial flasher config if needed
5. **Build and flash**:
```bash
idf.py build
idf.py -p PORT flash monitor
```
## Usage
### Button Controls
- **Single Click**: Display current system state
- **Double Click**: Clear all stored templates (both sensor and local storage)
- **Long Press (3 seconds)**: Switch between ENROLL and VERIFY modes
### Operation Modes
#### ENROLL Mode
- Place finger on sensor when prompted
- System will capture fingerprint and store it
- Automatically switches back to VERIFY mode after successful enrollment
#### VERIFY Mode
- Place finger on sensor
- System will search for matching fingerprint
- Displays success/failure with user information
### Initial Setup
On first run, the system will:
1. Perform handshake with AS608 sensor
2. Load any previously stored templates from NVS
3. Start in VERIFY mode
## Configuration
Modify `config.h` to adjust:
- UART pins and baudrate
- Button GPIO and timing
- Buffer sizes
## Component Dependencies
This example uses:
- `Kurtt806/khoa_as608` - The fingerprint sensor component
- `espressif/button` - For button handling
- ESP-IDF drivers (UART, GPIO, NVS)
## Troubleshooting
### Common Issues
1. **"Failed to initialize UART"**
- Check UART pin connections
- Verify AS608 power supply (3.3V)
2. **"Command failed" messages**
- Check sensor connections
- Ensure sensor is powered correctly
- Try power cycling the sensor
3. **No response from sensor**
- Verify baudrate (default 57600)
- Check TX/RX pin assignments
### Debug Logging
Set log level to see more details:
```c
esp_log_level_set("AS608", ESP_LOG_DEBUG);
esp_log_level_set("EXAMPLE", ESP_LOG_DEBUG);
```
## API Reference
The component provides these main functions:
- `as608_state_init()` - Initialize state management
- `template_manager_init()` - Initialize template storage
- `as608_state_start_task()` - Start background processing task
- `send_cmd_PS_*()` - Send commands to sensor
- Button callback registration for UI control
See component header files for complete API documentation.
## License
This example is provided under the MIT License.
idf.py add-dependency "kurtt806/khoa_as608^1.0.1"