Notes About Working with Various Arduino & Netduino Microcontroller Boards

Sunday, January 13, 2013

Innovations ID12 RFID Reader, Sparkfun RFID USB Reader Board, and a Netduino Plus 2

I posted yesterday about using an Innovations ID12 plus a Sparkfun RFID USB Reader board with a serial connection to an Arduino Uno to read RFID tags.  Here is a similar simple example of using an ID12 and a Sparkfun RFID USB Reader board with a Netduino Plus 2. This setup also uses a serial connection between the pins on the board (not the USB connection) and the Netduino.

The digital pins on the Netduino are 5 volt tolerant, but for best results, use a logic level converter on the serial RX line between the breakout board and the Netduino. Without the logic level converter, the output sometimes shows some garbage characters after a card's code.

This sample C# program reads the card when it is brought near the the ID12 and prints the card's code to the debug console. 

In the References section of the project in Visual Studio 2010, add the references for Microsoft.SPOT.Hardware.SerialPort and SecretLabs.NETMF.Hardware.NetduinoPlus.

Connections:


Reader Board   Netduino Plus 2 
  VCC            5V
  GND            GND
  TX             Digital 0 (via logic level converter)

Connect the serial RX line via the logic level converter. CC and GND on the level converter need to be connected - 3v3 side to Netduino and 5v side to the board. 

Logic Level Converter Connections:
  RXI  -->  Board's TX
  HV        Board's VCC
  GND       Board's GND
  RXO       Netduino's Digital 0
  LV        Netduino's 3V3
  GND       Netduino's GND
  

Code:


using System;
using System.Threading;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using System.IO.Ports;


namespace ID12
{
    public class Program
    {
        public static void Main()
        {
            SerialPort serial = new SerialPort(SerialPorts.COM1, 
                9600, Parity.None, 8, StopBits.One);
            serial.Open();
            while (true)
            {
                String code = "";
                while (serial.BytesToRead > 0)
                {
                    byte[] buf = new byte[1];
                    serial.Read(buf, 0, 1);
                    code += (char)buf[0];
                }
                if (code.Length > 0)
                {
                    Debug.Print(code);
                }
                // Slight delay - otherwise data is garbled
                Thread.Sleep(100);
            }
        }
    }
}



4 comments:

  1. can you please post the images of connection between reader and netduino plus 2.

    ReplyDelete
    Replies
    1. Hi Vignesh -

      I have avoided posting images and don't currently have this set up take any pictures. Are you having trouble with the connections? Which logic level converter are you using? As noted above, I included the logic level converter because it seemed to help with occasional garbage characters, but it isn't strictly necessary. Tell me a bit more about the problem you are encountering, and I'll be happy to set this up again when I have a free moment and see if I can help.

      Delete
  2. hello
    how i can connect D12 to raspberry B +?

    ReplyDelete
  3. hello
    how i can connect D12 to raspberry B +?

    ReplyDelete