Wiegand support for Photon (Solved)


#1

I have been trying to get an RFID access unit working with my Photon. It uses the wiegand protocol. I have successfully been able to use it without any issue on an Arduino uno using this library. Any suggestions for getting it ported over to the Photon? Unfortunately just packaging it up and importing it into the web IDE didn’t work (although didn’t throw any errors after adding application.h)

Solved
Final library with support for Photon can be found here.


Connecting Wiegand RFID Card Reader to Photon, Pins are kept being interrupted
#2

@gbaman, so I assume you removed this code in the .h file and replaced it with `#include “application.h” as you mentioned:

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

The key thing to change is in Wiegand.cpp, where the GPIO pins are specified in the begin() function:

void WIEGAND::begin()
{
  begin(2,0,3,1);
}

You will need to specify the correct Photon pins as per:
void WIEGAND::begin(int pinD0, int pinIntD0, int pinD1, int pinIntD1)

The arduino requires that you specify the pin and associated interrupt whereas with the Photon, the pin and interrupt are the same. So, to use pins D2 and D3 on the Photon as interrupt outputs D0 and D1 on the wiegand device, you need to change the begin() to:

void WIEGAND::begin()
{
  begin(D2,D2,D3,D3);
}

The rest of the code should work as-is. :smiley:


#3

Thanks @peekay123, that has solved part of it… The keypad on the reader now works using the example, but weirdly it is refusing RFID cards. With the Arduino Uno and the same code, when you place a card near it it beeps and spits out the ID to the serial console. With the Photon, the reader ignores the card, not even beeping? Any suggestions?
My quickly thrown together fork for the Photon is here.


#4

Scratch that, have sorted it! Turns out the Photon VIN pin was providing just not enough volts to run the RFID reader. When the reader was attached to a separate power supply, it all works fine :smile:

Thanks for the help @peekay123.