Integration with RC522

Has anyone managed to get one of these RC522 RFID readers working?

I can see information for it on esphome.io but cannot see a pinout for wiring and cannot get it communicating.

Thanks

It’s SPI - the pins are clearly labelled. Follow the i2c SPI example on the ESPHome site.

1 Like

But my board is slightly different to the one pictured.

You might want to share want the differences are…

Maybe you received a SPI version? How knows?

Yeah - well the original picture is actual SPI (my bad- was on my phone browsing) so you maybe have I2C anyhow. Post a photo of it showing pin labels.

Also note some manufacturers are renaming MOSI and MISO to SDO and SDI, and SS to CS so that causes some confusion.

1 Like

I’m not sure familiar with SPI, but in most of the wiring diagrams I can fine, which are also Arduino btw, they are wiring all the pins,

as I understand it, SDA normally only needs 2.

This is why im confused. Also, I see a SDA, but no SCL. Goes straight to SCK.

Pick suitable pins for the GPIO - these will work on an ESP32.

spi:
  clk_pin: GPIO14 # SCK on this board
  mosi_pin: GPIO13 # MOSI (misspelt MOIS)
  miso_pin: GPIO12 # MISO

rc522_spi:
  cs_pin: GPIO15 # SDA on this board I reckon (no idea why -- I suspect they just change a jumper for I2C board)
  reset_pin: GPIO16 # RST

Don’t define a binary sensor - scanning a tag should print it’s data in the log.

Plus of course power and GND.

1 Like

Im using ESP8266, D1 Mini

Same pins will work on D1 Mini except GPIO16 (D0), use GPIO5 (D1).

Ok, heres what i’ve got.

   ESP        |   RC522

D8 (GPIO15) | SDA
D7 (GPIO13) | MOSI
D6 (GPIO12) | MISO
D5 (GPIO14) | SCK

Oh damn, connected the RST pin and now its working :slight_smile:

[23:18:32][W][rc522:398]: Communication with the MFRC522 might be down, reset in -1
[23:18:32][I][rc522_spi:013]: SPI Setup
[23:18:32][D][spi_device:355]: mode 0, data_rate 4000kHz
[23:18:32][E][spi:021]: SPI device already registered
[23:18:32][I][rc522:295]: Soft reset...
[23:18:32][I][rc522:303]: Device online.
[23:18:38][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:18:42][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:18:44][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:18:46][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:18:49][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:18:53][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:18:56][D][rc522:263]: Found new tag '2F-A6-DE-02'
[23:19:37][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:19:41][D][rc522:263]: Found new tag '60-63-EA-1E'
[23:19:43][D][rc522:263]: Found new tag '60-63-EA-1E'
2 Likes

Thank you so much,

You are always very helpful!

Thanks for the info, got mine working following your post. Quick question, how do you list multiple tags?

Binary_sensor:
  - platform: rc522
  #  uid: 5A-64-90-1A,
    uid: F7-6C-0D-B3 # Add tag?
    name: "RC522 RFID Tag"

How do you get it working?

My wiring is:

esp rc522
D8 (GPIO15) SDA
D7 (GPIO13) MOSI
D6 (GPIO12) MISO
D5 (GPIO14) SCK
D0 (GPIO16) RST
GND GND
3V3 3.3v

My Config:

substitutions:
  name: rfid-reader-01
  friendly_name: RFID Reader 01
packages:
  esphome.bluetooth-proxy: github://esphome/firmware/bluetooth-proxy/esp32-generic.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
api:
  encryption:
    key: xxxxxxxxxxxxxxxx
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

spi:
  clk_pin: GPIO14
  mosi_pin: GPIO13
  miso_pin: GPIO12

rc522_spi:
  cs_pin: GPIO15
  reset_pin: GPIO16

My log:

[00:09:28][I][rc522_spi:013]: SPI Setup
[00:09:28][D][spi_device:379]: mode 0, data_rate 4000kHz
[00:09:28][E][spi:021]: SPI device already registered
[00:09:29][W][rc522:399]: Communication with the MFRC522 might be down, reset in 10
[00:09:30][W][rc522:399]: Communication with the MFRC522 might be down, reset in 9
[00:09:31][W][rc522:399]: Communication with the MFRC522 might be down, reset in 8
[00:09:32][W][rc522:399]: Communication with the MFRC522 might be down, reset in 7
[00:09:33][W][rc522:399]: Communication with the MFRC522 might be down, reset in 6
[00:09:34][W][rc522:399]: Communication with the MFRC522 might be down, reset in 5
[00:09:35][W][rc522:399]: Communication with the MFRC522 might be down, reset in 4
[00:09:36][W][rc522:399]: Communication with the MFRC522 might be down, reset in 3
[00:09:37][W][rc522:399]: Communication with the MFRC522 might be down, reset in 2
[00:09:38][W][rc522:399]: Communication with the MFRC522 might be down, reset in 1
[00:09:39][W][rc522:399]: Communication with the MFRC522 might be down, reset in 0

I dont think I got this working. I gave up on this.

It just went in the pile of shitty sensors with poor support. I will try something of a little more quality next time.

I solved my problem. There was an issue in my wiring, because my dev board is slightly different :frowning:

New wiring:

RFID-RC522 ESP32-DevKitC-32
SDA (SS) GPIO5
SCK GPIO18
MOSI GPIO23
MISO GPIO19
GND GND
RST GPIO21
3.3V 3.3V

Config changes:

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

rc522_spi:
  cs_pin: GPIO5
  reset_pin: GPIO21
1 Like