Cara Gampang Kegiatan Fingerprint Dengan Arduino (Enroll, Fingeprint, Delete)
Karena banyak seruan dari agan-agan penghuni Grup WhatsApp Kelas Robot, jadinya aku luangkan waktu untuk menciptakan Tutorial Arduino dengan FingerPrint Sensor.
Yang perlu kau siapkan adalah:
- 1x Arduino Uno BELI
- 1x FingerPrint Sensor BELI
Kemudian rangkai menyerupai pada gambar dibawah ini:
Sebelum masuk pemrograman, Kamu WAJIB untuk mendownload Library FingerPrint Sensor, kemudian add ke Arduino IDE kamu.
Download Adafruit Fingerprint Sensor Library Master
Bagi yang belum tau cara ADD Library ke Arduino IDE, silahkan ikuti Tutorial dibawah ini:
Bagaimana Cara Memasukan Library Ke Aplikasi Arduino IDE?
***
#1 ENROLL
Selanjutnya yakni kita akan Upload Program Enroll, yaitu Program untuk mendaptarkan Jari kau ke Fingerprint Sensor. Silahkan gunakan kegiatan dibawah ini:
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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | #include <Adafruit_Fingerprint.h> #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); uint8_t id; void setup(){ Serial.begin(9600); finger.begin(57600); if (finger.verifyPassword()) { Serial.println("FingerPrint Sensor Ditemukan!"); } else { Serial.println("FingerPrint Sensor Tidak Ditemukan! :("); while (1) { delay(1); } } } void loop(){ ENROLL(); } //---------------------------------------ENROLL--------------------------------------------------------------// void ENROLL(){ Serial.println("Ready to enroll a fingerprint!"); Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as..."); id = readnumber(); if (id == 0) {// ID #0 not allowed, try again! return; } Serial.print("Enrolling ID #"); Serial.println(id); while (! getFingerprintEnroll() ); } //------------------------------------PROSES ENROLL----------------------------------------------------------// uint8_t readnumber(void) { uint8_t num = 0; while (num == 0) { while (! Serial.available()); num = Serial.parseInt(); } return num; } //----RETURN NUM-------------------// uint8_t getFingerprintEnroll() { int p = -1; Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id); while (p != FINGERPRINT_OK) { p = finger.getImage(); switch (p) { case FINGERPRINT_OK: Serial.println("Image taken"); break; case FINGERPRINT_NOFINGER: Serial.println("."); break; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); break; case FINGERPRINT_IMAGEFAIL: Serial.println("Imaging error"); break; default: Serial.println("Unknown error"); break; } } // OK success! p = finger.image2Tz(1); 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; } Serial.println("Remove finger"); delay(2000); p = 0; while (p != FINGERPRINT_NOFINGER) { p = finger.getImage(); } Serial.print("ID "); Serial.println(id); p = -1; Serial.println("Place same finger again"); while (p != FINGERPRINT_OK) { p = finger.getImage(); switch (p) { case FINGERPRINT_OK: Serial.println("Image taken"); break; case FINGERPRINT_NOFINGER: Serial.print("."); break; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); break; case FINGERPRINT_IMAGEFAIL: Serial.println("Imaging error"); break; default: Serial.println("Unknown error"); break; } } // OK success! p = finger.image2Tz(2); 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! Serial.print("Creating model for #"); Serial.println(id); p = finger.createModel(); if (p == FINGERPRINT_OK) { Serial.println("Prints matched!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_ENROLLMISMATCH) { Serial.println("Fingerprints did not match"); return p; } else { Serial.println("Unknown error"); return p; } Serial.print("ID "); Serial.println(id); p = finger.storeModel(id); if (p == FINGERPRINT_OK) { Serial.println("Stored!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_BADLOCATION) { Serial.println("Could not store in that location"); return p; } else if (p == FINGERPRINT_FLASHERR) { Serial.println("Error writing to flash"); return p; } else { Serial.println("Unknown error"); return p; } } //---------------------------------------ENROLL END--------------------------------// |
Jika sudah DONE UPLOADING, silahkan buka Serial Monitor untuk mendaptarkan jari kamu.
Silahkan masukan angka dari 1-127, nomer untuk menyimpan jari kau kemudian klik Send atau tekan Enter.
Lalu letakan Jari kau ke Fingerprint sensor.
Kemudian lepas Jari Kamu, lalu letakan lagi untuk Konfirmasi.
Jika sudah ada keterangan Stored, berarti jari kau berhasil di daftarkan.
***
#2 FINGERPRINT
Setelah selesai melaksanakan Enroll, selanjutnya kau dapat coba kegiatan Fingerprint, yaitu kegiatan untuk cek jari kau terdaftar atau tidak. Silahkan gunakan kegiatan dibawah ini:
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 | #include <Adafruit_Fingerprint.h> #include <SoftwareSerial.h> SoftwareSerial mySerial(2, 3); Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); void setup(){ Serial.begin(9600); finger.begin(57600); if (finger.verifyPassword()) { Serial.println("FingerPrint Sensor Ditemukan!"); } else { Serial.println("FingerPrint Sensor Tidak Ditemukan! :("); while (1) { delay(1); } } } void loop(){ FINGERPRINT(); } //----------------------------------------------------FINGERPRINt----------------------------------------------// void FINGERPRINT(){ getFingerprintIDez(); delay(50); } //----------------------------------------------------PROSES FINGERPRINT--------------------------------------// uint8_t getFingerprintID() { 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.fingerFastSearch(); 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); return finger.fingerID; } // returns -1 if failed, otherwise returns ID # int getFingerprintIDez() { uint8_t p = finger.getImage(); if (p != FINGERPRINT_OK) return -1; p = finger.image2Tz(); if (p != FINGERPRINT_OK) return -1; p = finger.fingerFastSearch(); if (p != FINGERPRINT_OK) return -1; // found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence); return finger.fingerID; } //--------------------------------END FINGERPRINT----------------------------------------------// |
jika sudah DONE UPLOADING, silahkan buka Serial Monitor, kemudian letakan jari kau di sensor.
Lalu kalau muncul Found ID, berarti jari kau sudah terdaftar di Fingerprint Sensor.
***
#3 DELETE
Program terakhir yakni kegiatan Delete, ini fungsinya untuk menghapus data Jari yang sudah terdaftar di Fingerprint Sensor. Silahkan gunakan kegiatan dibawah ini:
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 | #include <Adafruit_Fingerprint.h> #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); void setup(){ Serial.begin(9600); finger.begin(57600); if (finger.verifyPassword()) { Serial.println("FingerPrint Sensor Ditemukan!"); } else { Serial.println("FingerPrint Sensor Tidak Ditemukan! :("); while (1) { delay(1); } } } void loop(){ DELETE(); } //------------------------------------------DELETE-----------------------------------// void DELETE(){ Serial.println("Please type in the ID # (from 1 to 127) you want to delete..."); uint8_t id = readnumber(); if (id == 0) {// ID #0 not allowed, try again! return; } Serial.print("Deleting ID #"); Serial.println(id); deleteFingerprint(id); } //------------------------------------------PROSES DELETE---------------------------// uint8_t readnumber(void) { uint8_t num = 0; while (num == 0) { while (! Serial.available()); num = Serial.parseInt(); } return num; } //----RETURN NUM-------------------// uint8_t deleteFingerprint(uint8_t id) { uint8_t p = -1; p = finger.deleteModel(id); if (p == FINGERPRINT_OK) { Serial.println("Deleted!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_BADLOCATION) { Serial.println("Could not delete in that location"); return p; } else if (p == FINGERPRINT_FLASHERR) { Serial.println("Error writing to flash"); return p; } else { Serial.print("Unknown error: 0x"); Serial.println(p, HEX); return p; } } |
jika sudah DONE UPLOADING, silahkan buka Serial Monitor.
Lalu masukan no ID yang ingin kau hapus, kemudian klik Send atau Tekan Enter.
Jika sudah ada keterangan Deleted!, artinya data jari yang terdaptar di Fingerprint Sensor sudah terhapus. Silahkan kau coba letakan lagi jarinya di sensor untuk mengetes.
***
Oke sekian Tutorial kali ini, kalau kau berhasil membuatnya silahkan kau Share di Kolom komentar ya. Thanks
Komentar
Posting Komentar