Hardware Employee Time Tracking with RFID Chips

We want to create a hardware device which allows employees to punch in and out of work using a RFID reader which stores the information in ERPNext.

Problem:

Most of our users are not salaried but get paid by the hour. Currently the information about work times is recorded outside of ERPNext using a RFID tracker that writes to a SQL database and has closed source software for the analytics.

Solution:

We will create a hardware device which will read an RFID tag and allow our employees to punch in an out which will call our ERPNext API. All data will be stored in ERPNext. The project itself will be completely open source so people can DIY or they might eventually be able to buy pre-fabricated devices with RFID chips from us if there is enough interest in this thing.

The prototype hardware will consist of an Arduino Uno, a simple display and 3 buttons (come, go, info), a buzzer and a Mifare RFID reader (RC522).

Basic function description:

  1. User presents RFID-tag to device and presses green “come” button. Device calls ERPNext API passing the RFID tag id. ERPNext logs come and returns employee name, employee number, start date, start time.

  2. User works his shift

  3. When user goes into break or leaves work he presses the red “go” button. Device calls ERPNext API passing the RFID tag ID. ERPNext logs go and returns employee name, employee number, start date, start time, work time.

  4. If user wants to know how many hours he has worked this month he can press the grey “info” button. It will give him his hours today and his ours this month.

Todo:

  1. We will develop the hardware, create BOM and schematics on how to assemble this
  2. The devices’ software will have to be written
  3. Make changes to ERPNext employee DocType to store RFID Tag
  4. Create or modify DocType to store information (see Questions below)
  5. Implement API

Questions:

How will we store the actual time logs start / stop and how will we analyze it? There are timesheets which are more to track specific actions instead of overall work time. Also there is employee attendance but that tracks only the days which employees were present.

21 Likes

@rmehta do you have an opinion on how we would save the time logs for the employees?

1 Like

Hi @dominik,

we have a similar topic, where we have extended the attendence module to not only cover present on a day or not, but actual working hours; also using a sign in/out. Maybe this would be the way to go in your case as well… (actual time tracking is done on timesheet, but not all time present is actually done in projects)

Track attendance?

Hello,
I did same for biomatrix
using attendance doctype add one child table for time logs in attendance doctype and add one custom field for total hours.
make three api’s
1)For In Punch:
when employee come and punch in then one entry add in time logs for IN.

2)For Out Punch:
when employee punch for out then update child table row that have last In punch and calculate OutTime-InTime=Total Hours
(Total Hours is update only when out punched)

3)For Total Hours Today&Month:
pass date today and make api which give today total hours from “total_hours” field and current month “total hours” sum of “total_hours” field from all document of current month.

1 Like

Hardware progress update

Working first prototype with Arduino Uno, LCD Display, RFID RC5522 Kit and a few resistors and buttons. It currently waits for the start button (left) or stop button (right), then gives the user 3 seconds to present the RFID tag. If tag presented it reads it.

Next step will be API calls to ERPNext to get the employee info for the tag and to make start and stop calls. I will also add a buzzer to give an audible signal on button press and RFID tag read.

10 Likes

@rmehta @lasalesi @Maheshwari_Bhavesh thank you for your feedback. We will start our PR tomorrow.

TODO

  • Add field „RFID Tag“ (Data) to Employee
  • Add childtable „Attendance Times“ to Attendance with fields (Start Time, Stop Time, Duration)
  • Add „Attendance Duration“ to Attendance as summarized field for that day.

When employee punches in add a row to the child table.
When Employee punches out add to the latest start and calculate duration in minutes.

Add API functions

punchIn(tag)

Only works if employee not currently punched in, otherwise return error.

Return:

  • status „OK“
  • employee_name „John Doe“
  • startdate „2018-08-01“
  • timezone „…“
  • starttime „17:14“

punchout(tag)

Only works if employee currently punched in, otherwise return error. Only works if start and end timezone the same.

Return:

  • status „OK“
  • employee_name „John Doe“
  • stopdate „2018-08-01“
  • stoptime „18:14“
  • timezone „…“
  • duration_min „60“

To Consider

  • If employee punches in, automatically create Attendance for that day
  • If employee works over midnight, automatically create proper records for first and second day
  • Consider employee timezone (don’t log server but employee timezone)
  • API needs a dedicated API user that can be set in the Arduino
2 Likes

This is a preliminary space usage sketch of how an integrated hardware could look like:


2 Likes

Hardware progress update

  • Upgraded from Arduino Uno to Arduino Mega to have more IO and more flash memory. Added ethernet controller.
  • Received a bag of RFID tags for testing.
  • Will also add Mini SD card to store config parameters such as IP, ERPNext API credentials etc.
  • The functional mockup is getting more and more crazy as there are now dozens of wires going back and forth.
  • Hardware design in Altium Designer has started, preliminary BOM created.

Current Breadboard Design

Preliminary BOM for Top Components

4 Likes

Hi All, here are a few notes from our testing and our design suggestion:

In the current design in ERPNext, here is how we should do it.

  1. We have to setup “Salary Structure” to set per Hour rate of hourly employees.
  2. When employee Punches IN first for the day, it will create “Timesheet” record with first line Item. It will put entry in “From Time”, leaving the “To Time” empty. When it punches “Go” then it will log the “To Time” of the first line. We will create multiple lines in one timesheet basing from how many times the employee time in and out.
  3. For the Info Button, it will just calculate the tentative time for the day and the summation of all submitted timesheet in the current month.
  4. at the end of the month or at the end of a salary cycle, accounting personnel can create Salary Slip basing from all the timesheet it created and calculate total amount from the Salary Structure set rate
  5. As for the current “Attendance” doctype in ERPNext, it will only log if employee is present or not regardless of the time it consumed. So once a timesheet is submitted by end of shift, it will create an entry to Attendance tagging employee as present.

This is okay but there are concerns that we need to raise:

  1. If the attendance time is track in Timesheet and the employee tracks an Activity within his attendance duration, then this is a duplicate.
  2. Timesheet can be manipulated unless restricted through permission.

Any thoughts on these concerns?

Tagging @nabinhait @rmehta

Regards,

Dory

1 Like

Hardware UI Interaction Mockups:

3 Likes

Hardware progress update

First preliminary 3D model of PCB for component placing.

1 Like

Thanks for your great write up @dominik

Great to see your thinking behind your requirements and ongoing realisation of it

2 Likes

The hardware is designed, circuit boards and all components have been purchased for 10 prototypes and will arrive here on Thursday.

We are also designing and 3D prining the casing as we speak.

I expect the boards to be finished this Friday.

We are now writing the firmware for the embedded system in C++.

What’s needed now is the ERPNext side of things. I would really appreciate some input and ideas on how to do it right. We need to get this going.

If anyone is interested in a device please write me an email. I would give away 5 of the first boards for manufacturing cost so we can test it and optimize it together.

6 Likes

This is awesome @dominik, @creamdory

My thoughts:

  • Attendance: Maybe we can have a new doctype called “Employee Checkin” (Employee, Location, Timestamp) that can log an employee at a location multiple times. At the end of the day we can run a scheduled script to mark in-time and out-time in Attendance (min and max)

  • Hourly Payroll: I like @creamdory’s idea to a weekly or monthly timesheet from checkins (with each shift in the line item) and link it to payroll. So before going to payroll there, someone can verify the total hours etc. This can automatically be created from the checkins.

I think @Pawan may have some ideas here!

3 Likes

Thank you for your feedback @rmehta

I think the timesheets (what billable or non billable thing did they do specifically) and the attendance (when were thy present) are two things. I also think that it should maybe go the other way that we pay per attendance and a time sheet could create attendance.

Instead of employee checkin what about attendance log?

Few thoughts

  1. Currently option to link Payroll to timesheets already exists and if option to link Payroll to attendance is required then that can be built. I think that is a feature many need. Payroll can feed off attendance data to get the number of working days and use it as an input to Payroll. There could be complications of half-day etc, in this method that would need to be factored into the payroll design.

  2. I agree on Attendance Log and taking min(in-time) and max(out-time) to create the final attendance record which would serve as an input to payroll. HR settings or setting at company level should dictate what is the input for payroll.

  3. Timesheet creating attendance is not a good idea, because timesheets are sometimes entered just to bill customers & are not related to attendance. So having payroll based on timesheet or payroll based on attendance should be mutually exclusive in my opinion.

5 Likes

@creamdory and @Pawan could you two connect and make a proposal that we can implement?

1 Like

Yes sure @dominik.

@Pawan thanks for your thoughts. So here is my assessment and suggested Design.

  1. Create new child doctype in Attendance called Attendance Log. This is the doctype Rushabh is referring to “Employee Checkin”. Fields will be:
  • Location
  • Time In
  • Time Out
  • Duration
  1. In HR Setting > Payroll Section, add field “Salary Slip Based On” with select options “Timesheet” and “Attendance Log”. Max working hours against Timesheet will show only for “Timesheet”.

  2. In Salary Structure, add checkbox “Salary Slip Based on Attendance Log”. We can have this auto populated based on the HR setting.

  3. Add new Doctype Attendance Log Validate. It will have the fields below:

  • Employee Link
  • Date From
  • Date To
  • Table which will be autopopulated with all the attendance logs base on the date duration.

User will be allowed to edit this for Salary Slip purposes. This will be the information pulled in the Salary Slip for payment.

  1. Edit script for these changes.

If this is okay, we can proceed with the development.

@dominik @rmehta

Thanks,

Dory