<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Issues interfacing MFRC522 (RFID) with M5Stack]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">I'm trying to run the example RFID M5Stack code on a standalone MFRC522 unit (from eBay) but having quite few issues getting the code to work.</p>
<p dir="auto">I can download the sample code to the stack and it displays 'M5StackFire MFRC522' on the display but does not read any RFID tags. I first connected the pins:</p>
<p dir="auto">SDA &gt; SDA<br />
SCK &gt; SCK<br />
MOSI &gt; MO<br />
MISO &gt; MI<br />
GND &gt; G<br />
RST &gt; RST (but on another bus, not sure I can do this)<br />
3.3V &gt; 3V3</p>
<p dir="auto">The tag was not recognised however. It seems the code never executes past mfrc522.PCD_Init(); (Although I'm really not sure where it gets stuck to be honest)</p>
<p dir="auto">Using the I2C scanner, a device was registered at address 0x10.</p>
<p dir="auto">I then realised as the code was using the I2C protocol I only needed to use the lines associated with I2C so wired up the following from the unit to the stack:</p>
<p dir="auto">SDA, MISO (SCL) , GND, RST and 3.3v</p>
<p dir="auto">Now the I2C scanner showed no devices attached at all.</p>
<p dir="auto">Any thoughts on what I may be doing wrong?</p>
<p dir="auto">Here's a picture of how I've wired it up:</p>
<p dir="auto"><img src="/assets/uploads/files/1586626938678-img_20200407_135221-resized.jpg" alt="0_1586626896779_IMG_20200407_135221.jpg" class=" img-fluid img-markdown" /></p>
<pre><code class="language-#include">#include "MFRC522_I2C.h"
#include &lt;M5Stack.h&gt;

// 0x28 is i2c address on SDA. Check your address with i2cscanner if not match.
MFRC522 mfrc522(0x10);   // Create MFRC522 instance.

void setup() {
  M5.begin();
  M5.Power.begin();
  M5.Lcd.fillScreen( BLACK );
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.setTextColor(YELLOW);  
  M5.Lcd.setTextSize(2);

  M5.Lcd.fillScreen( BLACK );
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.println("M5StackFire MFRC522");
  Serial.begin(115200);           // Initialize serial communications with the PC
  Wire.begin();                   // Initialize I2C
  
  mfrc522.PCD_Init();             // Init MFRC522
  ShowReaderDetails();            // Show details of PCD - MFRC522 Card Reader details
  Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
  M5.Lcd.println("Scan PICC to see UID, type, and data blocks...");
}

void loop() {
  // Look for new cards, and select one if present
  if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
    delay(50);
    return;
  }
  
  // Now a card is selected. The UID and SAK is in mfrc522.uid.
  
  // Dump UID
  Serial.print(F("Card UID:"));
  M5.Lcd.println(" ");
  for (byte i = 0; i &lt; mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] &lt; 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    M5.Lcd.print(mfrc522.uid.uidByte[i] &lt; 0x10 ? " 0" : " ");
    M5.Lcd.print(mfrc522.uid.uidByte[i], HEX);
  } 
  Serial.println();
  
}

void ShowReaderDetails() {
  // Get the MFRC522 software version
  byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
  Serial.print(F("MFRC522 Software Version: 0x"));
  Serial.print(v, HEX);
  if (v == 0x91)
    Serial.print(F(" = v1.0"));
  else if (v == 0x92)
    Serial.print(F(" = v2.0"));
  else
    Serial.print(F(" (unknown)"));
  Serial.println("");
  // When 0x00 or 0xFF is returned, communication probably failed
  if ((v == 0x00) || (v == 0xFF)) {
    Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
  }
}
</code></pre>
]]></description><link>https://community.m5stack.com/topic/1840/issues-interfacing-mfrc522-rfid-with-m5stack</link><generator>RSS for Node</generator><lastBuildDate>Fri, 08 May 2026 06:46:23 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/1840.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 11 Apr 2020 17:48:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Issues interfacing MFRC522 (RFID) with M5Stack on Tue, 14 Apr 2020 21:28:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/volatus" aria-label="Profile: volatus">@<bdi>volatus</bdi></a></p>
<p dir="auto">I2C # SPI<br />
You forgot to use #include &lt;SPI.h&gt; in your arduino code. So the code compiled for I2C interface.</p>
<p dir="auto">Beware using the wrong pins for external SPI deviceon your M5Stack. You may brick  your display. Interfacing to an external  a SPI peripheral device you should use pins which are not in conflict with the pins used for M5Stack internals, as I already wrote in my comments on SPI Interfacing a few days ago:<br />
<a href="http://community.m5stack.com/topic/1845/micropython-spi/8" target="_blank" rel="noopener noreferrer nofollow ugc">http://community.m5stack.com/topic/1845/micropython-spi/8</a><br />
You should keep it as they are saying on my spec sheet for the Heltec ESP32 LoRa board: "Pins used by on board OLED or LoRA must not be used for other purpose unless you know what you are doing !<br />
Accordingly, on the M5Stack you should only use the pins marked in blue.</p>
]]></description><link>https://community.m5stack.com/post/8158</link><guid isPermaLink="true">https://community.m5stack.com/post/8158</guid><dc:creator><![CDATA[crami25]]></dc:creator><pubDate>Tue, 14 Apr 2020 21:28:01 GMT</pubDate></item><item><title><![CDATA[Reply to Issues interfacing MFRC522 (RFID) with M5Stack on Tue, 14 Apr 2020 16:29:13 GMT]]></title><description><![CDATA[<p dir="auto">Hi Crami,</p>
<p dir="auto">Many thanks for your response. Unfortunately I don't have a drill so I can't enforce I2C mode. I've tried to change the code to use SPI instead. Now I can't get it to write at all and receive the following errors:</p>
<pre><code class="language-#include">#include "MFRC522.h"
#include &lt;M5Stack.h&gt;

// 0x28 is i2c address on SDA. Check your address with i2cscanner if not match.
MFRC522 mfrc522(0x15, 0x02);   // Create MFRC522 instance.

void setup() {
  M5.begin();
  M5.Power.begin();
  M5.Lcd.fillScreen( BLACK );
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.setTextColor(YELLOW);  
  M5.Lcd.setTextSize(2);

  M5.Lcd.fillScreen( BLACK );
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.println("M5StackFire MFRC522");
  Serial.begin(115200);           // Initialize serial communications with the PC
  SPI.begin();                   // Initialize I2C
  
  mfrc522.PCD_Init();             // Init MFRC522
  ShowReaderDetails();            // Show details of PCD - MFRC522 Card Reader details
  Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
  M5.Lcd.println("Scan PICC to see UID, type, and data blocks...");
}

void loop() {
  // Look for new cards, and select one if present
  if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
    delay(50);
    return;
  }
  
  // Now a card is selected. The UID and SAK is in mfrc522.uid.
  
  // Dump UID
  Serial.print(F("Card UID:"));
  M5.Lcd.println(" ");
  for (byte i = 0; i &lt; mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] &lt; 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    M5.Lcd.print(mfrc522.uid.uidByte[i] &lt; 0x10 ? " 0" : " ");
    M5.Lcd.print(mfrc522.uid.uidByte[i], HEX);
  } 
  Serial.println();
  
}

void ShowReaderDetails() {
  // Get the MFRC522 software version
  byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
  Serial.print(F("MFRC522 Software Version: 0x"));
  Serial.print(v, HEX);
  if (v == 0x91)
    Serial.print(F(" = v1.0"));
  else if (v == 0x92)
    Serial.print(F(" = v2.0"));
  else
    Serial.print(F(" (unknown)"));
  Serial.println("");
  // When 0x00 or 0xFF is returned, communication probably failed
  if ((v == 0x00) || (v == 0xFF)) {
    Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
  }
}
</code></pre>
<p dir="auto">Errors:</p>
<p dir="auto">Arduino: 1.8.12, Board: "M5Stack-Core-ESP32, QIO, 80MHz, Default, 921600, None"</p>
<p dir="auto">Sketch uses 356605 bytes (27%) of program storage space. Maximum is 1310720 bytes.<br />
Global variables use 17628 bytes (5%) of dynamic memory, leaving 310052 bytes for local variables. Maximum is 327680 bytes.<br />
<a href="http://esptool.py" target="_blank" rel="noopener noreferrer nofollow ugc">esptool.py</a> v2.6<br />
Serial port COM3<br />
Connecting....<br />
Chip is ESP32D0WDQ6 (revision 1)<br />
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None<br />
Uploading stub...<br />
Running stub...<br />
Stub running...<br />
Changing baud rate to 921600<br />
Changed.<br />
Configuring flash size...<br />
Warning: Could not auto-detect Flash size (FlashID=0x0, SizeID=0x0), defaulting to 4MB<br />
Compressed 8192 bytes to 47...</p>
<p dir="auto">Writing at 0x0000e000... (100 %)<br />
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 6553.6 kbit/s)...</p>
<p dir="auto">A fatal error occurred: Timed out waiting for packet header<br />
A fatal error occurred: Timed out waiting for packet header</p>
<p dir="auto">Can you spot anything I may be doing wrong?</p>
]]></description><link>https://community.m5stack.com/post/8155</link><guid isPermaLink="true">https://community.m5stack.com/post/8155</guid><dc:creator><![CDATA[volatus]]></dc:creator><pubDate>Tue, 14 Apr 2020 16:29:13 GMT</pubDate></item><item><title><![CDATA[Reply to Issues interfacing MFRC522 (RFID) with M5Stack on Sun, 12 Apr 2020 14:57:10 GMT]]></title><description><![CDATA[<p dir="auto">It appears, that you can't address your RFID reader over I2C. Ordering a MFRC522 from an eBay source you never know what you get. The safest way of an external sensor to communicate with an M5Stack is communicating by I2C.  With I2C the master can communicate with up to 127 different slaves.</p>
<p dir="auto">The SPI serial communication is between one master and a single slave. So, in addition to the communication lines (MOSI, MOSI, SCK)  you will need a CS line selecting the slave (only one at a time !!!  ) and  also a RST and maybe an IRQ line !  ESP32 devices comming from different manufacturers often have hooked up their own SPI peripherals controlled by their dedicated firmware. That's why programming in arduino you must carefully select which board you are using (M5Stack, M5Stick, HeltecLoRa, WemosOLED ...) otherwise it's a big chance to brick the LCD display of the M5Stack and maybe the ESP32 itself. I'm just experimenting with my TTGO WiFi LoRa 32. On the Pinout Diagram they are noting: "Pins with the red arrow are used by the on-board OLED or LoRa, they must not be used for any other purpose unless you konw what you are doing!".</p>
<p dir="auto">I'vd hooked up my M5Stack RFID unit to my M5Stack, read the ID of RFID devices and stored and retreived data (without noise from the speaker) in UIFlow.</p>
<p dir="auto">If you want to use your eBay RFID the best thing would be to convert it to an I2C device (address 0x3c) as descibed in</p>
<p dir="auto"><a href="https://www.teachmemicro.com/arduino-rfid-rc522-tutorial/" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.teachmemicro.com/arduino-rfid-rc522-tutorial/</a></p>
<p dir="auto">Here is a picture how they have done it:<br />
<img src="/assets/uploads/files/1586702796098-8256a229-2769-4dcc-b113-be87caf95cbc-image.png" alt="0_1586702670858_8256a229-2769-4dcc-b113-be87caf95cbc-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/8128</link><guid isPermaLink="true">https://community.m5stack.com/post/8128</guid><dc:creator><![CDATA[crami25]]></dc:creator><pubDate>Sun, 12 Apr 2020 14:57:10 GMT</pubDate></item><item><title><![CDATA[Reply to Issues interfacing MFRC522 (RFID) with M5Stack on Sun, 12 Apr 2020 13:50:06 GMT]]></title><description><![CDATA[<p dir="auto">Hi Crami,</p>
<p dir="auto">Thanks so much for the reply. I've tried to wire up the unit as you described. Unfortunately I cannot make use of the groove connector because the jumper wire connectors are  too large to all fit in the socket and I don't have any other wires.</p>
<p dir="auto">Instead I've wired:<br />
SDA -&gt; SDA,<br />
SCL -&gt; SCK (Instead of SCL/MISO),<br />
3V3 -&gt; 3.3V and G -&gt; GND.</p>
<p dir="auto">As for the code, it does #include &lt;wire.h&gt; (seems I cut if off the embed accidentally!)</p>
<p dir="auto">Unfortunately, still doesn't get past the println below:<br />
<img src="/assets/uploads/files/1586699369858-img_20200412_143959-resized.jpg" alt="0_1586699324434_IMG_20200412_143959.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">I should also mention there is a high pitched buzzing coming from the m5stack?</p>
<p dir="auto">Here's a the output from the serial plotter too:</p>
<p dir="auto"><img src="/assets/uploads/files/1586699395159-i2c.jpg" alt="0_1586699394421_i2c.JPG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/8125</link><guid isPermaLink="true">https://community.m5stack.com/post/8125</guid><dc:creator><![CDATA[volatus]]></dc:creator><pubDate>Sun, 12 Apr 2020 13:50:06 GMT</pubDate></item><item><title><![CDATA[Reply to Issues interfacing MFRC522 (RFID) with M5Stack on Sat, 11 Apr 2020 21:59:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/volatus" aria-label="Profile: volatus">@<bdi>volatus</bdi></a></p>
<p dir="auto">Your MFRC522 uses same chip as the M5Stack RFID unit.<br />
You did the right thing hooking it up to Vcc 3.3V (The M5Stack unit has a 3.3V voltage regulator build in):</p>
<p dir="auto">Try to hook it up only to I2C (SDA to SDA, SCL to SCK, GND to GND, 3.3V to 3.3V, +/- the red Grove A connector but with 3.3V  for Vcc instead of 5 V, otherwise you will probably brick the board). Then run the UIFlow/Blockly I2C scan and look if it responds to the 0x28 (decimal  40) address. If you are lucky and you can address the board on the wire I2C bus, you can either use UIFlow/Blockly or the M5Stack Arduino  code as described for their RFID unit.<br />
You forgot to "#include &lt;Wire.h&gt;" library in your Arduino code. The way you hooked up your board the ESP32 doesn't know how to address it (serial, SPI or I2C ?). The M5Stack library uses I2C for their RFID unit.</p>
]]></description><link>https://community.m5stack.com/post/8117</link><guid isPermaLink="true">https://community.m5stack.com/post/8117</guid><dc:creator><![CDATA[crami25]]></dc:creator><pubDate>Sat, 11 Apr 2020 21:59:36 GMT</pubDate></item></channel></rss>