markneustadt.com

Netduino system with Parallax RFID reader

Since I work in an RFID industry, it makes sense that I would want to explore this arena.  Thankfully with the help of the Netduino forum, I was able to get this working.  The one thing I needed to do was to include a reference to Microsoft.SPOT.Hardware.SerialPort

After that, and after I had things wired up correctly, I had pretty good luck.

Click here to download the ParallaxRFID.fzz

ParallaxRFID

Click here to download the source code and project – RFIDDemo2

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.IO.Ports;

namespace RFIDDemo2
{
    public class Program
    {
        public static void Main()
        {
            OutputPort pin4 = new OutputPort(Pins.GPIO_PIN_D4, false);
            InputPort btn = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);
            SerialPort COM1 = new SerialPort(SerialPorts.COM1, 2400, Parity.None, 8, StopBits.One);

            // enable the RFID reader
            pin4.Write(false);

            // Open the serial port if it's not already open.
            if (!COM1.IsOpen)
            {
                COM1.Open();
            }

            // Continue the program as long as the user hasn't hit the button.
            while (!btn.Read())
            {
                String output = "";
                while (COM1.BytesToRead > 0)
                {
                    byte[] buffer = new byte[1];

                    // read the first byte into the buffer array
                    COM1.Read(buffer, 0, 1);

                    // 0x0A is the end of data sequence
                    if (buffer[0] != 0x0A)
                    {
                        output += (char)buffer[0];
                    }
                    else
                    {
                        Debug.Print("Card RFID: " + output);
                        break;
                    }
                }

                // only loop once per quarter second
                Thread.Sleep(250);
            }

            // the user hit the button.  Disable the reader and close the port if necessary
            pin4.Write(true);
            if (COM1.IsOpen)
            {
                COM1.Close();
            }
        }
    }
}

SimpleParallaxRFID_01 SimpleParallaxRFID_02 SimpleParallaxRFID_03 SimpleParallaxRFID_04 SimpleParallaxRFID_05

 

 

Scroll To Top