Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Daniel Minnaar

Member Since 01 Oct 2011
Offline Last Active Apr 01 2014 08:38 AM

#49275 RFID Reader/Write (13.56khz - Mifare) on Netduino

Posted by Daniel Minnaar on 09 May 2013 - 04:50 AM


I've played around some with the SM130 Mifare module from SonMicro and didn't have any problems. Maybe that's not the one you got though.


In general hexadecimal formatting is merely used as a notation on paper and in programming languages. If you write 0x80 in C# (and C/C++) the actual value will be 128 decimal as it would if you wrote 128 in the first place.


In C# you can use hexadecimal notation freely so you should not need any conversion - unless of course the hexadecimal notation is in a string, then you need to convert it.


For single bytes, this can be done quite easily back and forth using (in analogy with the above example) 128.ToString("X2") and byte.Parse("0x80", NumberStyles.AllowHexSpecifier) functions respectively.


I don't know of a smart way to convert whole strings, but you could of course always traverse the array and assemble a string as you go using the mentioned functions.


This methods below are supposed to translate byte arrays into strings with 8 bit space separated hexadecimal numbers and vice versa. This is from the top of my head so you may need to alter it a bit if it does not compile as is:

public class HexConversion{   private static string _hex = "0123456789ABCDEF";   public static string toHex(byte[] 
B) { string s = ""; for(int i = 0; i < b.length; i++, s += " ") s += _hex[b[i] >> 4] + _hex[b[i] & 0xf]; return s; } public static byte[] fromHex(string s) { string[] a = s.Split(' '); byte[] b = new byte[a.Length]; for(int i = 0; i < b.length; i++) b[i] = byte.Parse(a[i], NumberStyles.AllowHexSpecifier); return b; } }

It could be you need to add the "0x" prefix in both the functions above. You would then use these functions like so:

// convert a regular string to a hex stringstring hex = HexConversion.toHex(Encoding.ASCII.GetBytes("Hello world"));// convert a hex string into a byte arraybyte[] bytes = HexConversion.fromHex(hex);// convert a byte array to a hex stringhex = HexConversion.toHex(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});


Hanzibal, is there a chance you could share the reading and writing code for the SM130 module? I think I might go with this if I have some proven code to go with... thanks!

#49217 RFID Reader/Write (13.56khz - Mifare) on Netduino

Posted by Daniel Minnaar on 08 May 2013 - 08:14 AM

Hi there,


After using the 125khz readers on the Netduino, I decided I want to write data to the tag, which forces me to use 13.56khz tags (Mifare) and appropriate reader/writers.


Initially I bought a NFC shield, which was a disaster because I couldn't get the SPI driver to work with Netduino. I've read multiple threads about it and no-one has been able to get it right with a Netduino. So I decided to get a new reader/writer using UART comms instead.


The problem is that the UART commands are all in hexadecimal format and I don't have much experience working with hex conversion into bytes to send over UART...



So a few questions before I start:


    [*]If I wanted to send 0x01 as a command to search for cards, could I simply do this? serialPort.Write(Text.Encoding.UTF8.GetBytes("0x01"), 0, theLength);
    [*]If I needed to encode something as hex, such as string or number (i.e "Hello World", or "12345"), how do I do this? Is there a library or method extension out there I can use to convert it?
    [*]At a first glance, would this reader/writer work with the Netduino 2? I see it uses a 4-pin wire, but I can just put in some solder wire tips and connect it to the headers: http://www.elechouse...roducts_id=2156
    [*]If I have 1k space on the Mifare Card, how can I calculate how much space "Helllo World" or "123456" would take in hex format on the card? I'll have a few variables i want to push into the card so I need to make sure it will all fit.


    I'd REALLY appreciate some help, it's for a project at work and I need to make sure of my facts. Thanks a ton!

#32628 Commonly grounding your circuit

Posted by Daniel Minnaar on 24 July 2012 - 03:17 PM

Hi, Since I've used a Netduino in a few projects, I've found that I can always group my ground pins to the same wire. In some instances I've found I can group my negatives, too. I'm trying to figure out why, and when this is a good/bad idea. When this is acceptable, does it always have to be the same supply voltage/current? What are the rules behind this? Thank you!

#20808 Netduino + WiFly: Connecting it up

Posted by Daniel Minnaar on 21 November 2011 - 09:12 AM

Hi, I recently purchased the WiFly RN-171, but I don't think I'm connecting it up right... could someone please explain where I'm going wrong? It's using RS-232 not SPI. I've connected a RX wire to DIO_1 and a TX wire to DIO_2 (I'm using pad 2 + 3 for data according to datasheet), but it's always just flashing/alternating between red and green - as if I'm not sending any data at all. I'm quite positive it's my connections because I've tried many different ways of sending the command-mode ASCII cmd ($$$)... Here's the datasheet: I'm not using a shield, just connecting straight to the module from 3.3V. Any help would be great.

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.