Skip to content

samt/node-wiegand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wiegand

Decoder for wiegand readers on GPIO. Currently works on linux only, but can be tested on other platforms.

requirements

  • Linux with GPIO
  • node-gyp

installation

$ npm install --save wiegand

running

Make sure you export your GPIO pins according to the epoll docs:

#!/bin/sh
echo 17 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio17/direction
echo both > /sys/class/gpio/gpio17/edge

Note: If you are using the GPIO command to export, it does not automatically set the edge for you. You must do it separately:

$ gpio export 17 in
$ echo both > /sys/class/gpio/gpio17/edge

usage

const wiegand = require('wiegand');

const w = wiegand();

w.begin({ d0: 17, d1: 18});

w.on('data', (data) => {
    console.log('Got', data.length, 'bits from wiegand with data:', data);
});

w.on('keypad', (num) => {
    console.log('Got', num, 'from the reader\'s keypad');
});

w.on('reader', (id) => {
    console.log('Got', id, 'from RFID reader');
});

api

class: Wiegand

inherits EventEmitter

method: begin([options], [callback])

default options:

{
    // RaspberryPI default
    d0: 17,
    d1: 18,
}

callback will fire on the ready event or if an error happens during the process. Errors will be emited on the error event.

method: stop([callback])

stop polling for changes to GPIO. Will callback when done and emit a stop event.

event: 'ready'

event: 'data'

event: 'error'

event: 'reader'

event: 'keypad'

event: 'stop'

license

The MIT License

About

Wiegand Interface via GPIO in Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published