I am trying to connect a Wiegand RFID card reader to a Photon.
The RFID card reader is powered with an external 12V power supply.
And its WG0 and WG1 are connected to the Photon’s D2 and D3.
Using a multimeter, WG0, WG1 to GND = 5V.
The Photon is powered with USB connected to my computer.
And I have tested codes from these 2 threads:
Touching a smartcard to the reader will not display anything on the screen.
So I added several Serial.println here and there and I can see that pin D2 and D3 are kept being interrupted all the time, even though there is no card near the RFID reader.
void WIEGAND::begin()
{
begin(D2,D2,D3,D3);
}
void WIEGAND::begin(int pinD0, int pinIntD0, int pinD1, int pinIntD1)
{
// original codes...
pinMode(pinD0, INPUT);
pinMode(pinD1, INPUT);
attachInterrupt(pinIntD0, ReadD0, FALLING);
attachInterrupt(pinIntD1, ReadD1, FALLING);
}
void WIEGAND::ReadD0()
{
Serial.println("Interrupted D0");
// original codes...
}
void WIEGAND::ReadD1()
{
Serial.println("Interrupted D1");
// original codes...
}
And my CLI will print out these lines:
…
Interrupted D0
Interrupted D1
Interrupted D1
Interrupted D0
Interrupted D1
Interrupted D0
Interrupted D1
…
Any idea why? This RFID can read card (display the card’s number on Notepad++) just fine if connected directly to a computer via an USB cable.
If I changed pinMode(pinD0, INPUT) to pinMode(pinD0, INPUT_PULLUP)
And I pulled out the pin D2 and D3 cables, the “Interrupted DX” stopped.