close
20180508_174531_1

Overview

This project is an attendance system using RFID tags/stickers to communicate with an MFRC522 RFID Reader/Writer Module that is connected to an Arduino UNO. The authentication data that is received by the Arduino UNO is then transmitted to Google Spreadsheets through an ENC28J60 Ethernet Module for real-time data storage and access. This makes the attendance system paperless and organized because of the timestamp, card key, and username columns in the spreadsheet API.

Hardware Components

Software Components

Application Discussion

How does an RFID Reader/Writer Module work?

An RFID, which means Radio-Frequency Identification, system consists of two main components: a transponder, a.k.a. tag, which is located on the object that we want to be identified, and a transceiver or a reader.

RFID How It Works

The RFID reader consists of a radio frequency module, a control unit and an antenna coil (inside the RFID reader/writer module) which generates a high-frequency electromagnetic field. On the other hand, the tag is usually a passive component, which consists of just an antenna and an electronic microchip. When it gets near the electromagnetic field of the transceiver, due to induction, a voltage is generated in its antenna coil and this voltage serves as power for the microchip.

Technical Details (MFRC522 Reader/Writer Module by Robotdyn)

Compatibility: can read and write Mifare’s tags, also supports MF1xxS20, MF1xxS70 and MF1xxS50 tags

Frequency: communicate using a 13.56MHz electromagnetic field.

Transfer speeds: up to 848 kBd in both directions

Size: 36x36mm

Power:  3.3V or 5V.

Note: If using 5v, you must a logic-level converter to make it 3.3V.

Antenna: built-in

Range of sensitivity: height of 25m

RFID Working Principle

Now as the tag is powered, it can extract the transmitted message from the reader, and for sending a message back to the reader, it uses a technique called load manipulation. Switching on and off a load at the antenna of the tag will affect the power consumption of the reader’s antenna which can be measured as voltage drop. These changes in the voltage will be captured as ones and zeros and that’s the way the data is transferred from the tag to the reader.

Another way of transferring data between the tag and reader is called backscattered coupling. In this case, the tag uses part of the received power for generating another electromagnetic field which will be picked up by the reader’s antenna. [1]

How does an ENC28J60 module work?

The code “ENC28J60” refers to a chip developed by Microchip.  This chip has 28 pins and contains a complete stand-alone Ethernet controller for a 10BASE-T network connection with an SPI interface so microcontrollers like the Arduino can communicate to it.

10BASE-T is the same connector you’ll find on your computer (if it has one) to connect with a wire to a network, where “10” indicates a maximum speed of 10 Mbit/sec. That might sound slow, but if you consider that it’s being used by devices like the Arduino, then you can’t really expect massive data loads anyway. [2]

 

Image result for 10base-t connectors
Photo Credit: Router Switch Blog

Technical Details (ENC28J60 Ethernet Module by RobotDyn)

ENC28J60 is a 10BASE-T stand alone Ethernet module with on board MAC & PHY,

Buffer RAM: 8 kBytes

SPI serial interface for 3.3V and 5V logics.

Target applications: VoIP, Industrial Automation, Building Automation, Home Control, Security, and Instrumentation.

Set-up the Hardware

The whole setup is divided into four main categories which are to be done in a chronological order: Google Spreadsheets and Google Script setup, Pushingbox API setup, hardware setup and assembly, and Arduino IDE setup.

Google Spreadsheets and Google Script setup:

Login to your Google account in your browser. Open sheets.google.com.

Make a new spreadsheet document. Rename it. Place column labels on your spreadsheet like this.

In the tabs above the document, click Tools –>Script Editor. Copy and paste the Google Script code below. Keep in mind that the language used is JavaScript. If you want to add another column to the spreadsheet, be sure to add another switch case statement in the Google Script code.  Copy the syntax of one switch case statement and rename the case name and rowData value inside the brackets [].

Go back to your spreadsheet document to get the Spreadsheet ID needed for the Google Script code. Copy your spreadsheet ID (the highlighted portion in the picture below) and paste it between the apostrophes in

In the Google Script tab in the upper left corner, click File –> Save. Rename your project.

Click Publish tab –> Deploy as web app. Change the access in the “Who has access to the app” portion into “Anyone, even anonymous”, and click the Deploy button.

Then, it will ask for an authorization request. Click the Review Permissions button. Choose the Google Account that you will give permission for access to this app. It will show a safety warning dialog box. But no worries, click Advanced –> click Go to <file name> (unsafe). Then click the Allow button.

Before you click OK, copy the web app URL first. Then press OK. Paste your web app URL under the GET request query portion of the Google Script code for safekeeping purposes.

You can test if your Google Script code is working by putting some sample data in your web app URL. For example, you want to post John Smith in the username column. Just add “?ID=John Smith” after the exec in the web app URL. Paste the whole URL into your browser and click Enter (If John Smith doesn’t work, try adding %20 after John to remove the space).

The webpage should display Ok and your spreadsheet document should look like this. If the time is not showing in the timestamp column, click Format tab in the spreadsheet –> Number –> Date time.

Now we’re done in the software setup for Google Spreadsheets and Google Script. Do not proceed to the next steps if the sample data is not posted in the spreadsheet. If it isn’t posting, try making a new spreadsheet document and re-doing the steps again.

Pushingbox API setup

Go to www.pushingbox.com. Click login with Google in the upper right corner of the webpage. Click My Services tab. Click Add A Service button. Scroll down and click the Select This Service button beside the CustomURL service. Type down the name of your CustomURL configuration and paste your Google Script web app URL code in the Root URL textbox and click the Submit button.

Click the MY SCENARIOS tab. In the “Add a Device or Scenario” portion, enter the name of your new scenario and click the Add button. Click the Add an Action button. Click the Add an action with this service button beside the scenario you’ve just created. If the name of your scenario, for example, is Online Attendance Monitoring, click the Add an action with this service button beside it. In the Data text box, place the data format as shown below.  Then click the submit button. 

Now you can access and sample test your PushingBox API by sending GET requests in your browser URL in this format: (Your Device ID is seen after you click the Update button. It is shown below the Scenario name.)

A sample PushingBox URL would be:

Copy and paste that into your browser and it should post the data in your spreadsheet document like this:

Now we’re done with the software setup for PushingBox API. Again, don’t proceed to the next steps if the sample testing didn’t work. If it didn’t, try making a new spreadsheet document and re-doing the steps from the Spreadsheet and Script setup up to the PushingBox API setup.

Hardware Setup and Assembly

Setup your hardware as shown below.

NOTE: Make sure to ground both GND pins of the Ethernet module for it to work properly. Also, connect your ethernet port of the module to the LAN port of your router by using a UTP cable.

Both the RFID and Ethernet modules use SPI to communicate to Arduino so they share pins 11 to 13, which are MOSI (Master Out Slave In), MISO (Master In Slave Out), and SCK (Serial Clock) respectively. Since both of them use SPI, we have to assign separate pins for the modules as Chip Select or Slave Select pin. The Ethernet module automatically assumes pin 10 as chip select, and the RFID module uses pin 9 as slave select (in SDA pin). To activate one of the slave devices, you have to set the CS pin to LOW by the digitalWrite() command. You can’t activate both of the devices so you have to enable one device and disable the other. For this project, we first used the RFID module to detect and store card key strings. After storing, we disable the RFID module and enabled the ethernet module to relay the information to the spreadsheet using the Ethernet connection.

Arduino IDE setup

Copy and paste the Arduino code below to your IDE.

To get the MAC address of your internet connection. Follow these simple steps.

For MAC Users

Connect the ethernet port of your Mac to the LAN port of your router by using a UTP Cable.

Go to System Preferences –> Click Network –>Click Ethernet on the left portion. –> Click Advanced –> Click Hardware Tab. Then, you will see the MAC address. Copy it and paste it into the Arduino code specifically in the

Replace the letters inside the brackets {} with the MAC pair characters. If your MAC address is 10:a1:b1:ad:66:df, the format should be

For Windows users

Connect the ethernet port of your PC to the LAN port of your router by using a UTP Cable.

Click the icon, in the toolbar below the desktop, that looks like a PC monitor. Click Network & Internet Settings. Click View Your Network Properties in the Status Tab (right side). Find the network property that is named Ethernet, and copy the Physical Address (MAC) and paste it into the Arduino code with the same format as above.

To continue the Arduino IDE setup

Paste your PushingBox Device ID in the <insertPushingBoxdevIDhere> portion of the Arduino code (Make sure to remove the <> symbols).

Press RUN and tap your NFC/RFID tag. A sample serial monitor output will look like this (the whole output can be seen in the featured image):

Code

Libraries used

SPI.h by Arduino

This library is used if you’ll use pins 10-13, which are used for SPI communication.

EtherCard.h by Jean-Claude Wippler

This library is used if you will use an ENC28J60 Ethernet Module. Using an Ethernet Shield, you will have to use a different library. This library only supports the ENC28J60 chip. Depending on the size of the buffer for packets, this library uses about 1k of Arduino RAM. Large strings and other global variables can easily push the limits of smaller microcontrollers. This library uses the SPI interface of the microcontroller and will require at least one dedicated pin for CS, plus the SO, SI, and SCK pins of the SPI interface.

MFRC522.h by Miguel Balboa

This is the Arduino library for MFRC522 and other RFID RC522 based modules. It reads and writes different types of Radio-Frequency IDentification (RFID) cards on your Arduino using an RC522 based reader connected via the Serial Peripheral Interface (SPI) interface. For more details about the technical and compatibility aspects, click the link above.

Google Script code

Arduino IDE code

Conclusion

This project has its own limitations. An example would be that it would take a lot of time to connect to the internet when you scan your RFID tag for the second time. It was hard making this happen but at least you’ve come this far! You’ve now accomplished another IoT mini-project. You can now tinker and edit the hardware and software to make it advanced.

References

[1] – https://howtomechatronics.com/tutorials/arduino/rfid-works-make-arduino-based-rfid-door-lock/

[2] – https://www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/

Tags : apiarduinodatadata storageenc28j60ethercard.hethernetethernet modulegoogle scriptgoogle spreadsheetshome securityindustrial automationinternet of thingsiotjavascriptmfrc522mfrc522.hoffice securitypushingboxreal-time accessrfidrfid attendance systemrfid modulerobotdynspi.hspreadsheets

Leave a Response