Monday, November 17, 2014

ER301 NFC/Mifare driver in pure C#

A YouTube viewer found my old demonstration of ER301 anti-collision and asked if I could make the source code available. So I cleaned it up a bit and wrote this small blog entry about it.

When I started tinkering with the unified Danish transit card about a year ago, it was using a cheap Ehuoyan ER301 NFC/Mifare reader which I got from ebay. This was the first time I played with NFC stuff even if I would since move on to other and better devices. The cool thing about the ER301 however, apart from the price, is that it's relatively easy to interface with. This is because it's using a plain virtualized serial port with native (cp2102) driver available in Linux and even Windows.




No software came with the ER301 reader but there was a download link at the ebay site. The software was very basic, and all examples revolved around a driver DLL for which the source code sadly was not provided. With the documentation in hand and tracing the traffic going over the serial interface, I decided to implement it in pure C# so I would not depend on Windows and static architecture libraries.

Although originally developed with Mono/Monodevelop, the current sources revolves around a Visual Studio solution, with the driver as one project and a simple console application as another. Note that the driver is not complete yet and it caters only to the needs I had at the time (complete dump of data), but it should be fairly easy to extend it with the granularity you might need, since most of the core API have already been implemented. It supports Mifare Classic S50 (1K) and S70 (4K). It can easily be made to support other types as well as long as it's supported by the ER301 hardware.



ER301.NET Console app dumping data from a Mifare Classic S70/4K

The source code is available on Github under GPL2 and most of the interesting stuff takes place in ER301.cs. I am looking into releasing a (WinForms) client application as well, but I need to clear it with a customer of some derivative work first.

Post a Comment