A library to read HID RFID cards through the wiegand protocol. This was tested with the HID ProxPoint Plus 6005BG00.
Dependents: HID_ProxCard_Wiegand_Example
Wiegand Library for HID ProxPoint Plus
While this library should be able to read any wiegand input, the buffer can only store 64 bits, and it expects there to be less than a 5ms delay between each bit sent.
Here is a picture of some example wiring:
To use this library use the following pin attachments, the 6005BG00 has its pinouts on its back label (top right).
6005BG00 Wire | MBED PIN |
---|---|
data0 | p30 |
data1 | p29 |
hold | p28 |
GND | GND |
DRAIN | GND |
5-16V (red) | Vu |
Here is a picuture of it wired up:
include the mbed library with this snippet
void void onCardRead(); Wiegand rfid(p30, p29, p28, &onCardRead); int main() { while(1) { rfid.doEvents(); //checks if data has been fully read, and calls the callback } } void onCardRead() { /* Do stuff with data, as we've fully read the card. WHen this function exits, RFID reader will be reset to read Another Card */ //returns the unique student identifier on a buzzcard (6 digit number on back of buzzcard below gatech seal) uint64_t rawCardData = rfid.getBits(14,33); }
Description of public methods
method | description |
---|---|
Wiegand(PinName pdata0, PinName pdata1, PinName pHold, void (*onCardRead)()); | constructor, call WIegand wiegand (...) |
void doEvents(void) | checks if all RFID data has been read though the use of a timer, and calls the onCardRead callback |
uint8_t bitsRead(void) | returns the number of bits read |
uint64_t getBits(uint8_t start, uint8_t end) | Returns the bits read from in [start,end] (Inclusive). If its an invalid range, returns 0 |
Example Program
Import programHID_ProxCard_Wiegand_Example
Example program to read HID ProxCards using the gatech BuzzCard format with a HID ProxPoint Plus 6005BG00.
Here is a video of the example program in action:
ProxPoint Plus 6005BG00 Oscilloscope Capture
Gatech BuzzCard Protocol
The rfid buzzcard unique student identifier can be found on the back of your buzzcard below the shiny gatech seal (6 digit number). Each buzzcard's rfid tag stores 35 bits of data, but only bits [14,33] contain your id (bit index starts at 0, and range is inclusive).
Diff: Wiegand.h
- Revision:
- 0:21edeadd0ca0
- Child:
- 2:47ffa4e32ce3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Wiegand.h Tue Apr 22 17:52:05 2014 +0000 @@ -0,0 +1,78 @@ +/* Mbed Wiegand library + * Copyright (c) 2014, + * Colin Bookman, cobookman [at] gmail [dot] com + * Sarthak Jaiswal sjaiswal3 [at] gatech [dot] edu + * Avnish Kumar akumar96 [at] gatech [dot] edu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MBED_MICIO_H +#define MBED_MICIO_H + +#include "mbed.h" + +/** + * @code + * #include "Wiegand.h" + * + * Wiegand wiegand(pin data0, pin data1, pin hold, onRFIDRead); data0/data1 are ISR Inputs, hold = digital Out + * + * @endcode + */ +class Wiegand { +public: + + /* Create a Wiegand instance, and attach interrupts */ + Wiegand(PinName pdata0, PinName pdata1, PinName pHold, void (*onCardRead)()); + + /* Check if we've read all card data */ + void doEvents(void); + + /* return number of bits currently read */ + uint8_t bitsRead(void); + + /* Returns the bits read from in [start,end] (Inclusive) */ + uint64_t getBits(uint8_t start, uint8_t end); + +protected: + InterruptIn _data0ISR; + InterruptIn _data1ISR; + DigitalOut _hold; + Timer _lastISR; + + void (*_onCardRead)(); //callback function + + /* Internal buffer of wiegand data */ + volatile uint8_t _buffer[50]; + uint8_t _sizeOfBuffer; + + /* Number of bits currently read */ + volatile uint8_t _bitsRead; + + /* Reset buffer */ + void _resetBuffer(void); + + /* Attaches ISR Routines */ + void _attachInterrupts(void); + + /* ISR Routine for data 0 */ + void _data0ISRAction(void); + + /* ISR Routine for data 1 */ + void _data1ISRAction(void); + +}; + +#endif