Modul Sensor Fingerprint merupakan modul sensor yang berfungsi pemindaian identitas sidik jari manusia yang bersifat unik. Fingerprint dapat digunakan untuk membuka pintu, menyalakan lampu atau yang lainnya, kali ini kita akan mencoba menggunakan fingerprint untuk menyalakan lampu.
1. Alat / Bahan
- Arduino IDE Download
- Library: Fingerprint Download
- Arduino UNO 1 Buah
- Sensor Fingerprint 1 Buah
- Relay 1 Channel 1 Buah
- Kabel Jumper Secukupnya
2. Skema Rangkaian
Gambar Rangkaian Menyalakan Lampu Dengan Sidik Jari Sensor Fingerprint
Keterangan:
- 5V – VCC Fingerprint, VCC Relay
- GND – GND Fingerprint, GND Relay
- D8 – Pin Data Relay
- D2 – TX Fingerprint
- D3 – RX Fingerprint
3. Langkah Kerja
- Pertama, siapkan alat dan bahan yang akan digunakan
- Kedua, lakukan proses wiring dengan menggunakan Gambar skematik rangkaian diatas
- Ketiga, buka software Arduino IDE yang telah terinstal pada laptop/komputer
- Kemudian, unduh semua library di atas dan masukkan libray tersebut dengan cara buka Arduino IDE pilih Sketch->Include Library->Add.Zip Library
- Setelah itu ketikkan sketch program pada halaman Arduino IDE
- Cara mendaftarkan sidik jari dapat kalian pelajari materi pada berikut:
Cara Mendaftarkan Sidik Jari Pada Sensor Fingerprint - Terakhir lakukan proses uploading program kemudian ujicoba.
4. Sketch Program
Dapatkan puluhan ebook gratis dengan registrasi melalui tombol di bawah!
/*************************************************** This is an example sketch for our optical Fingerprint sensor Designed specifically to work with the Adafruit BMP085 Breakout These displays use TTL Serial to communicate, 2 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution ****************************************************/ #include <Adafruit_Fingerprint.h> // On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white // uncomment this line: // #define mySerial Serial1 // 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) // comment these two lines if using hardware serial #include <SoftwareSerial.h> SoftwareSerial mySerial(2, 3); Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); #define relay 8 bool kondisi_relay = false; void setup() { pinMode(relay, OUTPUT); digitalWrite(relay,HIGH); Serial.begin(9600); while (!Serial); // For Yun/Leo/Micro/Zero/... delay(100); Serial.println("\n\nAdafruit finger detect test"); // set the data rate for the sensor serial port finger.begin(57600); if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1) { delay(1); } } finger.getTemplateCount(); Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates"); Serial.println("Waiting for valid finger..."); } void loop() // run over and over again { getFingerprintIDez(); delay(50); //don't ned to run this at full speed. } 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); //Jika sidik jari sama, maka cek_relay(); return finger.fingerID; } //-------------------Prosedur cek relay-------------------// void cek_relay(){ if(kondisi_relay == false){ digitalWrite(relay, LOW); Serial.println("LAMPU ON"); kondisi_relay = true; } else{ digitalWrite(relay, HIGH); Serial.println("LAMPU OFF"); kondisi_relay = false; } }
Kesimpulan:
Sebelum program bekerja pastikan sidik jari kita sudah terdaftar untuk mendaftarkan sidik jadi ada pada materi “Cara Mendaftarkan Sidik Jari Pada Sensor Fingerprint”. Setelah sidik jari terdaftar, cobalah mengakses fingerprint. Jika lampu menyala maka program bekerja dengan baik.
Mau belajar elektronika dasar? Arduino? atau Internet of Things? Ikuti kursus online Indobot Academy!
Kalo saya ganti dengan finger yg lain apakah bisa?untuk wiringnya kalo saya liat tanpa beard board,berarti kabelnya langsung solder ya?