# node-rfid

> A node module to interface rc522 rfid reader with raspberry pi via node js!!!

Latest version **1.0.7** (published 2018-02-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install node-rfid
pnpm add node-rfid
yarn add node-rfid
bun add node-rfid
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-02-27 |
| First published | 2018-02-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 53.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | Electrocoders |
| Maintainers | beeplove1, electro_coders |
| Keywords | rfid, node-rfid, rfid-reader, rfid-node, rc522-reader, rc522 |

## Links

- npm: https://www.npmjs.com/package/node-rfid
- Repository: https://github.com/BeepLoveKarki/node-rfid
- Homepage: https://github.com/BeepLoveKarki/node-rfid#readme
- Issues: https://github.com/BeepLoveKarki/node-rfid/issues
- npm.io page: https://npm.io/package/node-rfid

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2018-02-27
- 1.0.6 — 2018-02-27
- 1.0.5 — 2018-02-27
- 1.0.4 — 2018-02-27
- 1.0.3 — 2018-02-27
- 1.0.2 — 2018-02-27
- 1.0.1 — 2018-02-27
- 1.0.0 — 2018-02-27

## README

# node-rfid


This module supports both Raspberry Pi (RPi) and BeagleBone Black development boards. 

It requires your RPi (or BeagleBone Black) <b>SPI interface</b> to be enabled for being used. For that:<br/>

a) Go the terminal and type:

  ```
   sudo raspi-config
  ```
b) This will open your raspi-config interface. Choose <b>Advanced Options</b> if no <b>Interfacing Options</b> is found else choose <b>Interfacing Options</b>. 

&nbsp;&nbsp;&nbsp; <img src="https://www.raspberrypi-spy.co.uk/wp-content/uploads/2014/08/rc_cmd_main_interfacing.png"/>

c) This will redirect you to next interface with various interfaces options. From those options choose the option <b>SPI</b>.<br/>

 <img src="https://cdn.sparkfun.com/assets/learn_tutorials/4/4/9/spi-menu.png"/>

After following these procedures, just hook up your rc522 rfid reader to the RPi (or BeagleBone Black) with the following datasheet:

<table>
  <tr>
    <th>RC522 pin name</th>
    <th>RC522 pin number</th>
    <th>RPi pin number</th>
    <th>RPi pin name</th>
    <th>Beaglebone Black pin name</th>
  </tr>
  <tr>
    <td>SDA</td>
    <td>1</td>
    <td>24</td>
    <td>GPIO8,CEO</td>
    <td>P9_17, SPI0_CS0</td>
  </tr>
  <tr>
    <td>SCK</td>
    <td>2</td>
    <td>23</td>
    <td>GPIO11,SCKL</td>
    <td>P9_22, SPI0_SCLK</td>
  </tr>
  <tr>
    <td>MOSI</td>
    <td>3</td>
    <td>19</td>
    <td>GPIO10,MOSI</td>
    <td>P9_18, SPI0_D1</td>
  </tr>
  <tr>
    <td>MISO</td>
    <td>4</td>
    <td>21</td>
    <td>GPIO9,MISO</td>
    <td>P9_21, SPI0_D0</td>
  </tr>
   <tr>
    <td>IRQ</td>
    <td>5</td>
    <td>18</td>
    <td>GPIO24</td>
    <td>P9_15, GPIO_48</td>
  </tr>
  <tr>
    <td>GND</td>
    <td>6</td>
    <td>6 or 9 or 20 or 25</td>
    <td>Ground</td>
    <td>Ground</td>
  </tr>
  <tr>
    <td>RST</td>
    <td>7</td>
    <td>22</td>
    <td>GPIO25</td>
    <td>P9_23, GPIO_49</td>
  </tr>
  <tr>
    <td>3.3V</td>
    <td>8</td>
    <td>1 or 17</td>
    <td>3V3</td>
    <td>VDD_3V3</td>
  </tr>
 </table>

The schematic image for raspberry pi is:

<img src="https://www.mathworks.com/matlabcentral/answers/uploaded_files/79445/pXzYv.png"/>

Note: The image is for RPi2, but the same works for RPi3 too!!!

After this, just browse to your node working directory through terminal via the command:
```
cd /folder_path
```
Then just install this node module as:
```
npm install node-rfid
```
This will add the node-rfid module to your node_modules folder

Now in your working nodejs code (or by creating a new file) just following the below guideline example:<br/>

<b>Simple reading</b><br/>

This code waits the until the rfid tag is shown to the rfid reader

```javascript
var rfid=require('node-rfid');

rfid.read(function(err,result){
     if(err) console.log("Sorry, some hardware error occurred"); //some kind of hardware/wire error
     console.log(result); //print rfid tag UID
});
```
 
<b>Reading with time limit</b><br/>

This code waits thr rfid tag to be shown to the rfid reader within a time linit, else displays timeout message. The following sample waits for 5000 ms (5 s) for the rfid reader to get rfid tag shown to it. On reaching or exceeding the time limit, the timeout message is displayed. You may change the time limit by passing the time in millisecond as the first parameter in the function "readintime".
For example: for 1 second time limit, just pass 1000.

```javascript
var rfid=require('node-rfid');

rfid.readintime(5000,function(err,result){
	   if(err) console.log("Sorry, some hardware error occurred"); //some kind of hardware/wire error
	   if(result=="timeout"){ 
	    console.log("Sorry, You timed out");  //check if time exceeded the time you passed as argument and print timeout message
	   }else{
	     console.log(result); //print rfid tag UID
	   }
});
```
Now just run your js file as below and see the output in the terminal:

```
 node /file_name
```

---
_Source: https://npm.io/package/node-rfid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
