RPi-MFRC522-nodejs
RPi-MFRC522 for nodejs
Read UIDs from your RFID cards with MFRC522 readers on Raspberry Pi. Works with multiple readers.
If you want to read more than the UID, change ./src/reader.cpp
according to https://github.com/CoolCyberBrain/RPi-MFRC522 and https://github.com/miguelbalboa/rfid (The Arduino rfid library)
Install
(Do the following on your Raspberry Pi)
Usage
const reader = require("rpi-mfrc522-nodejs");
const readerPins = [
[reader.RPI_V2_GPIO_P1_38, reader.RPI_V2_GPIO_P1_15],
[reader.RPI_V2_GPIO_P1_40, reader.RPI_V2_GPIO_P1_18],
];
reader.onRfidChange(readerPins, data => {
console.log(data);
});
Getting started
Connecting your MFRC522 to your Raspberry Pi
- Open https://pinout.xyz/pinout/spi in your browser as a reference.
- Connect the 3.3v pin on the MFRC522 to any 3.3v pin on the Raspberry Pi.
Connect the RST pin on the MFRC522 to any GPIO pin on the Raspberry Pi.
Connect the GND pin on the MFRC522 to any ground pin on the Raspberry Pi.
Leave the IRQ pin unconnected.
Connect the MISO pin on the MFRC522 to the MISO pin (19) on the Raspberry Pi.
Connect the MOSI pin on the MFRC522 to the MOSI pin (21) on the Raspberry Pi.
Connect the SCK pin on the MFRC522 to the SCLK pin (23) on the Raspberry Pi.
Connect the SDA pin on the MFRC522 to any GPIO pin on the Raspberry Pi.
(GPIO pins are just pins that are not ground or power)
Try the example
(make sure nodejs is installed)
- Download this repo by running
git clone https://github.com/CoolCyberBrain/RPi-MFRC522-nodejs.git
- Enter the folder by running
cd RPi-MFRC522-nodejs
npm install
- Run the example by running the following command (if you don't run in sudo the program will crash, need sudo to access the GPIO pins)
sudo node example.js