How to connect ESP8266 and RFID-RC522 using Javascript?


I have RFID-RC522 and I want to use it together with my ESP8266. I had some ideas, like reading a GPIO pin, but api_gpio.js only reads 0 or 1, but I need more information. How can I get information from a GPIO pin so that when RC522 reads a card, I can check if it’s valid or not, or is there a better way to do it (like a library)?
I connected everything and I use SPI api. When I look at output, all I see are “\x00\x00…” and when I put a card near RD522, the output doesn’t change. How to check if my SPI connection is good?


Currently there is no Mongoose OS library available to handle the MFRC522/RC522.

Data sheet

But there is SPI API, so surely you can communicate with RC522 with that? This is my setup:
3.3V -> 3V
IRQ -> not connected
MISO -> MISO (12)
MOSI -> MOSI (13)
SCK -> 15
SDA -> 16

I use Feather HUZZAH ESP8266.

This is my code for parameter:

let param = {
cs: 0,
mode: 0,
freq: 2000000,
hd: {
rx_len: 100,

Output is still 0’s.

Yes. The communication with the module is SPI.

In order to read the ID of a card, you need to initialize the module, send commands, read data, etc…
It will not output the ID “automagically” :slight_smile:



  • [“spi.enable”, true]
  • [“spi.miso_gpio”, 12]
  • [“spi.mosi_gpio”, 13]
  • [“spi.sclk_gpio”, 15]
  • [“spi.cs0_gpio”, 16]


let spi = SPI.get();
let param = {
cs: 0,
mode: 0,
freq: 2000000,
hd: {
rx_len: 100,
let someOutput = SPI.runTransaction(spi, param);

To my understanding I initalized module with SPI.get() (right?), I send command by putting my card in front of RC522 I read data using runTransaction. I looked at the output and it’s 0. Did I misunderstood you?

Yes, you did misunderstand.

Initialize - send commands to initialize/setup the module.
Send commands - send commands to tell the module what to do.
Read data - read the response

Read the manual I’ve linked earlier.