Video is below, click to view…
In this episode I look at a particular type of fingerprint sensor, the JM-101. It goes through how to store fingerprints on the device, how to clear them and how to check for a stored print. Spoiler alert: I’m not too happy with this particular sensor, with that said here are some affiliate links!
Finger print sensor: https://amzn.to/3Yv0iR8
Arduino Uno Official: https://amzn.to/3Yv0iR8
Arduino Uno Clone: https://amzn.to/3I77Dkv
The source code for the safe using the servo motor is below, showing how I read the scanner and act on it. Note that because this sensor is not very good I have a cheat pin that closes the door if required (just ground pin 4)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
#include <Adafruit_Fingerprint.h> #include <Servo.h> // This library is installed by default, no need to download and install it. #define CheatOpenPin 4 #define CheatClosePin 5 #if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__) // For UNO and others without hardware serial, we must use software serial... // pin #2 is IN from sensor (GREEN wire) // pin #3 is OUT from arduino (WHITE wire) // Set up the serial port to use softwareserial.. SoftwareSerial mySerial(2, 3); #else // On Leonardo/M0/etc, others with hardware serial, use hardware serial! // #0 is green wire, #1 is white #define mySerial Serial1 #endif Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); Servo myservo; // create servo object to control a servo int StartPos=125; int EndPos=10; int ServoPos=StartPos; void setup() { pinMode(CheatOpenPin,INPUT_PULLUP); pinMode(CheatClosePin,INPUT_PULLUP); Serial.begin(9600); myservo.attach(9); // attaches the servo on pin 9 to the servo object myservo.write(StartPos); // set servo to start pos Serial.println("Server moved"); while (!Serial); // For Yun/Leo/Micro/Zero/... delay(100); Serial.println("\n\nDoor open example"); // set the data rate for the sensor serial port finger.begin(57600); delay(5); if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1) { delay(1); } } Serial.println(F("Reading sensor parameters")); finger.getParameters(); Serial.print(F("Status: 0x")); Serial.println(finger.status_reg, HEX); Serial.print(F("Sys ID: 0x")); Serial.println(finger.system_id, HEX); Serial.print(F("Capacity: ")); Serial.println(finger.capacity); Serial.print(F("Security level: ")); Serial.println(finger.security_level); Serial.print(F("Device address: ")); Serial.println(finger.device_addr, HEX); Serial.print(F("Packet len: ")); Serial.println(finger.packet_len); Serial.print(F("Baud rate: ")); Serial.println(finger.baud_rate); finger.getTemplateCount(); if (finger.templateCount == 0) { Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example."); } else { Serial.println("Waiting for valid finger..."); Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates"); } } void loop() // run over and over again { getFingerprintID(); delay(50); //don't ned to run this at full speed. } uint8_t getFingerprintID() { // CHECK FOR CHEAT PINS Serial.println(digitalRead(CheatClosePin)); if(digitalRead(CheatClosePin)==LOW) MoveDoor(false); uint8_t p = finger.getImage(); switch (p) { case FINGERPRINT_OK: Serial.println("Image taken"); break; case FINGERPRINT_NOFINGER: //Serial.println("No finger detected"); return p; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return p; case FINGERPRINT_IMAGEFAIL: Serial.println("Imaging error"); return p; default: Serial.println("Unknown error"); return p; } // OK success! p = finger.image2Tz(); switch (p) { case FINGERPRINT_OK: Serial.println("Image converted"); break; case FINGERPRINT_IMAGEMESS: Serial.println("Image too messy"); return p; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return p; case FINGERPRINT_FEATUREFAIL: Serial.println("Could not find fingerprint features"); return p; case FINGERPRINT_INVALIDIMAGE: Serial.println("Could not find fingerprint features"); return p; default: Serial.println("Unknown error"); return p; } // OK converted! p = finger.fingerSearch(); if (p == FINGERPRINT_OK) { Serial.println("Found a print match!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_NOTFOUND) { Serial.println("Did not find a match"); return p; } else { Serial.println("Unknown error"); return p; } // found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence); // If ID is 1 then open door, if 2 close it. if(finger.fingerID==1) if(ServoPos>=StartPos) MoveDoor(true); else MoveDoor(false); return finger.fingerID; } void MoveDoor(bool Direction) { if(Direction) { Serial.println("Opening Door"); // open door for(;ServoPos>EndPos;ServoPos--) { myservo.write(ServoPos); // set servo to start pos delay(20); } Serial.println(ServoPos); } else { Serial.println("Closing Door"); for(;ServoPos<StartPos;ServoPos++) { myservo.write(ServoPos); // set servo to start pos delay(20); } Serial.println(ServoPos); } } |
This is unrelated to this video, but after browsing forums, and discords and watching videos i’m running out of places to turn for assistance.
I’m running an esp32 and including your dac audio library.
https://pastebin.com/m2pn0bEU
That’s my code for my esp, the latest variation, previous variations played the audio similar to the way your wav example did, just a straight DacAudio.Play(&whatever);, and it resulted in the transit audio, the wolf and the rooster all playing correctly, but after the transit audio looped a few hundred times It would not and could not play the clunk audio at the end, it would just be a garbled clicking noise. Maybe a buffer issue.
I figured maybe it’s using too much buffer so i’ve started messing with the queue options in your library, and now i have a similar but opposite problem. I get no sound with the current code, except for when it’s finished opening or closing. I get the clunk audio, but no rooster, no wolf, no transit.
Could I get a bit of your time to help?
Sorry for such a late reply. My site has been plagued with unsavoury comments for some time and I get so many that I put off ploughing through them. I’m afraid I don’t have time to look into your issue, I’ve not even time for new content at the moment. However I will bare what you say in mind. It sounds like a possible memory leak, perhaps I’m not releasing some memory somewhere and then the system ends up getting itself in a bad state.
I’m going to be looking at DacAudio in the next 2 – 4 weeks. I think something may have changed in the ESP32 libraries
Hello, sorry for being at the wrong place but it’s the only way I found to contact you.
I’ve been using your XT_DAC_audio libraries with great success for roleplay props until recently.
I suspect something changed on the ESP32 boards “lib” on the arduino IDE and nothing can be compiled anymore, even your examples 🙁
The error text is quite big. If needed my email is: maximefavre@gmail.com I’d be happy to help.
Sincerely
Max
Hi, sorry for lateness of reply, the site gets so much spam in the comments that I only pop in now and then to tidy up. I will look at this in the next 2-4 weeks.