Advice 1: How to connect RFID reader RC522 to Arduino

In this article we will consider the connection of the card reader and keyfobs RFID RC522 working frequency of 13.56 MHz.
RC522 RFID reader with a map and thumb
You will need
  • - Arduino;
  • - RC522 RFID reader;
  • wireless RFID label or regular metro ticket/land transport;
  • computer;
  • - connecting wires.
Instruction
1
Module RFID RC522 is executed on the chip MFRC522 NXP company. This chip provides two-way wireless (up to 6 cm) communication at 13.56 MHz. RFID is an abbreviation for "Radio Frequency IDentification" and is translated as "radio frequency identification".
Chip MFRC522 supports the following interfaces:
- SPI (Serial Peripheral Interface, a serial interface for connection of peripheral devices), provides data transfer speeds up to 10 Mbps;
- two-wire I2C interface, speed up to 3400 kbit / s in High-speed mode, up to 400 kbit / s in Fast mode;
- serial UART (similar to RS232), the speed 1228,8 kbit / s.
With this module you can record and read different RFID tags: keyfobs for intercoms, plastic cards and metro tickets and ground transportation, as well as the increasingly popular NFC tags.
The wireless module RFID RC522
2
Connect the module RFID RC522 to Arduino via SPI interface according to the above scheme.
The module power supply is provided with voltage from 2.5 to 3.3 V. the Rest of the findings connected to Arduino like this:
RST - D9;
SDA (SS) - D10;
MOSI - D11;
MISO - D12;
SCK - D13.
Don't forget that Arduino has a special connector ICSP to work on the SPI interface. Its Pinout is also shown in the illustration. You can connect the insights RST, SCK, MISO, MOSI and GND of the module RC522 to the ICSP connector on Arduino.
Wiring diagram for RFID-RC522 SPI
3
Chip MFRC522 has quite extensive functionality. To get acquainted with all the possibilities by examining her passport (datasheet). We are to explore the possibilities of this device will use one of ready libraries written for Arduino work with the RC522. At the end of the article you can find a link to one of the libraries, which is called rfid. Download it and unzip in the directory %IDE Arduino%/libraries/.
Installing the library "rfid master" to work with RFID tags
4
Now let's open the sketch from the examples: File -> Samples -> MFRC522 -> DumpInfo and upload it to the Arduino memory. This sketch defines the type applied to the device reader and reads data recorded on RFID tag or card, and then outputs them to the serial port. The text of the sketch fairly well commented by the developers of the library, "rfid", as well as lots of useful information on working with the library contained in the file MFRC522.h.
The sketch for reading the information recorded on the RFID-tag
5
Start monitor serial port key combination Ctrl+Shift+M, using the menu Tools or by clicking on the magnifying glass. Now attach to the reader metro ticket or any other RFID tag. Monitor serial port will show the data recorded on the RFID tag or ticket. For example, in my case is an encrypted, unique ticket number, purchase date, expiration date, number of remaining trips, and service information. We will examine in a future article, what is recorded on maps of the metro and surface transport.
Read data from a ticket for ground transport and the metro
Note
Yes, using the module of the RFID-RC522 to write the data on the ticket of the metro. But make no mistake, each card has a read-only counter of write cycles, so that the "add" travel to myself on the subway will not work - it will be immediately detected and the card will be rejected But the use of metro tickets to record them on small amounts of data - 1 to 4 - KB. And applications that are limited only by your imagination.

Advice 2: I2C interface and Arduino

In this article we will look at what I2C interface (AI-Tu-si, and two TSE), what are its characteristics and how to work with it.
I2c interface
You will need
  • - Arduino;
  • digital potentiometer AD5171;
  • led;
  • - resistor 220 Ohm,
  • - 2 resistor 4.7 kOhm;
  • - connecting wires.
Instruction
1
Serial communication Protocol IIC (also called I2C - Inter-Integrated Circuits, minicasino connection) used to transfer data for two bidirectional communication lines, which are called the serial data SDA (Serial Data) and the bus clock SCL (Serial Clock). There are also two lines for food. Bus SDA and SCL are pulled to the power bus through the resistors.
The network has at least one master device (Master) which initialisere data transfer and generates the synchronization signals. The network also has a slave device (Slave) that transmit data upon request of the presenter. Each slave has a unique address, which is a leading and turns to him. The device address specified in the passport (datasheet). To the same I2C bus can connect up to 127 devices, including several leading. The bus devices can be connected in the process, i.e. it supports "hot plugging".
Connection diagram for I2C interface
2
The Arduino uses the I2C interface two ports. For example, the Arduino UNO and Arduino Nano analog port A4 corresponds to SDA, analog port A5 corresponds to SCL.
For other models:
Arduino Pro and Pro Mini to A4 (SDA), A5 (SCL)
The Arduino Mega is 20 (SDA), 21 (SCL)
Arduino Leonardo - 2 (SDA), 3 (SCL)
Arduino Due - 20 (SDA), 21 (SCL), SDA1, SCL1
Compliance findings tyres Arduino SDA and SCL
3
To facilitate data exchange with devices on the I2C bus for Arduino is written standard library "Wire". It has the following functions:
begin(address) - initialize the library and connect to the I2C bus; if the address is not specified, the attached device is considered a leading; use 7-bit addressing;
requestFrom() - used by the master to request a certain number of bytes from the slave;
beginTransmission(address) - start data transfer to the slave at a particular address;
endTransmission() - end of the slave transmission;
write() - write data from the slave in response to the request;
available() - returns the number of bytes of information available for the reception from a slave;
read() - read bytes transferred from the host or the slave from the master to the slave;
onReceive() - specifies a function that should be called when the slave receives a transmission from the master;
onRequest() - specifies a function that should be called when the host device receives the transmission from the slave.
4
Let's see how to work with the I2C bus with Arduino.
First assemble the circuit as shown. Will control the brightness of the led using digital 64-position potentiometer AD5171, which is connected to the I2C bus. The address to which we will refer to the potentiometer - 0x2c (44 decimal).
Control scheme for the led using a digital potentiometer and an Arduino
5
Now open the examples library "Wire" sketch:
File -> examples -> Wire -> digital_potentiometer. Upload it into the Arduino memory. Turn on.
You see, the brightness of the led cycles increases, and then abruptly turns off. In this case we control the potentiometer with the Arduino using the I2C bus.
Sketch control a digital potentiometer via I2C bus
Search
Is the advice useful?