1.0.7 • Published 6 years ago

node-rfid v1.0.7

Weekly downloads
7
License
ISC
Repository
github
Last release
6 years ago

node-rfid

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

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

a) Go the terminal and type:

 sudo raspi-config

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

   

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

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

The schematic image for raspberry pi is:

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:

Simple reading

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

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
});

Reading with time limit

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.

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
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago