Skip to content

Arduino ESP32 ESP8266, RFID-MFRC522 Logger; read card with RC522 , send to SQL via web server over SSL

License

Notifications You must be signed in to change notification settings

gojimmypi/RFID_Logger

Repository files navigation

RFID Logger

This project is in active development. Feedback, ideas, suggestions, and PRs welcome.

Overview

This RFID Logger project uses the ThingPulse board specifically because of the low-power feature. (likely adaptable to other ESP32 boards, as well) along with an RFID reader such as this Mifare RC522 RFID Reader on Amazon. The intention of this project is to keep track of staff movements similar to an IN/OUT attendance board. Clearly much of the reliability and accuracy is based on the honor system to ensure cards are consistently used.

The Arduino MKRWi-Fi 1010, as well as the NodeMCU ESP8266 can also be used by uncommenting the settings in the GlobalDefine.h file.

See Project Emclosure Assembly Information.

lid cover view

Operation

The microcontroller waits for a card to be detected. Once a card is present, the UID is read and sent to a web server over HTTPS which saves the information in a SQL table.

In concept, this project could be used to control pretty much anything with the swipe of an RFID card. The receiving code could also be readily modified to save data to other databases, or even a text file.

Although this project focuses on the ESP32, the ESP8266 and MKR WiFi 1010 can also be used. Both regular and enterprise authentication are also supported.

If you are interested in guest authentication, check out my desktop dashboard that programmatically clicks the "I accept terms and conditions" and (simulates) pressing enter to connect to internet. Guest authentication is not (yet) implemented here.

Getting Started

Clone this repo to your local drive (typically in the c:\workspace directory for Windows users):

c:
mkdir -p c:\workspace
cd workspace
git clone https://github.com/gojimmypi/RFID_Logger.git

Assign your private settings

Edit the GlobalDefine.h file, and create/edit your own myPrivateSettings.h file:

#define USE_myPrivateSettings true

#if USE_myPrivateSettings == true 

#include "/workspace-git/myPrivateSettings.h"

#else

... your settings here for USE_myPrivateSettings == false, or copy example settings to your own myPrivateSettings.h

It is not recommended to set USE_myPrivateSettings == false, as it is usually best to keep your passwords and private settings someplace that will not be inadvertantly saved to GitHub. But yes, you can set this and edit the settings directly in the GlobalDefine.h file.

Build and upload RFID_Logger Code

The code is Arduino-style C created in Visual Studio using the Visual Micro Extension; see also the Arduino IDE for Visual Studio (Visual Micro) on the marketplace. It should also work just fine in the Arduino IDE (see the RFID_Logger.ino file)

Check the the proper board is selected (e.g. ESP32 WROVER for the ThingPulse board), and the appropriate settings for either environment:

Build with Visual Studio and Visual Micro Arduino IDE Extension.

Install the Visual Micro IDE Extension, if needed.

Open RFID_Logger.sln in Visual Studio. Check settings and select your COM port:

VisualStudio_IDE_Settings

Build with Arduino IDE

Open RFID_Logger.ino in the Arduino IDE. Check settings and select your COM port:

Arduino_IDE_Settings

Supported Hardware

Any Arduino-style device with Wi-Fi and SPI capabilities could probably be used; at this time both the ESP8266 and ESP32 are supported, as well as the Ardunio MKR WiFi 1010, using either regular or enterprise Wi-Fi, and communicating over SSL.

Design Concepts

The main app sits in an infinite loop awaiting a card to be detected. See the WiFi Helper for connection to WiFi. There's an IIS Web App for listening for inbound data. Data is saved in a SQL Table by a stored procedure called from the web page.

With Enterprise Security at the WiFi AP, integrated security could be configured at the web server.

Why not a Raspberry Pi? The only thing we are doing is sending an RFID value to a database. Yes, the implementation would probably be easier on a Raspberry Pi. But we don't need the complexity and vulerabilities of an entire operating system. An embedded controller is also vastly more appropriate for low power applications.

This solution should NOT be used for security applications, as noted here and repeated here:

Security


  • The UID of a card can not be used as an unique identification for security related projects. Some cards allow the UID to be changed - which means you can easily clone a card. For projects like access control, door opener or payment systems you must implement an additional security mechanism like a password or normal key.

  • This library only supports crypto1-encrypted communication. Crypto1 has been known as broken for a few years, so it does NOT offer ANY security, it is virtually unencrypted communication. Do not use it for any security related applications!

  • This library does not offer 3DES or AES authentication used by cards like the Mifare DESFire, it may be possible to be implemented because the datasheet says there is support. We hope for pull requests :).

Libraries needed:

This section applied to both Visual Micro and the Arduino IDE as Visual Micro uses the same settings and library paths as the Arduino IDE.

In the Arduino IDE, under File - Prewferences, enter a comma-delimited Additional Boards Manager URL such as these two for the ESP8266 and ESP32:

https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://dl.espressif.com/dl/package_esp32_index.json

Low Power Mode

Unfortunately, the D1 LED on the blue version of the board is a straight 10K power to ground as shown on the schematic. This LED drops about 1.8v so we have (3.3 - 1.8) / 10,000 = 0.15mA (150 microamps) wasted on a power indicator we can't even control. Ok, this is not a lot. On battery, every microamp counts. The entire RFID board consumes just under 10mA during normal operation (9.67mA measured).

See section 8.6 Power reduction modes (page 33) of the MFRC522 data sheet and TODO...

There's a SunFounder Mifare RC522 Card Reader that is more expensive, but appears to not have the LED. The wiki claims the idle current is still 10-13mA.

Parts

Not PN532 NFC/RFID

This code is not compatible with the PN532 NFC/RFID technology, such as the Adafruit PN532

Not 125kHz RFID Key Fob

Although they may look similar, this solution does not work with 125kHz RFID Key Fobs.

Troubleshooting

  • Make sure firewall port 443 is open on target system for the Wi-Fi IP address of your device. (beware DHCP addresses can change over time)
  • Check to see if any other program is using the COM port (Other instances of Visual Studio, Arduino IDE Serial Monitor, putty sessions, VM connections, etc.)
  • See miguelbalboa/rfid

Links to this project:

Resources, Inspiration, Credits, and Other Links:

I'd like to thank:

  • Dani for all the creative ideas exchanged via DM
  • Martin for all the great RFID code examples
  • Espressif for a simply amazing, low cost embedded controller: the ESP32

Essentials:

MKR WiFi 1010

Code samples:

WiFi:

HTTP:

RFID:

Power Related:

GitHub Issues:

Other stuff:

About

Arduino ESP32 ESP8266, RFID-MFRC522 Logger; read card with RC522 , send to SQL via web server over SSL

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published