Introduction: How to Display Data Read by MFRC522 Through LCD With Arduino
Due to my personal interest, I have been exposed to the development of Arduino for two weeks and found that Arduino is very simple, convenient, and practical. So I want to do a simple Demo with Arduino. I have an MFRC522 module at home, which I used when I was in college, but used STM32 to communicate with the MFRC522 module at that time, so I need to write the driver of the MFRC522 module by myself, which is quite complicated. Arduino has its own MFRC522 library file, so I don't have to write the driver file myself. This will be very convenient to use.
Step 1: Function
I need to make a Demo that can read MI card data and display the read data to the LCD screen.
According to this requirement, I need the following materials: Arduino UNO development board MFRC522 module LCD displayer The MI card Due to the serial communication in the Arduino demo program, it is better to operate the displayer through serial ports. And I just have a serial LCD displayer screen at home, which is also very convenient and easy to use, which will be introduced later.
Step 2: Hardware
There are three electronic modules in the project, which I will introduce one by one.
MFRC522 is a low-voltage, low-cost, small contactless read-write card chip launched by NXP, which is the choice for the development of smart meters and portable handheld devices.
Using advanced modulation and demodulation concepts, MFRC522 fully integrates all types of passive contactless communication modes and protocols at 13.56MHz.Support multi-layer application of ISO14443A.The internal transmitter section drives the reader antenna to communicate with the ISO14443A/MIFARE card and transponder without the need for additional circuits. The receiver section provides robust and efficient demodulation and decoding circuit for processing ISO14443A compliant transponder signals. The digital part handles ISO14443A frames and error detection (parity &CRC).MFRC522 supports MIFARE higher speed contactless communication, with a two-way data transmission rate up to 424kbit/s.
High integration modulation and demodulation circuit;
Support ISO/IEC 14443 TypeA and MIFARE Communication protocol;
The communication distance with ISO 14443A/MIFARE in reader mode is up to 50mm, depending on the length of the antenna.
Supports higher transmission rates of ISO 14443 212kbit/s and 424kbit/s.
SPI interface for 10Mbit/s
64 byte send and receive FIFO buffer;
Built-in temperature sensor to automatically stop RF emission when chip temperature is too high;
Adopt an independent multi-group power supply to avoid interference between modules and improve work stability.
CRC and parity check function.
Internal oscillator connected to 27.12mhz crystal;
2.5-3.3v low voltage and low power consumption design;
Operating temperature range: -30 ~ +85℃;
Super small size 5mm×5mm×0.85mm.
MFRC522 is suitable for a variety of applications based on ISO/IEC 14443A and requiring low cost, small size, high performance, and single power contactless communication.
- Public transport terminal
- Portable handheld device
- Contactless public telephone
- Door lock
Step 3: STONE STVC050WT-01 LCD-TFT Display Module
In this project, I intend to use the STONE STVC050WT-01 display screen to display the card data read by MFRC522.
The driver chip has been integrated inside the display screen, and there is development software that can be used by users. Users only need to add buttons and text boxes to the designed UI pictures through the pc, and then generate configuration files and download them into the displayer module. The STVC050WT-01 communicates with the MCU via a UART-TTL signal.
The official website has detailed information and introduction：https://www.stoneitech.com/
If you need video tutorials, you can also find them on the official website.
Three steps of STONE display screen development: l Design the display logic and button logic with STONE TOOL software and download the design file to the display module. l MCU communicates with the STONE LCD display module through the serial port. l With the data obtained in step 2, the MCU does other actions.
Step 4: STONE TOOL
Download the latest version of the STONE TOOL software (currently TOOL2019) from the website, and install it.
After the software is installed, the following interface will be opened:
Click the "File" button in the upper left corner to create a new project, which we will discuss later.
Step 5: Arduino
Developers do not need to care about the tedious details of single-chip programming, providing you with an easy-to-use kit. Arduino also simplifies the work process of microcontroller, but compared with other systems, Arduino is more advantageous in many places, especially suitable for teachers, students, and amateurs:
1. Cheap -- Arduino boards are really cheap compared to other platforms. The cheapest version of Arduino can be made with your own hands, and even an assembled product costs no more than 200 yuan.
2. Simple programming environment -- Arduino programming environment is easy for beginners to learn to use, and it can provide enough advanced applications for advanced users.
3. Software is open source and extensible - Arduino software is open source and can be extended by experienced programmers. The Arduino programming language can be extended through the C++ library.
4. Open source and extensible hardware -- Arduino board is based on ATMEGA8 and atmega168/328 microcontroller of Atmel.
Arduino is based on the Creative Commons license, so experienced circuit designers can design their own modules to extend or improve on the requirements. Even for some relatively inexperienced users, you can make test boards understand how Arduino works, which saves money and time.
Arduino, based on the AVR platform, compiles and encapsulates AVR libraries twice. Ports are packaged, and registers, address Pointers, and other things are not needed. Greatly reduce the difficulty of software development, suitable for non-professional enthusiasts to use.
Step 6: The Development Environment
Arduino IDE is very easy for beginners to learn and has plenty of flexibility. Arduino language is developed based on wiring language, which is the second packaging of the Avr-GCC library. It does not need too much foundation of SCM or programming, so you can develop it quickly after simple learning.
The Arduino development environment is the Arduino IDE, which can be downloaded from the Internet. After installing the Arduino IDE, the following interface will appear when you open the software:
The Arduino IDE creates two functions by default: the setup function and the loop function.
There are a lot of Arduino introductions on the Internet. If you don't understand, you can go to the Internet to look up materials.
Step 7: Hardware Connection
To ensure that the next step in writing code goes smoothly, we must first determine the reliability of the hardware connection.
Only three pieces of hardware were used in this project:
1. Arduino UNO development board
2. STONE STVC050WT-01 TFT-LCD displayer
3. MFRC522 module
Arduino UNO development board and STVC050WT TFT-LCD display screen are connected through UART, and Arduino UNO development board is connected with MFRC522 module through SPI interface. After thinking clearly, we can draw the following wiring picture(as shown in the 1st picture).
The specific pin connection is as shown in the 2nd picture.
Make sure there are no errors in the hardware connection and proceed to the next step(as shown in the 3rd picture).
Step 8: TFT LCD User Interface Design
First of all, we need to design a picture, which can be designed by PhotoShop or other image design tools. After designing the picture, save the picture in JPG format.
Open the software STONE TOOL2019 and create a new project (as shown in the 1st picture)
Remove the image (as shown in the 2nd picture)
that was loaded by default in the new project, and add the UI image that we designed.
Add the text display component, design the display digit and decimal point, get the storage location of the text display component in the display screen. The effect is as shown in the 3rd picture.
Step 9: Generate Configuration File
Once the UI design is complete, the configuration file can be generated and downloaded to the STVC050WT-01 display, which is described in STONE's development materials.
First, perform step 1, then insert the USB flash drive into the computer, and the disk symbol will be displayed. Then click "Download to u-disk" to Download the configuration file onto the USB flash drive, and then insert the USB flash drive into STVC050WT-01 to complete the upgrade. (as shown in the 1st picture)
We don't need to program the MFRC522 module. We just need to make sure that the hardware is connected reliably.
Open the Arduino IDE and find the following buttons(as shown in the 2nd picture)
Search "RC522" to find the RC522 library file, then click download and install.
You can also download it directly from the Internet: https://github.com/miguelbalboa/rfid
After the installation, you can find the Demo of MFRC522 in the LIB library folder of Arduino(as shown in the 3rd picture)
Double-click the file to open it. (as shown in the 4th picture)
This Demo can be directly tested. After compiling and downloading the code into the Arduino development board, the data of MFRC522 can be seen in the serial debugging tool if there are not any problems with the hardware connection.
Open the Arduino serial listener, and you can see the following output: (as shown in the 5th picture)
I have to say that the modular programming of Arduino is very convenient, and I don't even need to understand how the driver code of Uart and SPI is implemented.
Step 10: Display Data to the STONE Displayer Through Arduino
Compile the code, download it to the Arduino development board, and you're ready to start testing.
Place the M1 card on the MFRC522 collector to see the MI card number. The effect can be seen in the following picture.