Hello. I am creating a credit card shaped device which uses 3V battery-powered electrochromic switchable smart film (a paper-like material which turns transparent when on and opaque when off). I am using a SEN0348 DFRobot fingerprint sensor with the ID809.h library to control the switchable film's on and off function. After a fingerprint is enrolled on startup, the fingerprint scanner should act like a switch and turn on the film (transparent) if recognised. If not recognised, the film stays as is (blurred). I am currently using a breadboard but would like to remove that eventually.
I am unsure of how to wire the film, there are two 15 by 15 (cm) HOHOFILM film pieces which run on two AA batteries, 3V I believe. Also, the battery pack has a button to turn film on/off, so I don't of how to simulate the fingerprint sensor causing the switch instead of the button. The film has two wires, a red positive and black negative. The But I have checked the schematics of the SEN0348 and I'm pretty sure that has been wired correctly. I am using an official Arduino Nano A000005. In the end, I would like everything to be powered by a separate power supply as the credit card case has to be portable obviously.
The main issue I am facing right now is with the fingerprint sensor. When I open the serial monitor, the fingerprint sensor initializes and starts to try and enroll even if my finger is not on the sensor. Also, I don't see any LED light up on the fingerprint sensor (don't know if the SEN0348 has an LED). So whenever I open serial monitor and whether place my finger on the sensor or not, the sensor goes ahead and tries to enroll but the serial monitor says: Failed to enroll fingerprint. Error: 255. I cannot find anything online about this issue. I have bulb shaped two pin LEDs to test with instead of the film, but I don't know if the wiring will be the same.
Please help me wire the electrochromic film and solve the Error Code 255 problem.
Code:
<#include <DFRobot_ID809.h>
DFRobot_ID809 fingerprintSensor;
const int ELECTROCHROMIC_FILM_PIN = 9;
bool printFlag = false; // Flag to indicate whether to print the message or not
unsigned long lastPrintTime = 0; // Variable to store the time of the last print
void setup() {
Serial.begin(9600);
while (!Serial);
fingerprintSensor.begin(Serial); // Use Serial for UART communication
Serial.println("Fingerprint sensor initialized!");
pinMode(ELECTROCHROMIC_FILM_PIN, OUTPUT);
Serial.println("Place your finger on the sensor to enroll an initial fingerprint:");
enrollFingerprint(); // Enroll a fingerprint during setup
}
void loop() {
if (Serial.available()) {
char command = Serial.read();
if (command == 'e') {
enrollFingerprint(); // Allow manual enrollment if needed
}
}
if (fingerprintSensor.detectFinger()) {
if (fingerprintSensor.search()) {
Serial.println("Fingerprint match found!");
digitalWrite(ELECTROCHROMIC_FILM_PIN, HIGH);
Serial.println("Electrochromic film activated!");
delay(60000);
digitalWrite(ELECTROCHROMIC_FILM_PIN, LOW);
Serial.println("Electrochromic film deactivated.");
} else {
if (!printFlag) {
Serial.println("Fingerprint not recognized!");
lastPrintTime = millis(); // Update the last print time
printFlag = true; // Set the print flag to true
}
}
}
// Check if 5 seconds have passed since the last print
if (millis() - lastPrintTime >= 5000) {
// Reset the print flag after 5 seconds
printFlag = false;
}
delay(50);
}
void enrollFingerprint() {
Serial.println("Place your finger on the sensor for enrollment:");
int id = fingerprintSensor.getEmptyID(); // Find an empty ID to store the fingerprint
if (id == -1) {
Serial.println("No empty ID available.");
return;
}
while (!fingerprintSensor.collectionFingerprint(id)) {
delay(100);
Serial.println("Place your finger again.");
}
Serial.println("Fingerprint data being processed...");
delay(2000);
int result = fingerprintSensor.storeFingerprint(id);
if (result == 0) {
Serial.println("Fingerprint enrolled successfully!");
} else {
Serial.println("Failed to enroll fingerprint. Error: " + String(result));
}
}
Wiring connections (fingerprint sensor to nano):
Yellow with yellow jumper(TX) to Nano RX0 pin
Black with brown jumper (RX) to Nano TX1 pin
White with white jumper (power/3.3V) to Nano 3.3V pin
Red with orange jumper (GND) to Nano GND pin
Green and Blue unused
Electrochromic film link: Amazon Electrochromic 15cmx15cm Film HOHOFILM
Fingerprint sensor link: DFRobot SEN0348 fingerprint sensor


Link to electrochromic film video: electrochromic film video
P.S: This is my first post so if I missed something sorry!
P.S.S:The project needs to be done by February 20, that is my competition deadline.
23 posts - 3 participants