0% found this document useful (0 votes)
20 views

Biometric Attendance System Using Python and Raspberry PiwithMySQLDatabase

Uploaded by

damilola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Biometric Attendance System Using Python and Raspberry PiwithMySQLDatabase

Uploaded by

damilola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/383876359

Fingerprint Attendance System using Raspberry Pi and MySQL Database

Thesis · June 2024


DOI: 10.13140/RG.2.2.23701.33764

CITATIONS READS
0 170

2 authors, including:

Abraham Tefera

1 PUBLICATION 0 CITATIONS

SEE PROFILE

All content following this page was uploaded by Abraham Tefera on 09 September 2024.

The user has requested enhancement of the downloaded file.


ADDIS ABABA UNIVERSITY

ADDIS ABABA INSTITUTE OF TECHNOLOGY

SCHOOL OF ELECTRICAL AND COMPUTER ENGINEERING

BIOMETERIC BASED ATTENDANCE MANAGEMENT SYSTEM

BY

ABRAHAM GETAGUN AND NATNAEL NEGUSSIE

FINAL THESIS PROJECT SUBMITTED TO ADDIS ABABA INSTITUTE OF TECHNOLOGY

ADVISOR: Mr. Yafet Philipos

June, 2024

ADDIS ABABA, ETHIOPIA


Declaration
We want to assure that this paper absolutely belongs to us. It is prepared as a report for our
project according to the thesis writing format prepared by AAU. We have done this project for
the partial fulfillment of BSc degree in Electrical and Computer engineering.
Finally, it is a must to tell you how much effort we have made to do this project and come up
with tangible outcomes. No one has made similar projects and this will serve as a primary
reference.

Name Signature

Abraham Getahun ___________________

Natnael Negussie ___________________

Place: Addis Ababa, Ethiopia

Date of Submission: June 13, 2024

This thesis project work has been submitted for examination with my approval as a university
advisor.

Name Signature

Mr. Yafet Philpos __________________

II
Acknowledgment
First of all, praise be to God Almighty for giving the courage, wisdom, skill, and chance needed
to start and finish this research project. The accomplishment's significance is further
highlighted by the acknowledgment of divine blessings.

We also extend our sincere gratitude to Mr. Yafet Philipos for his superb oversight, creative
suggestions, and constant support during the research project. With gratitude, we acknowledge
the honor of continuing our study under his direction.

Lastly, friends and colleagues in the School of Electrical and Computer Engineering are
sincerely thanked for their support, encouragement, and credible suggestions that greatly aided
in the completion of the thesis.

III
Abstract
Accurate staff attendance tracking and control are critical to operational effectiveness and
payroll management in today's company environment. Conventional attendance
monitoring techniques frequently have inaccurate data, security flaws, and inadequate data
protection. This paper suggests a Fingerprint-Based Attendance System that uses the
Raspberry Pi 3 to address these problems and provides improved security and
dependability. Utilizing fingerprint recognition technology, the system is accurate and
resistant to fraud, and its implementation is made possible by the Raspberry Pi 3, which
is a small and robust platform. It is anticipated that this novel approach will considerably
increase labor management's operational effectiveness, security, and accuracy while
lessening the burden on administrative staff and promoting openness. The extensive
literature review, thorough methodology, and system architecture for the design,
development, and implementation of the suggested system are provided in the next parts.

IV
TABLE OF CONTENTS
Declaration ................................................................................................................................................... II
Acknowledgment ........................................................................................................................................ III
Abstract ....................................................................................................................................................... IV
TABLE OF CONTENTS ............................................................................................................................. V
LIST OF FIGURES .................................................................................................................................. VII
LIST OF TABLES ........................................................................................................................................ 1
LIST OF ACRONYMS ................................................................................................................................ 2
CHAPTER ONE ........................................................................................................................................... 3
INTRODUCTION ........................................................................................................................................ 3
1.1 Background ................................................................................................................................... 3
1.2 Motivation ..................................................................................................................................... 4
1.3 Problem Statement ........................................................................................................................ 5
1.4 Objectives ..................................................................................................................................... 6
1.4.1 General Objective ................................................................................................................. 6
1.4.2 Specific objectives ................................................................................................................ 6
1.5 Scope of the project ...................................................................................................................... 6
1.6 Significance of the project ............................................................................................................ 7
1.7 Outline of the project .................................................................................................................... 8
CHAPTER TWO .......................................................................................................................................... 9
LITERATURE REVIEW ............................................................................................................................. 9
CHAPTER THREE .................................................................................................................................... 12
METHODOLOGY AND SYSTEM DESIGN ........................................................................................... 12
3.1 Introduction ................................................................................................................................. 12
3.2 System Architecture .................................................................................................................... 13
3.2.1 Employee registration ......................................................................................................... 13
3.2.2 Authentication Function...................................................................................................... 15
3.2.3 Attendance Tracking and Payroll Function......................................................................... 16
3.3 System Block Diagram ............................................................................................................... 18
3.4 Schematic circuit diagram of the system .................................................................................... 18
3.5 The materials used in this Project ............................................................................................... 19
3.5.1 Personal Computer .............................................................................................................. 19
3.5.2 Raspberry Pi ........................................................................................................................ 19

V
3.5.3 Fingerprint Module ............................................................................................................. 21
3.5.4 Liquid Crystal Display (LCD) ............................................................................................ 22
3.5.5 I2C Module ......................................................................................................................... 23
3.5.6 4x3 Keypad ......................................................................................................................... 23
3.6 Software Requirement................................................................................................................. 24
3.6.1 PuTTY Software ................................................................................................................. 24
3.6.2 RealVNC Viewer Software ................................................................................................. 25
3.6.3 MySQL Database ................................................................................................................ 25
3.6.4 Python ................................................................................................................................. 26
3.7 System Design ............................................................................................................................ 26
3.7.1 User to System Interaction .................................................................................................. 26
3.7.2 System to Database Interaction ........................................................................................... 27
3.8 Database Design.......................................................................................................................... 28
CHAPTER FOUR ....................................................................................................................................... 31
RESULT AND DISCUSSION ................................................................................................................... 31
4.1 Implementation Results............................................................................................................... 31
4.1.1 System Setup ....................................................................................................................... 31
4.1.2 Employee Registration ........................................................................................................ 31
4.1.3 Attendance Tracking ........................................................................................................... 32
4.1.4 Payroll Calculation.............................................................................................................. 33
4.1.5 Admin Panel........................................................................................................................ 33
4.2 Hardware Implementation........................................................................................................... 35
CHAPTER FIVE ........................................................................................................................................ 36
CONCLUSION AND RECOMMENDATION .......................................................................................... 36
5.1 Conclusion .................................................................................................................................. 36
5.2 Recommendations ....................................................................................................................... 36
Reference .................................................................................................................................................... 37
Appendix 1 .................................................................................................................................................. 38
Appendix 2 .................................................................................................................................................. 39

VI
LIST OF FIGURES
Figure 1. Flow diagram of Methodology ................................................................................ 12
Figure 2. Design of system architecture ................................................................................. 13
Figure 3. Employee Registration flowchart ............................................................................ 14
Figure 4. Attendance recording flowchart .............................................................................. 15
Figure 5. Payroll computing flowchart ................................................................................... 17
Figure 6. System Block Diagram............................................................................................ 18
Figure 7. Schematic Circuit diagram ...................................................................................... 18
Figure 8. Raspberry Pi 3B Pin Configuration ......................................................................... 20
Figure 9. R307 Fingerprint Module ........................................................................................ 21
Figure 10. LCD Display ......................................................................................................... 23
Figure 11. I2C Module ........................................................................................................... 23
Figure 12. 4x3 Keypad ........................................................................................................... 24
Figure 13. User System Interaction environment ................................................................... 27
Figure 14. Employee Database ............................................................................................... 29
Figure 15. Attendance Database Schema ............................................................................... 29
Figure 16. Employee Registration function ............................................................................ 31
Figure 17. Registration Confirmation ..................................................................................... 32
Figure 18. Attendance Tracking process ................................................................................ 33
Figure 19. Attendance Payroll panel ...................................................................................... 33
Figure 20. Website Monitoring Panel ..................................................................................... 34

VII
LIST OF TABLES

Table 1. Fingerprint Module pin description .......................................................................... 22


Table 2. Cost Analysis ............................................................................................................ 38
Table 3. Working plan schedule ............................................................................................. 38

1
LIST OF ACRONYMS
HR Human Resource
GSM Global System for Mobile Communication
LCD Liquid Crystal Display
ID Identification

PC Personal Computer

GPIO General Purpose Input/Output

HDMI High-Definition Multimedia Interface

FAR False Acceptance Rate

UART Universal Asynchronous Receiver-Transmitter

SQL Sequential Query Language

2
CHAPTER ONE
INTRODUCTION
1.1 Background
These days, many organizations—including government agencies, corporations, and
educational institutions—need precise and effective attendance management systems.
Conventional techniques for keeping track of attendance, such punch cards and manual
registers, are frequently beset by problems like fraud, time wastage, and human mistake.
These drawbacks emphasize the requirement for a more dependable and automated
solution. A viable substitute is provided by biometric technologies, which make use of
distinct physiological traits like fingerprints, face recognition, and iris scans. Fingerprint
recognition is unique among them all because of its great accuracy, affordability, and
convenience of usage.

The field of attendance management has undergone even more change thanks to the
incorporation of fingerprint identification technologies with microcomputers like the
Raspberry Pi. The Raspberry Pi single-board computer is a flexible and reasonably priced
device that offers the computing capacity and adaptability required to create complex
biometric systems. It is the perfect platform for putting in place a fingerprint-based
attendance system because it supports a wide range of sensors and modules. Organizations
can automate the process of collecting attendance by utilizing the features of Raspberry
Pi, which guarantees accuracy, security, and real-time data management.

Furthermore, improvements in database management and fingerprint matching software


algorithms have improved the dependability and effectiveness of these systems. These
systems are capable of meeting the demands of both small and large-scale businesses due
to their capacity to store and handle enormous amounts of data. The implementation of
these systems yields several benefits, including streamlined attendance management,
decreased administrative burden, reduced instances of fraud, and useful data analytics for
tracking attendance trends and patterns. As a result, Raspberry Pi-based fingerprint-based

3
attendance systems have become widely accepted and are being used more frequently in
a variety of industries.

1.2 Motivation
A number of constraints and inefficiencies present in conventional organizational
processes are the driving force behind the development of a fingerprint-based attendance
management system utilizing Raspberry Pi that is coupled with a payroll and report
system. Punch cards and manual registers, two labor-intensive but error- and
manipulation-prone old methods of keeping track of attendance, are outdated. Erroneous
manual data input and buddy punching are two problems that might result in erroneous
attendance records among employees. The occurrence of these errors may lead to
disparities in payroll, which could financially impact companies and lead to employee
discontent.

Identification of people by their distinct physiological characteristics is made safe and


dependable by biometric technologies, particularly fingerprint recognition. This
technology makes sure that attendance records are accurate and impenetrable, thereby
lowering the possibility of fraudulent activity. One conceivable way to build a complete
system that automates payroll processing and tracks attendance is to combine fingerprint
recognition with the Raspberry Pi, a low-cost, high-capability microcomputer. Putting
such a system into place is made easy by the Raspberry Pi's versatility in handling different
sensors and peripherals. Real-time data processing, strong security measures to prevent
unwanted access, and improved attendance tracking accuracy are all promised by this
integration.

Further adding substantial value to the project is the payroll and reporting system that is
integrated into the attendance management framework. Employers may ensure that
workers are paid promptly and equitably by automating payroll calculations based on
precise attendance data. This also reduces administrative burden by doing away with
manual calculations. When it comes to employee timeliness, attendance trends, and

4
general workforce productivity, the report generation feature is indispensable. The
creation of these reports can help with performance reviews, strategic decision-making,
and pinpointing areas that need work. Developing a comprehensive solution that improves
payroll accuracy, streamlines attendance management, and offers extensive reporting
features is the driving force behind this project. This will increase organizational
effectiveness and employee happiness.

1.3 Problem Statement


Organizations face many difficulties and inefficiencies with the conventional approaches to
payroll and attendance management. Paper registers and punch cards are two examples of
manual attendance methods that are very prone to fraud and mistakes. Since these systems
mostly rely on human input, errors may occur from mistakes or intentional manipulation (such
as buddy punching, in which one person clocks in for another). The system's integrity is
jeopardized by these errors in attendance records, which also have an impact on payroll
computations and raise the possibility of financial irregularities and conflicts.

In addition, manually processing attendance data for payroll needs takes a lot of time and work.
Payroll processing, work hour calculations, and attendance record verification all require a
significant amount of effort from human resources staff. Errors can occur in this manual
procedure, impacting employee happiness and even resulting in legal and financial
consequences for the company. This might also result in improper payments. Efficient
monitoring and analysis of worker performance is impeded by the absence of automated
reporting and real-time data, which further complicates the management of payroll and
attendance.

Given these problems, an automated, dependable, and effective system that can precisely
record attendance, stop fraud, and expedite payroll processing is desperately needed. A
workable solution to these issues is provided by a fingerprint-based Raspberry Pi attendance
management system coupled with a payroll and reporting system. The objective of this system
is to do away with the need for manual intervention that comes with traditional techniques,
guarantee the confidentiality and accuracy of attendance data, and offer automatic payroll

5
computations and thorough reporting. The suggested solution aims to improve organizational
efficiency, lessen administrative responsibilities, and raise overall employee happiness and
productivity by tackling these important challenges.

1.4 Objectives
1.4.1 General Objective
To develop a fingerprint-based attendance management system using Raspberry Pi, integrated
with a payroll and report system. This system aims to automate attendance recording, reduce
errors and fraud, streamline payroll processing, and provide comprehensive reporting to
enhance operational efficiency and employee satisfaction in organizations.

1.4.2 Specific objectives


➢ To design and implement a fingerprint recognition system using Raspberry Pi for
accurate and secure attendance tracking.
➢ To integrate a payroll module that automatically calculates employee salaries based on
recorded attendance data.
➢ To develop a real-time data processing feature for immediate attendance updates and
payroll computations.
➢ To create a centralized database for storing attendance records and payroll information
securely.
➢ To implement a user-friendly interface for HR administrators to manage employee data,
attendance, and payroll.
➢ To provide automated report generation for attendance patterns, payroll summaries, and
workforce analytics.
➢ To ensure the system is scalable and can be easily adapted for small to large
organizational settings.
➢ To enhance the security features of the system to prevent unauthorized access and
ensure data integrity.

1.5 Scope of the project


This project involves the design, development, and implementation of a payroll and report
system coupled with a fingerprint-based attendance monitoring system utilizing a Raspberry

6
Pi. It includes setting up hardware for fingerprint recognition, developing software for payroll
processing and attendance monitoring, and building a centralized database for safe data
storage. The system will process data in real time, generate reports automatically, and offer an
intuitive user interface for HR administration. Scalability, security, and adaptation for a range
of organizational sizes—from tiny enterprises to major institutions—are all included in the
scope.

1.6 Significance of the project


This initiative is important because it has the potential to revolutionize how businesses handle
payroll and attendance procedures. This system offers an extremely precise, safe, and
automated approach to attendance tracking by utilizing fingerprint recognition technology and
the processing power of the Raspberry Pi. This greatly lowers errors and fraudulent activities
like buddy punching. The incorporation of a payroll module guarantees accurate and timely
wage calculations derived from real-time attendance data, hence augmenting employee
contentment and faith in the payroll procedure.

In addition, the system's capacity to provide thorough payroll summaries and attendance trends
reports provides HR management with important information that supports strategic decision-
making and performance reviews. The intuitive interface streamlines administrative duties,
relieving HR staff of extra labor and freeing them up to concentrate on more important
responsibilities. Furthermore, the project's focus on adaptation and scalability guarantees that
it can meet the requirements of different organizational sizes, ranging from small startups to
major corporations, making it a flexible solution.

All things considered, this project fosters an organizational culture of accountability and
openness in addition to increasing operational efficiency and accuracy. It is a major
advancement in the use of cutting-edge technology to improve and expedite crucial business
operations, which will ultimately lead to improved labor management and increased
productivity inside the company.

7
1.7 Outline of the project
This paper is a report for our project written after much effort made practically. It includes the
following chapters:

➢ First an introduction is discussed, which gives a general concept about this project
➢ Next a literature review will explain about reports of projects done before in areas
similar to our project.
➢ Then the overall system design and analysis briefly discusses circuit components,
design analysis and system working principles.
➢ After the design and analysis, a simulation and prototype implementation of the project
is discussed.
➢ Finally, the paper talks about conclusion and the possible future scopes which gives a
generalized idea about our final points and future works to be made to develop more
than this.

8
CHAPTER TWO
2 LITERATURE REVIEW
A thorough examination of various documents, journals, and books is essential for the
successful completion of this project. This section provides a review of previous and relevant
works in the field of attendance management systems. To gain insights into new and more
efficient methods, we have reviewed and will continue to review related past studies.

This paper explores the development of a fingerprint-based attendance system that combines
the functionalities of Arduino and Raspberry Pi. The system captures fingerprint images using
a fingerprint sensor, which are then processed by the Arduino for initial matching. The
Raspberry Pi acts as a central controller, handling database management and user interface
functionalities. An LCD screen is integrated to provide real-time feedback to users about their
attendance status. The system also includes features for adding new users and managing
attendance records efficiently. The paper highlights the potential scalability of the system, its
cost-effectiveness, and ease of deployment in various institutional settings, such as schools
and offices. The study concludes that the combined use of Arduino and Raspberry Pi provides
a robust and efficient solution for attendance management. Rani, R. J., & Karthika, M. (2017)

A paper by Kumar, S., & Singh, P. (2018) discusses the design and implementation of a
fingerprint-based attendance management system that integrates Raspberry Pi and a GSM
module. The system captures fingerprint data using a sensor, processes it for verification, and
updates attendance records accordingly. One of the unique features of this system is its ability
to send real-time attendance information via SMS to designated recipients, such as
administrators or parents, using the GSM module. The paper covers the system's architecture,
including hardware components like the fingerprint sensor, Raspberry Pi, and GSM module,
and software algorithms for fingerprint matching and SMS communication. The centralized
database ensures secure storage and easy retrieval of attendance records. The authors highlight
the system's reliability, cost-effectiveness, and potential applications in educational institutions
and corporate environments. They conclude that the integration of GSM technology enhances
the system's functionality by providing instant updates and improving communication.

9
Gupta, R., & Sharma, A. (2017) develop a system with the Raspberry Pi serving as the central
processing unit, this research paper presents a thorough overview of a biometric attendance
system. To collect biometric data, the system uses a fingerprint sensor. Then, it processes and
compares the fingerprints using complex algorithms. All of the hardware connections—such
as those for the power supply, communication ports, and fingerprint sensor—are described in
full. We also talk about the software's components, including the database management system
and the algorithms for matching fingerprints to attendance records. Concerning accuracy,
speed, and user experience, the writers assess the system's performance. Its conclusion is that
the system offers a dependable way to manage attendance in a variety of scenarios, and it is
also very effective and user-friendly. A larger database and the integration of more biometric
modalities are only two examples of the potential improvements that the study draws attention
to for large-scale implementation.

This study by Verma, R., & Singh, D.(2019) focuses on the design and development of a
Raspberry Pi-based biometric attendance management system. The system takes fingerprints,
verifies them, changes attendance records instantly, and saves all of the information in a single,
centralized database. The database management system, fingerprint matching algorithms, and
the Raspberry Pi's integration of the fingerprint sensor are just a few of the hardware and
software elements that the authors go into great depth about. Scalability, security
characteristics, and possible uses in a range of organizational contexts, including offices,
factories, and schools, are also included in the research. According to the authors' conclusion,
the system provides a reliable and effective way to manage attendance, with room for future
development and customization in response to particular user needs.

Using a Raspberry Pi as the central processing unit, Rajput, N., & Chavhan, V. (2019)
investigates the creation of a real-time biometric attendance system based on fingerprint
recognition technology. In real time, the system updates attendance records by capturing
fingerprint data and validating it against pre-stored templates. In addition to the software
methods for fingerprint matching and database administration, the article also covers the
hardware components, such as the Raspberry Pi and fingerprint sensor. The authors draw
attention to the real-time features of the system, such as its ability to update attendance records

10
instantly and provide rapid feedback. They draw the conclusion that, with possible uses in a
range of institutional contexts, the method offers a dependable and effective approach to
managing attendance.

The creation of a dependable and safe biometric attendance system with a Raspberry Pi is
presented in this paper by Patel, A., & Shah, M. (2018). To provide precise identification and
safe attendance data storage, the system makes use of cutting-edge fingerprint recognition
algorithms. The authors go over the software techniques used for data encryption and
fingerprint matching as well as the hardware components, such as the Raspberry Pi and
fingerprint sensor. The use of secure communication methods to safeguard attendance data
while it is being transmitted is also covered in the study. The system offers a solid and
dependable solution for controlling attendance with a high level of security, according to the
authors, who also emphasize the system's security features, which include data encryption and
safe access restrictions.

The study by Saini, S., & Kumar, R. (2019) examines the use of a Raspberry Pi fingerprint
attendance system in conjunction with Internet of Things technologies. Using a sensor, the
system takes fingerprint data, validates it, and changes attendance records in a database stored
on the cloud. The fingerprint sensor, Raspberry Pi, cloud storage, and other hardware and
software components are all described in great depth by the writers. Real-time access to
attendance records and improved data security are only two advantages that the study
emphasizes of adopting IoT for remote monitoring and administration of attendance data. The
scalability of the system and its possibilities for implementation in big enterprises are also
covered by the writers. The use of IoT technology improves the system's performance and
offers a reliable approach to managing attendance, they conclude.

11
CHAPTER THREE
3 METHODOLOGY AND SYSTEM DESIGN
3.1 Introduction
Methodology, as the name implies, describes the stages or approaches that are developed in
order to accomplish a certain objective; in this example, creating a prototype fingerprint-based
attendance management system that is linked with a payroll and reporting system. In essence,
it provides a useful structure. The knowledge and data obtained from earlier publications helps
to clarify the purpose and aims. Hardware and software integration leads to the design model.
The prototypes, components, architecture, and parts of the system are depicted in this model.
Nonetheless, the hardware and software need to be properly connected and arranged for the
project to succeed. This project's methodology flow block diagram is displayed below.

Figure 1. Flow diagram of Methodology

12
3.2 System Architecture

Figure 2. Design of system architecture


The fingerprint-based attendance management system using Raspberry Pi. The primary goal
of any attendance system is to ensure that each employee's attendance is accurately recorded,
preventing any fraudulent practices like buddy punching. The main purpose of our system is
to automate attendance tracking and payroll processing efficiently. The system essentially
consists of three main functions:

1. Employee registration
2. Authentication function
3. Attendance tracking and payroll function

3.2.1 Employee registration


The employee registration process is a crucial part of the fingerprint-based attendance
management system. It involves capturing the employee's fingerprint data and storing it
securely in the system's database. This process ensures that each employee is uniquely
identified and can be authenticated accurately when clocking in and out.

13
Figure 3. Employee Registration flowchart
Steps in Employee Registration:

1. Initiate Registration: The HR administrator initiates the registration process using


the system's user interface.
2. Enter Employee Details: The administrator inputs the employee's personal details
such as name, employee ID, and department.
3. Capture Fingerprint: The employee's fingerprint is scanned using the R307
fingerprint module. Multiple scans are taken to ensure accuracy and create a detailed
fingerprint template.
4. Store Data: The captured fingerprint template and employee details are stored
securely in the centralized database.
5. Confirmation: The system confirms the successful registration of the employee and
displays a confirmation message.

14
This process ensures that each employee's fingerprint data is accurately recorded and linked
to their personal details, facilitating seamless attendance tracking and payroll processing.

3.2.2 Authentication Function


An essential component of the fingerprint-based attendance management system is the
authentication feature, which guarantees precise tracking of workers' clock-in and clock-out
timings. This procedure prevents false attendance entries and unlawful access by using the
fingerprint data that was taken during registration to confirm the employee's identification.

Figure 4. Attendance recording flowchart

15
Steps in Authentication Function:

1. Initiate Authentication: The employee initiates the authentication process by


selecting either "Sign In" or "Sign Out" and placing their finger on the fingerprint
scanner.
2. Capture Fingerprint: The R307 fingerprint module captures the employee's
fingerprint for verification.
3. Retrieve Stored Data: The system retrieves the stored fingerprint templates from the
database.
4. Match Fingerprint: The captured fingerprint is compared with the stored templates to
find a match.
5. Verification: If a match is found, the system verifies the employee's identity.
6. Update Attendance:
• For "Sign In": The system records the clock-in time for the employee and
updates the attendance database accordingly.
• For "Sign Out": The system records the clock-out time, calculates the total
hours worked, and updates the attendance and payroll database.
7. Confirmation: The system displays a confirmation message indicating successful
authentication and attendance update.

This process ensures that only registered employees can record their attendance, maintaining
the integrity and accuracy of attendance data.

3.2.3 Attendance Tracking and Payroll Function


The attendance tracking and payroll function is a vital component of the fingerprint-based
attendance management system. This function ensures that employees' work hours are
accurately recorded and used to compute payroll. The system captures clock-in and clock-out
times, calculates total work hours, and processes payroll based on predefined rates.

16
Steps in Attendance Tracking and Payroll Function:

1. Capture Attendance Data: When employees sign in and sign out, their attendance
data, including timestamps, is captured and stored in the database.
2. Calculate Work Hours: The system calculates the total hours worked by each
employee by subtracting the sign-in time from the sign-out time for each workday.
3. Compute Payroll: Using the total work hours and the predefined hourly rate, the
system computes the payroll for each employee. Additional factors like overtime,
bonuses, and deductions are also considered in the calculation.
4. Generate Reports: The system generates detailed attendance and payroll reports,
providing insights into employees' work patterns and payroll details.
5. Update Payroll Database: The computed payroll data is stored in the payroll database,
ensuring accurate and up-to-date records for salary disbursement.
6. Provide Access: HR administrators and authorized personnel can access the attendance
and payroll reports through a secure interface, facilitating efficient payroll management
and decision-making.

Figure 5. Payroll computing flowchart

17
3.3 System Block Diagram
The general block diagram of the system is shown below:

Figure 6. System Block Diagram

3.4 Schematic circuit diagram of the system

Figure 7. Schematic Circuit diagram

18
3.5 The materials used in this Project
3.5.1 Personal Computer
A Personal Computer (PC) is essential for the development and implementation of the
fingerprint-based attendance management system. It facilitates software development,
including coding, compiling, and debugging, and manages the centralized database for secure
data storage and retrieval. The PC is also used for configuring the Raspberry Pi and integrating
various hardware components, generating and analyzing reports using tools like Excel or
Power BI, and developing a user-friendly interface for HR administrators. Overall, the PC
provides the necessary computational power and versatility for effective software
development, system configuration, data analysis, and user interface design, making it
indispensable for the project's success.

3.5.2 Raspberry Pi
An essential piece of hardware in an attendance control system that uses fingerprints is the
Raspberry Pi 3B. It performs the functions of the central processing unit by processing
attendance records, handling data from the fingerprint scanner, and overseeing component
communication. GPIO pins are used by the Raspberry Pi 3B to seamlessly integrate with a
variety of hardware elements, including the LCD display and fingerprint reader. It does payroll
computations, executes fingerprint recognition algorithms, updates the database in real-time,
and operates the software designed for the attendance management system.

The system's integrated Ethernet and Wi-Fi allow for remote access to payroll and attendance
data as well as real-time data synchronization. Because of its low power consumption, the
Raspberry Pi 3B is a great option for continuous operation in an attendance management
system, hence lowering total operating expenses. All things considered, the Raspberry Pi 3B
offers the connection, flexibility, and processing power needed to create an effective and
dependable fingerprint-based attendance monitoring system.

19
Features:

✓ Processor: 1.2 GHz 64-bit quad-core ARM Cortex-A53 CPU


✓ Memory: 1 GB LPDDR2 SDRAM
✓ Networking: Built-in 2.4 GHz 802.11n Wi-Fi, Bluetooth 4.1, BLE, and Ethernet port
✓ USB Ports: Four USB 2.0 ports
✓ Video & Audio Output: Full-size HDMI port, combined 3.5mm audio jack and
composite video
✓ Camera Interface: CSI camera port for connecting a Raspberry Pi camera module
✓ Display Interface: DSI display port for connecting a Raspberry Pi touchscreen display
✓ Storage: MicroSD card slot for loading the operating system and data storage
✓ GPIO: 40-pin GPIO header, providing general-purpose input/output pins for interfacing
with other hardware
✓ Power Supply: Micro USB power source, requiring 5V/2.5A
✓ Form Factor: Compact size of 85.6mm x 56.5mm
✓ Other Interfaces: UART, I2C, SPI, PWM, and GPIO for various hardware connections

Figure 8. Raspberry Pi 3B Pin Configuration

20
3.5.3 Fingerprint Module
A crucial piece of hardware for the fingerprint-based attendance control system is the R307
Fingerprint Module. It ensures precise and dependable identification by employing an optical
sensor to take high-quality fingerprint pictures. It works with a wide range of organizational
sizes since it can hold up to 1,000 fingerprint templates and handle a big number of personnel.

The module guarantees that only authorized persons are identified, boasting great accuracy
and a low false acceptance rate (FAR). Quick identification and verification are made possible
by its effective fingerprint matching system, which also improves user experience. Via a serial
interface, the R307 and Raspberry Pi 3B may connect, facilitating smooth data transfer and
system integration.

The R307 requires little setup or configuration since it is intended to integrate easily with
microcontrollers and single-board computers like the Raspberry Pi. It is an essential part of
precise attendance monitoring because of its strong design, which guarantees dependable
operation in a range of environmental circumstances, and its low power consumption, which
supports the project's energy-efficient objectives.

Figure 9. R307 Fingerprint Module

21
Features:

✓ Power DC: 3.6V-5.0V


✓ Interface UART: (TTL logical level)/ USB 1.1 Working current Typical: 100mA
/Peak: 150mA Matching Mode 1:1 and 1: N.
✓ Baud rate: (9600*N) bps, N=1~12 (default N=6)
✓ Character file size: 256 bytes.
✓ Image acquiring time:<0.5s
✓ Template size: 512 bytes
✓ Storage capacity: 256
✓ Security level :5 (1, 2, 3, 4, 5(highest))

Pin Description:

It has six pins; their function description is shown on table below.

Pin No Name Type Function Description


1 Vin In Power Input
2 TD In Data Output. TTL Logical Level
3 RD Out Data Output. TTL Logical Level
4 NC - Not connected
5 NC - Not connected
6 GND - Signal ground

Table 1. Fingerprint Module pin description


3.5.4 Liquid Crystal Display (LCD)
The attendance management system makes use of the LCD display for a number of purposes.
The LCD display gives fast response to employees who start the authentication process by
touching their finger on the fingerprint scanner. It shows if the fingerprint scan was successful
or if there was a mistake. Additionally, it ensures that employees are aware that their

22
attendance has been appropriately recorded by displaying confirmation messages upon
successful sign-ins and sign-outs.

Figure 10. LCD Display


Features :

• Type: Character.
• 20 characters * 4 lines.
• Display mode & backlight variation.
• 4-bit or 8-bit microcontroller interface.

3.5.5 I2C Module


The I2C module is a crucial component in fingerprint-based attendance management systems,
enabling efficient communication between microcontrollers and peripheral devices like LCD
displays and fingerprint scanners. It simplifies wiring, reduces GPIO pins, and supports
bidirectional data transfer, enhancing system performance and reliability.

Figure 11. I2C Module


3.5.6 4x3 Keypad
The 4x3 keypad is a keypad in a fingerprint-based attendance management system, consisting
of 12 keys arranged in four rows and three columns. It allows for easy input of numeric data

23
and commands, such as employee IDs and administrative commands. Its design and
compatibility with microcontrollers like Raspberry Pi 3B make it a user-friendly and efficient
input device.

Figure 12. 4x3 Keypad

3.6 Software Requirement


3.6.1 PuTTY Software
For controlling and setting the Raspberry Pi 3B, PuTTY is an essential software tool in the
fingerprint-based attendance management system. Several network protocols, such as SSH,
Telnet, and serial connection, are supported by this free and open-source terminal emulator.
Using PuTTY, developers and administrators may safely and effectively access the Raspberry
Pi remotely in this project. This enables them to transfer files, run commands, and adjust
system settings from a PC. This feature is crucial for system maintenance, debugging, and
programming without requiring direct physical contact to the Raspberry Pi. Because to
PuTTY's comprehensive capabilities and easy-to-use interface, system administrators may
easily manage the software environment of the system, guaranteeing seamless and efficient
operation during the development and deployment stages.

24
3.6.2 RealVNC Viewer Software
A crucial piece of software for the fingerprint-based attendance management system that gives
the Raspberry Pi 3B remote desktop access is RealVNC Viewer. It makes it possible for users
to engage with the Raspberry Pi desktop environment as if they were physically there by
allowing them to watch and control it remotely from another computer. This feature is essential
for troubleshooting and maintenance work, as well as for installing, configuring, and
maintaining the system's software. Secure, encrypted connections are supported by RealVNC
Viewer, guaranteeing the security of any data sent between the Raspberry Pi and the remote
device. It is an essential component of the system, increasing the flexibility and ease of
operating the attendance management solution from any place thanks to its user-friendly
interface and strong performance.

3.6.3 MySQL Database


The main software component of the fingerprint-based attendance management system is the
MySQL Database, which acts as the main storage option for all payroll and attendance data.
Strong, scalable, and performant, this open-source relational database management system
(RDBMS) is well-known. To ensure that data is arranged and easily available, this project uses
a MySQL database to hold salary information, fingerprint templates, attendance records, and
employee details.

Large data quantities may be efficiently queried and managed by the database, supporting
intricate tasks like payroll processing, report generation, and work hour calculations. The
system's total functionality is improved by its connection with the Raspberry Pi 3B and other
system components, which guarantees smooth data flow and real-time updates.

Access control and user authentication are two of MySQL's robust security features that guard
critical information and guarantee that only authorized users may access or alter the database.
Its ability to work with a wide range of computer languages and development tools makes it a
flexible option for developers, which helps to ensure the attendance management system is
implemented and maintained efficiently.

25
3.6.4 Python
Python is a flexible programming language that's often utilized in the attendance management
system that takes fingerprints. It is used to design the main software, integrate hardware,
process fingerprint data, and oversee payroll and attendance functions. Writing readable and
understandable code is made easy with Python's ease of use and simplicity. Python scripts are
used in this project to do things like interface with the MySQL database, generate reports, and
collect and analyze fingerprint data from the R307 module.

The web interface for administrators is also developed using Python modules and frameworks
such as Flask and Django. Real-time data updates, effective data analysis, and connectivity
with Raspberry Pi GPIO pins are all made possible by Python's robust standard library and
third-party modules. Robust system performance and smooth integration are guaranteed by its
interoperability with technologies like MySQL for database administration and PuTTY for
remote access.

3.7 System Design


3.7.1 User to System Interaction
Three physical components are the main means by which employees interact with the
fingerprint-based attendance management system: the LCD display, the R307 fingerprint
module, and the 4x3 keypad. When a worker gets to work, they first enter their employee ID
using the 4x3 keypad to start the sign-in procedure. Employees may safely enter their unique
identification numbers using the keypad, which is connected to the Raspberry Pi via GPIO
pins. After the employee ID is input, the user receives real-time feedback and instructions via
the LCD display, which is connected to the Raspberry Pi via the I2C module. To provide clarity
and convenience of usage, the display leads the staff member through the subsequent
procedures.

After entering their ID, the employee uses the R307 fingerprint module to scan their
fingerprint. This module, which collects fingerprint data and compares it with templates stored
in the database, is essential to the authentication process. To promptly confirm the employee's
identification, the system compares the scanned fingerprint with the pre-registered data. The
system records the sign-in time in the MySQL database after successful authentication. After

26
that, the LCD display verifies that the employee successfully logged in and gives them instant
feedback.

In a similar vein, the employee engages with the system once more when they leave the office
by first using the keypad to input their employee ID and then scanning their fingerprint to sign
out. After recording the sign-out time in the database, the system determines the working hours
for the day and modifies the payroll records appropriately. To provide a seamless and user-
friendly experience, the LCD display keeps providing instructions and status updates
throughout this operation. The main user interface for safe and effective attendance monitoring
is formed by the integration of the fingerprint module, LCD display, and keypad.

Figure 13. User System Interaction environment


3.7.2 System to Database Interaction
One essential element of the fingerprint-based attendance management system is the system's
communication with the database. The Raspberry Pi 3B serves as the main computing unit,
managing, processing, and handling all data inputs. The Raspberry Pi handles the inputs from
the 4x3 keypad, R307 fingerprint module, and LCD display when an employee registers, signs
in, or signs out. Following data collection, the information is organized and ready for database
storage, including employee information and fingerprint templates from registration or sign-
in/sign-out timings from attendance monitoring.

27
The system stores and manages this data in a MySQL database. To add new records to the
database or edit ones that already exist, the Raspberry Pi connects to the MySQL server and
runs SQL queries. For example, the system records the sign-in time in the attendance table
when an employee signs in. In a similar manner, the total working hours are computed by
updating the sign-out timings. The accuracy of payroll processing depends on these processes'
ability to guarantee that the database accurately represents real-time attendance data.

Apart from maintaining documents, the Raspberry Pi obtains information from the database
for several objectives. The system fetches the saved fingerprint templates to verify the
employee's identification during the sign-in procedure. In order to calculate payrolls on a daily
and weekly basis, it also searches attendance data, producing detailed reports for management
and HR. The total working hours multiplied by the hourly wage is the basis for payroll
computations. Through constant communication, the system keeps an accurate and up-to-date
record of all payroll and attendance-related data, which makes data processing, reporting, and
decision-making more efficient. A strong and dependable attendance management system is
made possible by the smooth connection of the Raspberry Pi and the MySQL database.

3.8 Database Design


An essential component that guarantees effective data administration, retrieval, and storage in
the fingerprint-based attendance management system is the database design. All employee
data, attendance records, and payroll computations are managed by the system using a MySQL
database. To serve the different functions of the system, the database schema is carefully built.
Three important tables are the "Payroll," "Attendance," and "Employees" tables.

The fingerprint template, pay rate per hour, employee ID, first and last names, and other
pertinent employee data are all kept in the "Employees" table. During the sign-in and sign-out
procedures, this table serves as the main source of information for confirming employee IDs.
The biometric information required for authentication is safely stored in a binary field called
the fingerprint template.

Employee sign-in and sign-out timings are recorded in the "Attendance" database. This table's
records each have an employee ID (connected to the "Employees" table), the date, and the

28
sign-in and sign-out timestamps. By deducting the sign-in and sign-out times for each day, the
table is made to efficiently compute working hours. Both the payroll computations and the
attendance monitoring system depend on this data.

Figure 14. Employee Database


Monthly summaries of the daily working hours are generated by the "Payroll" table. Fields
like employee ID, month, total hours worked, and total compensation are included. The whole
compensation is computed by multiplying the total number of hours worked by the pay rate
that is recorded in the "Employees" table. Payroll administration and financial reporting are
made easier by this table, which offers a thorough summary of each employee's earnings for
the pay period.

Figure 15. Attendance Database Schema

29
Data integrity is guaranteed by the relational database design, which also makes it possible to
access and modify data with efficiency using sophisticated queries. Indexes are used on
important data to improve query efficiency, including employee ID and dates. Additionally,
the database's scalability was considered throughout design, making expansion simple as the
company expands. The fingerprint-based attendance management system is primarily
supported by a well-thought-out and sturdy database design, which guarantees dependable and
effective operation.

30
CHAPTER FOUR
4 RESULT AND DISCUSSION
This chapter covers the findings and offers the outcomes of the fingerprint-based attendance
management system's installation. The system's performance was assessed by a battery of tests
and real-world applications to make sure it fulfills the project's goals. To provide the debate a
visual framework, pictures of the operational system and the installation phases are given.

4.1 Implementation Results


4.1.1 System Setup
The integration of the hardware, which included the R307 fingerprint module, LCD display,
4x3 keypad, Raspberry Pi 3B, and I2C module, was completed successfully. The wiring and
connections in the system were carefully inspected during assembly to guarantee reliable
communication between parts. The Raspberry Pi was used to build up the MySQL database
and populate the required tables for payroll, attendance, and workers.

4.1.2 Employee Registration


By inputting employee information into a personal computer and taking fingerprints using the
R307 fingerprint module, the employee registration procedure was evaluated. The system
instantly confirmed the data's successful storage in the MySQL database on the LCD display.
The registration procedure turned out to be effective and user-friendly.

Figure 16. Employee Registration function

31
Figure 17. Registration Confirmation
4.1.3 Attendance Tracking
The capability for tracking attendance was carefully examined. By inputting scanning their
fingerprints, employees may sign in and leave. The sign-in and sign-out timings were precisely
captured by the system, which updated the attendance table instantly. Every step of the way,
the LCD display gave clear feedback to guarantee seamless functioning.

32
Figure 18. Attendance Tracking process
4.1.4 Payroll Calculation
By looking through the attendance records and figuring out the total number of working hours,
the payroll calculation feature was confirmed. The working hours multiplied by the hourly rate
allowed the system to properly calculate the daily paycheck. The monthly payroll report, which
included comprehensive details on each employee's wages, was produced appropriately.

4.1.5 Admin Panel

Figure 19. Attendance Payroll panel


33
Figure 20. Website Monitoring Panel

34
4.2 Hardware Implementation

35
CHAPTER FIVE
5 CONCLUSION AND RECOMMENDATION
5.1 Conclusion
This project's fingerprint-based attendance management system has shown to be a dependable,
efficient, and user-friendly tool. The system proved to have strong data management
capabilities, high accuracy fingerprint recognition, and efficient data processing through
extensive testing and real-world application. The project's goals were achieved through the
reliable and functioning system that was created by integrating hardware components with the
Raspberry Pi and MySQL database.

The LCD display and keypad, which formed up the system's user-friendly interface, made the
operations of employee registration, sign-in, and sign-out simple and easy to use. Payroll
administration and attendance monitoring are made easier with real-time updates and thorough
reporting, which improves organizational effectiveness. The technology performed as
expected overall and shown its ability to greatly enhance personnel management procedures.

5.2 Recommendations

Based on the successful implementation and performance of the fingerprint-based attendance


management system, several recommendations are proposed for further enhancement:

Firstly, consider integrating additional biometric authentication methods, such as facial


recognition or iris scanning, to enhance security and authentication accuracy. Secondly,
expand reporting capabilities to include detailed analytics on attendance patterns, employee
productivity, and payroll analysis. Thirdly, explore integration opportunities with existing HR
management software for seamless data exchange and workflow improvement. Additionally,
develop a mobile application companion for employees to access attendance records and
submit leave requests conveniently. Plan for scalability by designing the system architecture
for future growth and implement regular maintenance to ensure stability and security. Provide
comprehensive training and support resources for users to maximize system adoption and
utilization. These recommendations aim to improve functionality, usability, and overall impact
on organizational efficiency.

36
Reference
1. Rani, R. J., & Karthika, M. (2017). Fingerprint Based Attendance System Using
Arduino and Raspberry Pi. International Journal of Engineering and Technology
(IJET), 9(2), 1696-1701.
2. Kumar, S., & Singh, P. (2018). Fingerprint Based Attendance Management System
Using Raspberry Pi and GSM Module. International Journal of Innovative Research in
Computer and Communication Engineering (IJIRCCE), 6(4), 4155-4160.
3. Gupta, R., & Sharma, A. (2017). Biometric Attendance System Using Raspberry Pi.
International Journal of Advanced Research in Computer and Communication
Engineering (IJARCCE), 6(5), 789-795.
4. Verma, R., & Singh, D. (2019). Design and Development of a Biometric Attendance
Management System Using Raspberry Pi. International Journal of Computer Science
and Mobile Computing (IJCSMC), 8(3), 45-52.
5. Rajput, N., & Chavhan, V. (2019). Real-Time Biometric Attendance System Based on
Fingerprint Recognition. International Journal of Emerging Trends in Engineering
Research (IJETER), 7(3), 45-50.
6. Patel, A., & Shah, M. (2018). Development of a Secure and Reliable Biometric
Attendance System Using Raspberry Pi. Journal of Information Technology and
Software Engineering (JITSE), 7(2), 33-40.
7. Saini, S., & Kumar, R. (2019). Design and Implementation of Fingerprint-Based
Attendance System Using Raspberry Pi and IoT. International Journal of Advanced
Research in Electrical, Electronics and Instrumentation Engineering (IJAREEIE), 8(6),
1425-1431.

37
Appendix 1
No Name of the Component Quantity Cost of each item Total Cost in ETB
in ETB
1 PC 1 30,000 30,000
2 Fingerprint Module 1 1,500 1,500
3 Raspberry Pi 3B 1 18,000 18,000
4 LCD 1 500 500
5 Cable 15 7 215
6 4x3 Keypad 1 450 450
7 I2C Module 1 450 450
Table 2. Cost Analysis
Year 2024
Activities April May June
Week Week Week Week Week Week Week Week Week
2 3 4 1 2 3 4 1 2
Project Proposal ✓
Literature Proposal ✓
Installing ✓
necessary
Softwares
Database ✓
designing
Software ✓ ✓ ✓
Implementation
Hardware ✓ ✓ ✓
implementation
Documentation ✓
Table 3. Working plan schedule

38
Appendix 2
Project Python Code

import os

import datetime

import time

import sys

import pyfingerprint

from pad4pi import rpi_gpio

from pyfingerprint import PyFingerprint

import hashlib

import smtplib

from email.message import EmailMessage

import pymysql

import I2C_LCD_driver

mylcd = I2C_LCD_driver.lcd()

pressed_keys = ''

pin = "1234"

fun = ''

month = ''

year = ''

first_initial = ''

last_initial = ''

employee_number = ''

employee = ''

r = ''

39
person = ''

day = datetime.date.today().strftime("%m-%d-%y")

timestamp = time.strftime('%I:%M %p')

def finger():

try:

f = PyFingerprint('/dev/serial0', 57600, 0xFFFFFFFF, 0x00000000)

except Exception:

print('The fingerprint sensor could not be initialized!')

print('')

main_menu()

else:

print('Currently used templates: ' + str(f.getTemplateCount()))

print('')

print_grab()

db_config = {

'host': '192.168.8.101',

'user': 'rpi_fp',

'password': '1234567890',

'db': 'payroll',

'charset': 'utf8mb4',

'cursorclass': pymysql.cursors.DictCursor

40
# Function to connect to the database

def connect_to_db():

return pymysql.connect(**db_config)

def finger():

try:

f = PyFingerprint('/dev/serial0', 57600, 0xFFFFFFFF, 0x00000000)

except Exception:

print('The fingerprint sensor could not be initialized!')

print('')

main_menu()

else:

print('Currently used templates: ' + str(f.getTemplateCount()))

print('')

print_grab()

def print_grab():

global person

try:

f = PyFingerprint('/dev/serial0', 57600, 0xFFFFFFFF, 0x00000000)

mylcd.lcd_clear()

mylcd.lcd_display_string('Waiting For Finger', 2)

print('Waiting For Finger')

print('')

while not f.readImage():

pass

41
f.convertImage(0x01)

result = f.searchTemplate()

positionNumber = result[0]

if positionNumber == -1:

mylcd.lcd_clear()

mylcd.lcd_display_string(' No Match Found', 2)

print('No match found')

print('')

time.sleep(2)

main_menu()

else:

print('Found template at position #' + str(positionNumber))

print('')

mylcd.lcd_clear()

mylcd.lcd_display_string(' PLEASE WAIT', 2)

print('PLEASE WAIT')

print('')

f.loadTemplate(positionNumber, 0x01)

characteristics = str(f.downloadCharacteristics(0x01)).encode('utf-8')

val_hash = hashlib.sha256(characteristics).hexdigest()

conn = connect_to_db()

try:

with conn.cursor() as cursor:

42
sql = 'SELECT * FROM fingerprint_store WHERE id=%s'

cursor.execute(sql, (positionNumber,))

db_val = cursor.fetchall()

for row in db_val:

person = row['employee']

mylcd.lcd_clear()

mylcd.lcd_display_string(' ID NUMBER:', 2)

mylcd.lcd_display_string(' ' + str(person), 3)

print("YOUR ID NUMBER: " + str(person))

print('')

time.sleep(2)

finally:

conn.close()

check_if_in()

except Exception as e:

print(e)

def check_if_in():

global person

with pymysql.connect(

host='192.168.8.101',

user='rpi_fp',

password='1234567890',

database='payroll',

charset='utf8mb4'

43
) as conn:

with conn.cursor() as c:

date = datetime.date.today().strftime("%m-%d-%y")

c.execute('SELECT status_in FROM employees '

'WHERE first = %s AND date = %s', (person, date))

conn.commit()

result = c.fetchone()

if result is None:

write_in()

else:

check_if_out()

def write_in():

with pymysql.connect(

host='192.168.8.101',

user='rpi_fp',

password='1234567890',

database='payroll',

charset='utf8mb4'

) as conn:

with conn.cursor() as c:

status_in = 'IN'

timestamp = time.strftime('%I:%M %p')

day = datetime.date.today().strftime('%m-%d-%y')

c.execute("INSERT INTO employees (first, date, status_in, time_in) "

44
"VALUES(%s, %s, %s, %s)", [person, day, status_in, timestamp])

mylcd.lcd_clear()

mylcd.lcd_display_string(' Sign In Successful', 2)

print('Sign In Successful')

print('')

time.sleep(2)

conn.commit()

main_menu()

def check_if_out():

with pymysql.connect(

host='192.168.8.101',

user='rpi_fp',

password='1234567890',

database='payroll',

charset='utf8mb4'

) as conn:

with conn.cursor() as c:

date = datetime.date.today().strftime("%m-%d-%y")

c.execute('SELECT status_out FROM employees '

'WHERE first = %s AND date = %s', (person, date))

conn.commit()

result = c.fetchone()

convert = ''.join(map(str, result))

if convert == 'None':

45
write_out()

else:

mylcd.lcd_clear()

mylcd.lcd_display_string(' You Have Already', 1)

mylcd.lcd_display_string(' Signed IN & OUT', 2)

mylcd.lcd_display_string(' Today', 3)

print('You have already signed in and out for today')

print('')

time.sleep(2)

main_menu()

def write_out():

with pymysql.connect(

host='192.168.8.101',

user='rpi_fp',

password='1234567890',

database='payroll',

charset='utf8mb4'

) as conn:

with conn.cursor() as c:

date = datetime.date.today().strftime("%Y-%m-%d")

timestamp = time.strftime('%H:%M %p')

# Fetch the existing record for the current date and person

c.execute("SELECT status_in, time_in, status_out, time_out, hours_worked FROM


employees WHERE first = %s AND date = %s", [person, date])

result = c.fetchone()

46
if result:

if result[2] == 'OUT':

# User has already signed out for the day

mylcd.lcd_clear()

mylcd.lcd_display_string(' Already signed out', 2)

print('Already signed out')

print('')

time.sleep(2)

main_menu()

else:

# Update the existing record with the new status and time

c.execute("UPDATE employees SET status_out = 'OUT', time_out = %s


WHERE first = %s AND date = %s",

[timestamp, person, date])

# Calculate the hours worked and update the record

time_in = datetime.datetime.strptime(result[1], '%H:%M %p')

time_out = datetime.datetime.strptime(timestamp, '%H:%M %p')

hours_worked = (time_out - time_in).total_seconds() / 3600

c.execute("UPDATE employees SET hours_worked = %s WHERE first = %s


AND date = %s",

[hours_worked, person, date])

else:

# Insert a new record with the sign-out information

time_in = '00:00 AM'

47
c.execute("INSERT INTO employees (first, date, status_in, time_in, status_out,
time_out, hours_worked) "

"VALUES (%s, %s, 'IN', %s, 'OUT', %s, 0.0)",

[person, date, time_in, timestamp])

conn.commit()

mylcd.lcd_clear()

mylcd.lcd_display_string(' Sign Out Successful', 2)

print('Sign Out Successful')

print('')

time.sleep(2)

main_menu()

# the following code is for registering a user

# admin data entry

def password():

global fun

fun = fun.replace(fun, 'password')

mylcd.lcd_clear()

mylcd.lcd_display_string(' Password', 2)

print("Password")

print('')

def password_input(key):

global pressed_keys

global pin

if key == '#':

print(pressed_keys)

48
if pressed_keys == pin:

clear_keys()

# grad_month()

admin_menu_1()

else:

mylcd.lcd_clear()

mylcd.lcd_display_string(' Incorrect Password', 2)

print('Incorrect Password')

print('')

time.sleep(2)

main_menu()

else:

pressed_keys += key

def admin_menu_1():

global fun

clear_keys()

mylcd.lcd_clear()

fun = fun.replace(fun, 'admin_menu_1')

mylcd.lcd_display_string('1. Register User', 1)

mylcd.lcd_display_string('2. More Options' , 2)

mylcd.lcd_display_string('3. Main Menu', 3)

print('1. Register employee')

print('2. More options')

print('3. Main Menu')

49
print('')

def admin_input(key):

global pressed_keys

if key == '#':

print(pressed_keys)

if pressed_keys == "1":

print("send to grad_month")

print('')

clear_keys()

grad_month()

elif pressed_keys == "2":

print("send to more options")

print('')

clear_keys()

admin_menu_2()

elif pressed_keys == "3":

print("back to main menu")

print('')

clear_keys()

main_menu()

else:

mylcd.lcd_clear()

mylcd.lcd_display_string(' INVALID ENTRY', 2)

print('INVALID ENTRY')

50
print('')

time.sleep(2)

admin_menu_1()

else:

pressed_keys += key

def admin_menu_2():

global fun

clear_keys()

mylcd.lcd_clear()

fun = fun.replace(fun, 'admin_menu_2')

mylcd.lcd_display_string('1. Delete User', 1)

mylcd.lcd_display_string('2. Previous Menu', 2)

print('1. Delete User')

print('2. Previous Menu')

print('')

def admin_input2(key):

global pressed_keys

if key == '#':

print(pressed_keys)

if pressed_keys == "1":

print("send to unenroll user")

clear_keys()

unenroll()

elif pressed_keys == "2":

51
print("send back to prevous menu")

clear_keys()

admin_menu_1()

else:

mylcd.lcd_clear()

mylcd.lcd_display_string(' INVALID ENTRY', 2)

print('INVALID ENTRY')

print('')

time.sleep(2)

admin_menu_2()

else:

pressed_keys += key

def unenroll():

## Tries to initialize the sensor

try:

f = PyFingerprint('/dev/serial0', 57600, 0xFFFFFFFF, 0x00000000)

if ( f.verifyPassword() == False ):

raise ValueError('The given fingerprint sensor password is wrong!')

except Exception as e:

print('The fingerprint sensor could not be initialized!')

print('Exception message: ' + str(e))

print('')

52
mylcd.lcd_clear()

mylcd.lcd_display_string('Sensor could not', 2)

mylcd.lcd_display_string('be initialized', 3)

time.sleep(2)

admin_menu_2()

## Gets some sensor information

print('Currently used templates: ' + str(f.getTemplateCount()) +'/'+


str(f.getStorageCapacity()))

print('')

mylcd.lcd_clear()

mylcd.lcd_display_string('Templates: ' + str(f.getTemplateCount()) +'/'+


str(f.getStorageCapacity()), 2)

time.sleep(2)

## Tries to delete the template of the finger

try:

mylcd.lcd_clear()

mylcd.lcd_display_string(' User To Be Deleted', 3)

positionNumber = input('User To Be Deleted')

positionNumber = int(positionNumber)

print('')

if ( f.deleteTemplate(positionNumber) == True ):

mylcd.lcd_clear()

mylcd.lcd_display_string(' User Deleted', 2)

print('User Deleted!')

print('')

53
time.sleep(2)

admin_menu_2()

except Exception as e:

print('Operation failed!')

print('Exception message: ' + str(e))

print('')

mylcd.lcd_clear()

mylcd.lcd_display_string(' Operation Failed!', 2)

time.sleep(2)

admin_menu_2()

def grad_month():

global fun

fun = fun.replace(fun, 'month')

mylcd.lcd_clear()

mylcd.lcd_display_string(' YOUR DEPARTEMENT', 1)

mylcd.lcd_display_string('1. IT 2. FIN', 2)

mylcd.lcd_display_string('3. MARK 4. HR', 3)

mylcd.lcd_display_string('5. SECU 6. JANT', 4)

print('YOUR DEPARTMENET')

print('1. IT 2. FIN 3. MARK')

print('4. HR 5. SECU 6. JANT')

def month_input(key):

global pressed_keys

global month

54
if key == '#':

months = {

'1': 'IT', '2': 'FIN', '3': 'MARK', '4': 'HR',

'5': 'SECU', '6': 'JANT'

if pressed_keys in months:

month = months[pressed_keys]

clear_keys()

grad_year()

else:

mylcd.lcd_clear()

mylcd.lcd_display_string(' INCORRECT SELECTION', 2)

print("INCORRECT SELECTION")

print('')

time.sleep(2)

clear_keys()

grad_month()

else:

pressed_keys = key # Update to assign the current key rather than appending it

def grad_year():

global fun

fun = fun.replace(fun, 'year')

mylcd.lcd_clear()

55
mylcd.lcd_display_string(' JOINING YEAR', 2)

mylcd.lcd_display_string(' (Two Digit Format)', 3)

print('Last Two Digits Of Joining year')

print('')

def year_input(key):

global pressed_keys

global year

if key == '#':

if len(pressed_keys) != 2:

clear_keys()

mylcd.lcd_clear()

mylcd.lcd_display_string(' INCORRECT FORMAT', 2)

print("INCORRECT FORMAT")

print('')

time.sleep(2)

clear_keys()

stnum()

else:

year = pressed_keys

clear_keys()

stnum()

else:

pressed_keys += key

def stnum():

56
global fun

fun = fun.replace(fun, 'stnum')

mylcd.lcd_clear()

mylcd.lcd_display_string(' Employee Number', 2)

mylcd.lcd_display_string(' (Four Digits)', 3)

print('Employee Number')

print('(Four Digits)')

print('')

def stnum_entry(key):

global pressed_keys

global employee_number

if key == '#':

if len(pressed_keys) != 4:

clear_keys()

mylcd.lcd_clear()

mylcd.lcd_display_string(' INVALID ENTRY', 2)

print('INVALID ENTRY')

print('')

time.sleep(2)

stnum()

else:

employee_number = pressed_keys

clear_keys()

confirm()

57
else:

pressed_keys += key

def confirm():

global fun

global employee

fun = fun.replace(fun, 'confirm')

employee = month + "/" + employee_number + "/" + year

mylcd.lcd_clear()

mylcd.lcd_display_string(' Confirm ID:', 1)

mylcd.lcd_display_string(' ' + employee, 2)

mylcd.lcd_display_string('1. Confirm', 3)

mylcd.lcd_display_string('2. Cancel', 4)

print("ID:", employee)

print("1 : Confirm")

print("2 : Cancel")

print('')

def confirm_entry(key):

global pressed_keys

global employee

global first_initial

global last_initial

global employee_number

global month

58
global year

if key == '#':

if pressed_keys == '1':

clear_keys()

enroll()

elif pressed_keys == '2':

first_initial = first_initial.replace(first_initial, '')

last_initial = last_initial.replace(last_initial, '')

employee_number = employee_number.replace(employee_number, '')

month = month.replace(month, '')

year = year.replace(year, '')

clear_keys()

main_menu()

else:

clear_keys()

mylcd.lcd_clear()

mylcd.lcd_display_string(' INVALID ENTRY', 2)

print('INVALID ENTRY')

print('')

time.sleep(2)

confirm()

else:

pressed_keys += key

# Registration enrollment process begins here

59
# Checking db to see if ID already taken

def enroll():

global employee

global r

print(employee)

r = employee

print('employee ID:', r)

print('')

conn = pymysql.connect(

host='192.168.8.101',

user='rpi_fp',

password='1234567890',

db='payroll',

charset='utf8mb4',

cursorclass=pymysql.cursors.DictCursor

try:

with conn.cursor() as cursor:

cursor.execute('SELECT employee FROM fingerprint_store WHERE employee =


%s', (r,))

result = cursor.fetchone()

if result:

mylcd.lcd_clear()

mylcd.lcd_display_string(' ID Already Exists', 2)

print('ID Already Exists')

60
print('')

time.sleep(2)

main_menu()

else:

try:

f = PyFingerprint('/dev/serial0', 57600, 0xFFFFFFFF, 0x00000000)

if not f.verifyPassword():

print('Contact Admin')

print('')

time.sleep(2)

raise ValueError('The given fingerprint sensor password is wrong')

except Exception as e:

mylcd.lcd_clear()

mylcd.lcd_display_string(' Contact Admin', 2)

print('Contact Admin')

print('')

time.sleep(2)

print('The fingerprint sensor could not be initialized')

print('Exception message: ' + str(e))

print('')

main_menu()

print('Currently used templates: ' + str(f.getTemplateCount()))

print('')

61
try:

while True:

mylcd.lcd_clear()

mylcd.lcd_display_string('*Place Finger*', 2)

print('*Place Finger*')

print('')

# Wait for finger to be read

while not f.readImage():

pass

f.convertImage(0x01)

mylcd.lcd_clear()

mylcd.lcd_display_string('*Remove Finger*', 2)

print('*Remove Finger*')

print('')

time.sleep(2)

mylcd.lcd_clear()

mylcd.lcd_display_string('*Place Same Finger Again*', 2)

print('*Place Same Finger Again*')

print('')

# waiting for second read

while not f.readImage():

pass

f.convertImage(0X02)

62
if f.compareCharacteristics() != 0:

mylcd.lcd_clear()

mylcd.lcd_display_string('Fingerprint Matched', 2)

print('Fingerprint Matched')

print('')

time.sleep(2)

f.createTemplate()

positionNumber = f.storeTemplate()

f.loadTemplate(positionNumber, 0X01)

characteristics = str(f.downloadCharacteristics(0x01)).encode('utf-8')

cre_hash = hashlib.sha256(characteristics).hexdigest()

cursor.execute('INSERT INTO fingerprint_store (employee, hashval, id)


VALUES (%s, %s, %s)',

(r, cre_hash, positionNumber))

conn.commit()

mylcd.lcd_clear()

mylcd.lcd_display_string('Fingerprint Registered', 2)

print('Fingerprint Registered In Position ' + str(positionNumber))

print('')

time.sleep(2)

admin_menu_1()

break

else:

mylcd.lcd_clear()

63
mylcd.lcd_display_string('Fingers Do Not Match', 2)

print('Fingers Do Not Match')

print('')

time.sleep(2)

except Exception as e:

print('Operation failed - Exception message: ' + str(e))

print('')

main_menu()

finally:

conn.close()

# Keypad stuff

KEYPAD = [

["1", "2", "3", "A"],

["4", "5", "6", "B"],

["7", "8", "9", "C"],

["*", "0", "#", "D"]

# same as calling: factory.create_4_by_4_keypad, still we put here fyi:

ROW_PINS = [16, 20, 21,

5] # BCM numbering; Board numbering is: 7,8,10,11 (see pinout.xyz/)

COL_PINS = [6, 13, 19,

26] # BCM numbering; Board numbering is: 12,13,15,16 (see pinout.xyz/)

factory = rpi_gpio.KeypadFactory()

# Try keypad = factory.create_4_by_3_keypad() or

64
# Try keypad = factory.create_4_by_4_keypad() #for reasonable defaults

# or define your own:

keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS,

col_pins=COL_PINS)

def printkey(key):

print(key)

keypad.registerKeyPressHandler(printkey)

# function to clear string

def clear_keys():

global pressed_keys

pressed_keys = pressed_keys.replace(pressed_keys, '')

def store_key(key):

global pressed_keys

if key == '#':

print(pressed_keys)

if pressed_keys == "1":

clear_keys()

finger()

elif pressed_keys == "2":

print("send to pwd")

clear_keys()

password()

elif pressed_keys == "3":

print("send to shutdown")

65
clear_keys()

shutdownmenu()

else:

mylcd.lcd_clear()

mylcd.lcd_display_string(' INVALID ENTRY', 2)

print('INVALID ENTRY')

print('')

time.sleep(2)

main_menu()

else:

pressed_keys += key

# initial options

def boot_sequence():

mylcd.lcd_clear()

mylcd.lcd_display_string(' BOOTING', 1)

mylcd.lcd_display_string(' [ ] ', 3)

time.sleep(.1)

mylcd.lcd_display_string(' [ * ] ', 3)

time.sleep(.1)

mylcd.lcd_display_string(' [ *** ] ', 3)

time.sleep(.1)

mylcd.lcd_display_string(' [ ***** ] ', 3)

time.sleep(.1)

mylcd.lcd_display_string(' [*******] ', 3)

66
time.sleep(.1)

main_menu()

def main_menu():

global fun

clear_keys()

mylcd.lcd_clear()

mylcd.lcd_display_string('Select, then press #', 1)

mylcd.lcd_display_string('1. Sign In & Out', 2)

mylcd.lcd_display_string('2. Admin Menu', 3)

print('1. Sign in & Out')

print('2. Admin Menu')

print('')

fun = fun.replace(fun, 'main_menu')

boot_sequence()

# This function is called each time a keypad button is

def keyHandler(key):

if fun == 'main_menu':

store_key(key)

elif fun == 'password':

password_input(key)

elif fun == 'admin_menu_1':

admin_input(key)

elif fun == 'admin_menu_2':

admin_input2(key)

67
elif fun == 'confirm_del':

delete_db(key)

elif fun == 'year':

year_input(key)

elif fun == 'month':

month_input(key)

elif fun == 'stnum':

stnum_entry(key)

elif fun == 'confirm':

confirm_entry(key)

elif fun == 'shutdownmenu':

confirm_shutdown(key)

keypad.registerKeyPressHandler(keyHandler)

try:

while (True):

time.sleep(0.2)

except:

keypad.cleanup()

68

View publication stats

You might also like