NFC ring logger tutorial with a KeyDuino

  • the code:

     You will need PN532_HSU.h & PN532.h library to use it.
     #include < PN532_HSU.h > #include < PN532.h > #define BUZZER 15
     PN532_HSU pn532hsu(Serial1);
     PN532 nfc(pn532hsu);
     String NFC_Key_1 = "xxxx";
     String NFC_Key_2 = "xxxx";
     String PASSWORD = "xxxxxxxx";
     //*******************fonction lecture de tag
     String fct_lecture() {
     	String Received;
     	boolean success;
     	uint8_t IdReceived[] = {
     		0, 0, 0, 0, 0, 0, 0
     	uint8_t Id_Length;
     	if (success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, & IdReceived[0], & Id_Length)) {
     		for (uint8_t i = 0; i < Id_Length; i++)
     		Received += String(IdReceived[i], HEX);
     		return (Received);
     	} else return ("NULL");
     void setup(void) {
     	uint32_t versiondata = nfc.getFirmwareVersion();
     	pinMode(BUZZER, OUTPUT);
     void loop(void) {
     	String Received;
     	Received = fct_lecture();
     	if (Received != "NULL") {
     		Serial.print("NFC tag found: ");
     		if (Received == NFC_Key_1 || Received == NFC_Key_2) {
     			digitalWrite(BUZZER, HIGH);
     			digitalWrite(BUZZER, LOW);
     	} else Serial.print(".");

    EDIT BY JOHN, adding three ` before and after your code makes it a code block and does syntax highlighting :) Also I fixed your lazy indenting! :P

  • NFC Ring Team

    Quick disclaimer, you shouldn't really use this in production.. As awesome as the keyduino is and as awesome as this is as a quick win it's not secure..

    The problem is that it will send keyboard events potentially pasting your password in your current focused element.. IE if your ring touched the reader half way through writing an email it might put your password in the contents of that email.. While you would probably notice this is still undesirable..

    We're working on a way to make this better :) @MrStein btw is there anyway we could write a driver to make the Keyduino show up as an NFC reader in Windows?

  • Ahah, thank you for the edit :p
    The goal is just to showing the keyboard use of the leonardo bootloader but I'm agree, it's not a secure way is you plug it all days.

    For the driver, I'm working for a new bootloader, that will name the keyduino "keyduino" instead of "leonardo". Problem is about the unsigned drivers (the way to accept a driver without signature is not the same between Win7,8 or 10). So it will be a little bit difficult..

  • Community Helper

    Well, this is a lot tidier then my implementation, however I stopped using it as it was just too bulky as i never bothered to place it in a case, so wires everywhere! Kudos none the less!

    e; maybe a bit more commenting in the code for people whom is newer on the coding side?
    I always try to practice commenting every line if i release code.

Log in to reply

Looks like your connection to NFC Ring Forum was lost, please wait while we try to reconnect.