How to read Wiegand on Raspberry Pi 3 with Node?

1.2k Views Asked by At

I've tried numerous tutorials, and I can't get it to work.

Current situation:
- 12V Access control device that is connected like this i.e. Wiegand D0 to GPIO14 (pin 8/Tx) and D1 to GPIO15 (pin 10/Rx), with voltage dividers, shifting 5V to 3.3V.
- Raspberry Pi 3 with Raspbian Lite OS.
- Configured the GPIO serial port i.e. enabling uart and disabling the console.

I am using the onoff NPM package to read the signals, but I am not getting anything.

const Gpio = require('onoff').Gpio;
const d0 = new Gpio(8, 'in');
const d1 = new Gpio(10, 'in');

d0.watch((err, value) => {
  if (err) {
    throw err;
  }

  d0.readSync(value);
});

d1.watch((err, value) => {
  if (err) {
    throw err;
  }

  d1.readSync(value);
});

process.on('SIGINT', () => {
  d0.unexport();
  d1.unexport();
});

What am I doing wrong?

1

There are 1 best solutions below

0
On

The NPM package you're trying to use can only detect changing logic levels on GPIO pins.

You should use Wiegand NPM instead.

And I think you have set the wrong pins on your code. Pins 8 and 10 are in fact GPIO14 and GPIO15. The library I linked uses GPIO17 and GPIO18 by default, which are located on pins 11 and 12 of the connector.

Having said that, there is no need to disable the UART to use pins 8 and 10 as digital GPIO.