Remarks
IDxxLA | |
---|---|
Status | |
Source code | GitHub *TODO (not in master yet) |
NuGet package |
The ID-Innovations LA series is a 125KHz RFID reader controlled via serial connection. There are currently 3 variations available: The ID-12LA, the ID-20LA which has a larger antenna and the ID-2LA/ID-3LA, which is the smallest but requires an external antenna.
Purchasing
The LA series is available from the following suppliers:
To use the RFID readers in your designs, the following breakout boards are available:
- SparkFun RFID USB Reader has optional breakout pin header
- SparkFun RFID Reader Breakout
- Recommend purchasing 2x 2mm sockets to reduce the chance of damaging the RFID readers when soldering
Code Example
The IDxxLA
can be consumed though an event or by subscribing as an observer. Both approaches are equally effective and have slightly different usage patterns. It is also possible to read the LastRead
property at any time get the last RFID successfully scanned by the device.
Sample projects available on GitHub
Event Approach
public class MeadowApp : App<F7Micro, MeadowApp>
{
private readonly IRfidReader _rfidReader;
public MeadowApp()
{
_rfidReader = new IDxxLA(Device, Device.SerialPortNames.Com1);
// subscribe to event
_rfidReader.RfidRead += RfidReaderOnTagRead;
_rfidReader.StartReading();
}
private void RfidReaderOnTagRead(object sender, RfidReadResult e)
{
// event triggers after a complete read, even if unsuccessful
// e.Status returns whether the read was successful or not
if (e.Status == RfidValidationStatus.Ok)
{
Console.WriteLine($"Tag value is {DebugInformation.Hexadecimal(e.RfidTag)}");
return;
}
Console.WriteLine($"Error {e.Status}");
}
}
Observable approach
public class MeadowApp : App<F7Micro, MeadowApp>
{
private readonly IRfidReader _rfidReader;
public MeadowApp()
{
_rfidReader = new IDxxLA(Device, Device.SerialPortNames.Com1);
// subscribe to IObservable
_rfidReader.Subscribe(new RfidObserver());
_rfidReader.StartReading();
}
private class RfidObserver : IObserver<byte[]>
{
// OnCompleted will only be called if you dispose of the reader
public void OnCompleted()
{
Console.WriteLine("RfidReader has terminated, no more events will be emitted.");
}
// 'error' can optionally be cast to RfidValidationException
public void OnError(Exception error)
{
Console.WriteLine(error);
}
// Only called on successful reads.
public void OnNext(byte[] value)
{
Console.WriteLine($"Tag value is {DebugInformation.Hexadecimal(value)}");
}
}
}
Wiring Example
To wire an LA series RFID reader to your Meadow board, connect the following depending on the breakout board used:
Meadow Pin | RFID Reader Breakout | RFID USB Reader + Breakout Header |
---|---|---|
5V |
VCC |
VCC |
GND |
GND , FORM |
GND , GND (there are 2) |
D13 |
D0 |
TX |
RFID Reader Breakout diagram:
RFID USB Reader + Breakout Header diagram:
Other wiring notes:
- If you are using an ID-2LA/ID-3LA, you will need to connect an antenna to the
AN1,AN2
/ANT,ANT
pins (orange wires in above diagrams). - For the reader breakout it is important to connect
FORM
toGND
, as this tells the reader to use the ASCII format. Other formats are not supported. - For the reader breakout a LED can be connected to
READ
which can be used as an indication of a card being read. This is completely optional. The LED and a 330Ω resistor is included in the above diagram. - All the LA series RFID readers are suitable for 5V, however should also work fine with 3V3.
Characteristic | Locus |
---|---|
Inheritance | System.Object > IDxxLA |
Implements | IRfidReader System.IObservable<System.Byte[]> System.IDisposable |
Inherited Members | System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone() |
Namespace | Meadow.Foundation.Sensors.Radio.Rfid |
Assembly | IDxxLA.dll |
Syntax
public class IDxxLA : IRfidReader, IObservable<byte[]>, IDisposable
Constructors
IDxxLA(IIODevice, SerialPortName)
Create an IDxxLA RFID reader
Declaration
public IDxxLA(IIODevice device, SerialPortName serialPortName)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | Device to use |
SerialPortName | serialPortName | Port name to use |
IDxxLA(ISerialMessagePort)
Create an IDxxLA RFID reader using an existing port.
Declaration
public IDxxLA(ISerialMessagePort serialPort)
Parameters
Type | Name | Description |
---|---|---|
ISerialMessagePort | serialPort |
Remarks
Be sure to use suitable settings when creating the serial port. Default BaudRate and DataBits are exposed as constants.
Fields
BaudRate
Declaration
public const int BaudRate = 9600
Field Value
Type | Description |
---|---|
System.Int32 |
DataBits
Declaration
public const int DataBits = 7
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
LastRead
A cached copy of the last successfully read RFID tag.
Declaration
public byte[] LastRead { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | The last read RFID tag. |
SerialPort
Declaration
public ISerialMessagePort SerialPort { get; }
Property Value
Type | Description |
---|---|
ISerialMessagePort |
Methods
Dispose()
Dispose of this instance.
Declaration
public void Dispose()
StartReading()
Start reading for RFID tags.
Declaration
public void StartReading()
StopReading()
Stop reading for RFID tags.
Declaration
public void StopReading()
Subscribe(IObserver<Byte[]>)
Subscribe to RFID tag reads. Observer will only receive valid reads, with invalid reads triggering an OnError call. OnComplete will be called if this instance is disposed. This call is thread-safe.
Declaration
public IDisposable Subscribe(IObserver<byte[]> observer)
Parameters
Type | Name | Description |
---|---|---|
System.IObserver<System.Byte[]> | observer | The observer to subscribe |
Returns
Type | Description |
---|---|
System.IDisposable | Disposable unsubscriber |
Events
RfidRead
Event fired when an RFID tag is read. Check the read status to see if the read was successful.
Declaration
public event RfidReadEventHandler RfidRead
Event Type
Type | Description |
---|---|
RfidReadEventHandler |