3.8 RFID Sensor

3.8.1 Overview

RFID-RC522 module adopts Phillips MFRC522 original chip in card reading circuit, which is easy to use and with low cost. It is suitable for equipment and reader development, advanced applications, RF card terminal design and producing.

3.8.2 Schematic Diagram

6-8-2

RFID (Radio Frequency Identification):

The card reader is composed of a frequency transmitter module and a high level magnetic field. The Tag transponder is a device to be sensed without a battery. It consists only of tiny integrated circuit chips, media for storing data, and antennas for receiving and transmitting signals. To read the data in the tag, it must be placed within the reading range of the reader. After that, the reader will generate a magnetic field. According to Lenz’s law (magnetic energy generates electricity), the RFID Tag will be powered, thus activating the device.

NOTE: this module only recognize card working at 13.56MHz. It is recommended to use the provided card in the kit.

3.8.3 Code Blocks

  1. j27

    This block initializes RFID module. Without it, its data cannot be read.

  2. 28

    This block reads the card value of the RFID sensor.

  3. image-20240701104605293

    This is a comparison block that determines whether the value of two parts equals each other. When they are equal, it outputs 1, or else it outputs 0.

  4. image-20240701104539284

    This is a logical block to reverse the value. That means this block outputs 0 when the condition block outputs 1, and it outputs 1 when the condition outputs 0. It reverses outputs.

  5. image-20240701104509861

    This is a conversion block that converts values into one of types of integer, decimal or string.

image-20240701105332920

3.8.4 Test Code

3.8.4.1 Build Code

There are two ways to upload the code: directly open the code file we provide; or manually build blocks.

Directly open the code file we provide:

  1. Click and choose Load from your computer

  1. We have already downloaded the codes on computer desktop, so open the file and choose 3-8-rfid.sb3

Manually build blocks:

  1. In events, find j1 block.

  2. In rfid, find and put j27 under j1

  3. In serial, find j12 and set baud rate to 9600

  4. In control, put j7 under 6-4-4-1-1, and set variable Type to string

  5. In control, put j2 below the block

image-20240701131338008

  1. In control, place j9 in j2

  2. In rfid, put j21 in the right box of block j9

  3. In control, add a j25 under image-20240701131625149

  4. In operator, put j22 into the condition box of j25

  5. In operator, put j22 into the condition box of j25

image-20240701131910235

  1. In control, put j9 into the left part of j22

  2. In image-20240701132101678, put j9 into the right part of j22 and modify the conversion value to “0” and conversion type to “string”.

image-20240701132257387

  1. In serial, find j13 and put it into image-20240701132431720, and modify the printing content into “RFID:” and set printing mode to no-warp.

  2. Drag another j13, and then add a variable block j9 into the printing content box.

As follows:

image-20240701132734670

Complete Test Code

image-20240701132810067

3.8.4.2 Test Result

After uploading code, cover the RFID sensing area with the IC card or the key in the kit, and you will see the serial monitor prints the ID numbers.

image-20240701133030371