HID r10 reading iseu

so i have a HID r10 reader and i have it working as it should but it reads verry inconsistent not reallyable does anybody maybe know hy it does that ?

black and red are data 0 and data 1

wich i conected to the ardiuno

#include <Wiegand.h>


#define relaisPin 4
#define schakelaar 5

// registered codes
long long int code = {card ID, card ID};

void setup() {

pinMode(relaisPin, OUTPUT);
pinMode(schakelaar, INPUT);

// default Wiegand Pin 2 and Pin 3 see image on README.md
// for non UNO board, use wg.begin(pinD0, pinD1) where pinD0 and pinD1
// are the pins connected to D0 and D1 of wiegand reader respectively.

void loop() {
Serial.print(“Wiegand HEX = “);
Serial.print(”, DECIMAL = “);
Serial.print(”, Type W”);

// for all registered codes
for(int i = 0; i < (sizeof(code) / sizeof(code[0])); i++){
  // if code is registered
  if(wg.getCode() == code[i]){
    // do the thing
    Serial.println("if statement ran");  //debug
    digitalWrite(relaisPin, HIGH);
    digitalWrite(relaisPin, LOW);


if(digitalRead(schakelaar) == HIGH){
digitalWrite(relaisPin, HIGH);
digitalWrite(relaisPin, LOW);

Wiegand HEX = mycard, DECIMAL = my card, Type W34
inf statement ran
Wiegand HEX = 5, DECIMAL = 5, Type W4
Wiegand HEX = 5, DECIMAL = 5, Type W4
Wiegand HEX = 82AA8154, DECIMAL = 2192212308, Type W34
Wiegand HEX = D6AAD2B5, DECIMAL = 3601519285, Type W34
Wiegand HEX = 5, DECIMAL = 5, Type W4
Wiegand HEX = 5, DECIMAL = 5, Type W4
Wiegand HEX = 5, DECIMAL = 5, Type W4
Wiegand HEX = 5, DECIMAL = 5, Type W4
Wiegand HEX = 5, DECIMAL = 5, Type W4
Wiegand HEX = D, DECIMAL = 13, Type W4
Wiegand HEX = 7223CC46, DECIMAL = 1914948678, Type W34
Wiegand HEX = mycard, DECIMAL = mycard, Type W34
if statement ran

in between the my cards and inf statemt is random stuf the reader spits out every once in a while

with kind regards simon :smiley:

@cexshun had a similar problem with getting noise in his Arduino project. He eventually nailed it down to the Arduino I believe and fixed it by changing boards.

Yup. All mini arduinos, including the official Arduino brand Nano, failed to read the data stream reliably. Went with the full sized Arduino, and the issue went away.


Ah okey intresting what ardiuno should i use?

I am now using a uno

Should i be using a mega?

I used an uno Rev 3 and even an ancient duemilanove.

If you are already using an uno, I suspect you aren’t using a pull up resistor? And I don’t see your code utilizing the onboard pullup resistor.

Try setting the input pinmode to input_pullup instead of input. Or run a 10k resistor from the input pin to +5v.

What are you using to power the arduino and the reader? Volt and Amp rating?

ah okey

ehm no i havent used a pul up ristor this is how i conected it up

and i wil first try to do the input_pullup when i get home today im intrested if that wil work

and for power for the ardiuno it now runs of a usb port
and the reader runs of my bench powersuply

Input pins float. If they read inconsistently, or seem to randomly detect signal, then that’s the problem. Weigand reads high and drops to low to flip the bit. So you need to use a pullup resistor which keeps the input high at the full 5v rather than fluttering around. When the Weigand wire goes low, it has less resistance than the resistor, so it drops to 0v which is read as a low state.

It’s really best practice to always use a pullup or pulldown resistor when using a digital input pin. Weigand just happens to be pullup.

I believe, from the factory, HID reads MSB while mifare chips are LSB. So if you are reading mifare, be prepared for it to be read backwards unless it was specifically ordered as LSB or you’ve reprogrammed it with a config card. They also only read 32bit and will strip a good portion of the mifare chip, unless custom ordered or configed to be 56bit.


so i have put the pul up ristor in place and i am not getting any random reads any more for now

it stil is not reading really reliable though

Reliable how? Also what value resistor?

The only way you’re going to get reliable reads from unpredictable input is by using an interrupt handler. Luckily the Arduinos all have 2 pins dedicated for that, you’ll just need to modify your code.

i wil try and do that have no cleu how yet though :smiley:

You could use something like this

This one is for specific bit lengths, but there’s a link at the beginning to some less stable code that will accept any amount of bits the reader puts out that you can pick apart.

this looks like its working its now 9 out 10 times thats good for me


wel not any more haha after some time it gets in consistent again :open_mouth:

its working:D

and here is my janky setup

thanks to @Satur9 @cexshun

1 Like