ESP32: RFID RC522 i2c

Out there there are tons of "tutorials" (almost copied/pasted) about how to use RC522 connected to an ESP32. One among the others: https://esp32io.com/tutorials/esp32-rfid-nfc

Almost all of them says the RC522 has three communication channels: i2c, spi and uart.
But when they come down to the examples, I always see the spi used.

In my custom board I would like to use the i2c, but I'm unable to find a library that support this communication protocol.

I found:

not maintained anymore (2019) and does not support neither uart nor i2c

not updated since several years and still does not support uart/i2c

same

and several other forks, but all of them reports in the README the uart and i2c is not supported.
Is there a chance to find a library that supports i2c? Otherwise I have to write my own, but I'm not so expert like them.

There are 2 reasons:

  • SPI is faster
  • Boards layout doesn't have a jumper to select the communication type.

So, on many (or all?) boards, you have to cut a trace on it.

Here a I2C tutorial:

The link you provided does not work for me. It lands on an advertising page.
Not sure about the jumper issue: on (all) board I've seen there are already all the pins available. You should just connect to the ESP32 board the required pins, if I'm not wrong.

By the way, I'm reading the datasheet and I didn't find anything about this. In detail it says:

The MFRC522 identifies the host interface by sensing the logic levels on the control pins after the reset phase. This is done using a combination of fixed pin connections

Use an ad-blocker :wink: It is a nice tutorial to understand how to connect and use it with I2C.
This image:


shows it to you. SDA can be UART, I2S or SPI. But not all 3 at the same moment. You define what you want with a pullup on the IC itself. You need the datasheet of the board, not from the IC if you want change it and know how to change it.

Edit:
asking Bing:

1 Like

Sorry, I didn't explained well. I'm using an ad blocker, but the address itself does not work. It's redirected to multiple pages, not safe (advertising, xxx, etc...)

Of course I can't use all the three channel at the same moment. But connecting the right pins to the host should be enough to selecting the correct protocol, without the need to cut traces.

Thanks for the library. I'll give it a try!
By the way, looking at the ds it seems the three protocols are quite similar about the payload. Hence, if the libraries above are good written, I should be able to easily change only the lower level functions (send / receive).

Link worked for me. As to the 'drill a hole in the board", I'd love to see a schematic that justifies it, but there's probably nothing available.

Actually, I think @Adrianotiger is right, check this out. The schematic shows the config pins are hard-tied, so no way to change the protocol.

What made me out of the track is the silkscreen on the connector that reports also the SDA pin. It makes no sense since it's not possible to use the i2c!

Well, I'd submit that someone should discipline that designer. A couple of jumper pads, and all three implementations could be used. I'm particularly interested in the I2C arrangement, but I'd also explore the UART option.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.