Navigation

    • Login
    • Search
    • [[global:header.recent]]
    • [[global:header.tags]]
    • [[global:header.popular]]
    • [[global:header.groups]]
    • [[global:header.search]]

    NFC ring logger tutorial with a KeyDuino

    Ideas for using NFC Rings
    keyduino nfc arduino
    3
    4
    6947
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MrStein
      MrStein last edited by johnyma22

      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) {
       	Serial.begin(115200);
       	Serial.println("Hello!");
      
       	nfc.begin();
       	uint32_t versiondata = nfc.getFirmwareVersion();
       	nfc.setPassiveActivationRetries(0xFF);
       	nfc.SAMConfig();
       	pinMode(BUZZER, OUTPUT);
       }
      
       void loop(void) {
       	String Received;
       	Received = fct_lecture();
      
       	if (Received != "NULL") {
       		Serial.print("NFC tag found: ");
       		Serial.println(Received);
       		if (Received == NFC_Key_1 || Received == NFC_Key_2) {
       			digitalWrite(BUZZER, HIGH);
       			delay(100);
       			digitalWrite(BUZZER, LOW);
       			Keyboard.println(PASSWORD);
       			delay(1000);
       		}
       	} 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

      1 Reply Last reply Reply Quote 1
      • johnyma22
        johnyma22 NFC Ring Team last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • MrStein
          MrStein last edited by

          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..

          1 Reply Last reply Reply Quote 1
          • Andreas
            Andreas Community Helper last edited by Andreas

            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.

            ~Deas

            1 Reply Last reply Reply Quote 0
            • First post
              Last post