Connect multiple wiegand readers to esp32 using arduino

Hello
I want to connect two RFID readers to a single ESP32 module . So I have used the wiegand Liberary which I downloaded from here :

Then I used the liberary example and modified it for 2 readers .

#include <Wiegand.h>

WIEGAND wg0;
WIEGAND wg1;
void setup() {
 Serial.begin(9600);  
 
 // 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.
 wg0.begin(16,17);
        wg1.begin(34,35);
  
}

void loop() {
 if(wg0.available())
 {
 Serial.print("Wiegand HEX from RD1= ");
 Serial.print(wg0.getCode(),HEX);
 Serial.print(", DECIMAL = ");
 Serial.print(wg0.getCode());
 Serial.print(", Type W");
 Serial.println(wg0.getWiegandType());    
 }
 if(wg1.available())
 {
    Serial.print("Wiegand HEX from RD2= ");
    Serial.print(wg1.getCode(),HEX);
    Serial.print(", DECIMAL = ");
    Serial.print(wg1.getCode());
    Serial.print(", Type W");
    Serial.println(wg1.getWiegandType());    
  }
}

I have connected my Node mcu module to the readers via a level converter . D16 and D17 are connected to reader 1 , D34 and D35 are connected to reader 2
The problem is that when reader 1 sends data sometimes the esp says that it is from reader 2 and vice versa. so I can’t understand which reader has read the card.
could you please help me find the problem ?

Check the GitHub, they offer a comparison of the libraries

They state

This is the easiest and cleanest library to use when only a single wiegand reader is needed. I strongly suggest to use this version if you only need one reader support

You should try

I tried using this

but it only support AVR boards, when I used it with ESP32 there is an error stating " can not compile for esp32".
is there any other way of doing this?

I've not played with that library on ESP32. I suspect that the library you picked does not work for multiple instances... I'm unaware of other libraries, I've seen GitHub - paulo-raca/YetAnotherArduinoWiegandLibrary: Event-driven Wiegand Library for Arduino but did not test.

ll ESP32 GPIO pins are interrupt -capable pins so should work maybe

thankyou , I'll have a look at it

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.