Implementing Wiegand protocol? [DONE]

So I got my hands on a RFID reader that supports the wiegand protocol and UART TTL Interface. The current available library for it uses SoftwareSerial.h and Arduino.h as dependancies and can’t simply be commented/removed to make compatible with the Spark Core.

Any suggestions on how to approach this?

The RFID reader library and source code is available here:

There’s some minor parts that needs to be changed in order for it to work with :spark: core?

Are you familiar? :smile:

I can chip in some help to get it converted

I got it ported over to Spark IDE and there’s only one part i can’t figure out what to replace with:

class SeeedRFID
	SoftwareSerial * _rfidIO; // software serail
	RFIDdata _data;
	boolean _isAvailable;
	RFIDType _type;
	boolean checkBitValidationUART();
	boolean read();

What should this be changed to SoftwareSerial * _rfidIO; // software serail ?

I used USARTSerial to replace and made it USARTSerial * _rfidIO

Wondering if it’s correct but i managed to compile.

@felixekman are you free to try out the code? :smiley:

Actually I don’t know how to do that. Right now I just read the normal incoming serial and do verification against read data that way. As for the library, it would be great to have it converted to work with spark core. But would be even better if we have some solid implementation of a Wiegand protocol since it is the “de facto standard commonly used to connect a card reader or keypad to an electronic entry system.”

There is a library for Arduino already but that needs to be ported, which is beyond my skill set.

There’s a high chance I can get it ported.

Let me head home and dedicate tonight to work on it :slight_smile:

I got the Wiegand protocol ported without changing a single line of code and you might want to test it out!

Not going to claiming any credit cos i didn’t do anything except trying to compile it in Spark IDE :slight_smile:

Huh, wired… I still get problems when I port it. Will have to look at it again tomorrow, probably doing something stupid that I’m not realising! ^^

There’s some parts you need to comment away and would work fine.

See here:

Have fun!

kennethlimcp, [quote=“kennethlimcp, post:2, topic:3551”]
used USARTSerial to replace and made it USARTSerial * _rfidIO

That is the correct syntax as long as _rfidIO is set to &Serial1 at some point. :smile:

:smiley: i tried my luck looking at how Serial1 is being initalized in the core-firmware code.

Cos i never written code using this way and had no clue what to change.

I did the Serial1.begin in the .cpp file :blush:

Hmm. I can’t get it to compile though.

Need to modify here…

> SeeedRFID::SeeedRFID(int rxPin, int txPin)
> {
>     _rfidIO = USARTSerial Serial1; //some error with this
>     _rfidIO->begin(9600);
>    }

kennethlimcp, I just looked at the seeedStudio code and now I see what they did. I wish coders would stop using SoftwareSerial as it really is a useless approach to doing serial communications. To follow their logic, you could rewrite init() like this:

SeeedRFID::SeeedRFID(int rxPin, int txPin)
    _rfidIO = &Serial1;

	// init RFID data
	_data.dataLen = 0;
	_data.chk = 0;
	_data.valid = false;

	_isAvailable = false;
	_type = RFID_UART;


Woohoo! Brilliant :slight_smile:

Don’t suppose anyone has working copy of the code?

My compile attempts are failing and the gist link is a 404 :frowning:

@bufferout, I can port the library later today. Are you using the web IDE or Spark CLI / DEV? :smile:


@peekay123 that would be amazing if you have the time. I’m using the web IDE.

@bufferout, the library (SEEDRFID) is now available on the web IDE. It is set to use Serial1 by default. :smile: