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

    Logging into Desktop with Arduino

    Ideas for using NFC Rings
    arduino
    5
    14
    17284
    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.
    • M
      MacManus last edited by MacManus

      You want to Login to your Desktop with your NFC Ring?
      You have an Arduino Leonardo, an NFC Ring and an Elechouse PN532 reader (v3 recommended)?

      Great, lets build a Log-In Station for your Laptop.
      It works with nearly every password field (Debian Linux Login, Windows 8.1 Login, Keepass tested and worked - BIOS password doesn't work).

      Connect the Elechouse reader to the Arduino Leonardo (see below) and connect the Arduino via USB to your computer.

      PN532 Module <-> Arduino

      GND <-> GND
      VCC <-> 3v3
      SDA <-> SDA (on Arduino Leonardo D2)
      SCL <-> SCL (on Arduino Leonardo D3)

      So here's the code:

      #include <EEPROM.h>
      
      /**************************************************************************/
      /*!
      Autor: Pascal König
      Website: http://blog.koenig-pascal.de
      
      Elechouse NFC Module v2.0
      Library: https://github.com/elechouse/PN532
      NFC Code Template: https://github.com/JohnMcLear/NFC_Ring_Arduino_Door_Lock/blob/master/NFC_Door_Lock.ino
      
      */
      /**************************************************************************/
      
      
      #include <Wire.h>
      #include <PN532_I2C.h>
      #include <PN532.h>
      
      PN532_I2C pn532i2c(Wire);
      PN532 nfc(pn532i2c);
      
      
      void setup(void) {
        Keyboard.begin();
        Serial.begin(115200);
        Serial.println("Hello!");
      
        nfc.begin();
      
        uint32_t versiondata = nfc.getFirmwareVersion();
        if (! versiondata) {
          Serial.print(versiondata);
          Serial.print("Didn't find PN53x board");
          while (1); // halt
        }
        
        // Got ok data, print it out!
        Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
        Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
        Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
        
        // Set the max number of retry attempts to read from a card
        // This prevents us from waiting forever for a card, which is
        // the default behaviour of the PN532.
        nfc.setPassiveActivationRetries(0xFF);
        
        // configure board to read RFID tags
        nfc.SAMConfig();
          
        Serial.println("Waiting for an ISO14443A card");
      }
      
      void loop(void) {
        String ringUid;
        boolean success;
        uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
        uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
        
        // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
        // 'uid' will be populated with the UID, and uidLength will indicate
        // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
        success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
        
        if (success) {
          // Display some basic information about the card
          // Serial.println("Found an ISO14443A card");
          // Serial.print(" UID Length: "); Serial.print(uidLength, DEC); Serial.println(" bytes");
          Serial.print(" UID Value: ");
          for (uint8_t i = 0; i < uidLength; i++)
          {
            //Serial.print("..");
            //Serial.print(uid[i], HEX);
            ringUid += String(uid[i], HEX);
      
          }
          //Serial.println(ringUid + "\n");
          Serial.println(ringUid);
          if(ringUid == "publicRingUID"){
            Serial.println("public");
          }
          else if (ringUid == "privateRingUID"){
            Serial.println("private");
            Keyboard.println("password");
            delay(5000);
          }
        }
      }
      

      Change your password at the end of the code (in the private Ring Area).

      And here's a video

      If you have questions: Feel free to ask.

      1 Reply Last reply Reply Quote 2
      • Lokki
        Lokki Community Helper last edited by

        Nice one mate, that's cool. I was all hot to go with some spares I just happened to have but I think I'm going to have to reinstall the arduino IDE as it wont compile for me.

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

          Great job man!
          You were faster than me!
          I'll try to build my own version later (because I need to reorder some arduino and stuff to my new adress).
          I'd be happy to see the hardware, some pics you know.

          1 Reply Last reply Reply Quote 0
          • Lokki
            Lokki Community Helper last edited by

            @Nairod785 note that you can only use keyboard commands with the leonardo, with uno, mega etc you have to do some sneaky re-flashing of the usb interface chip in order to emulate a keyboard. If you're ordering a new arduino it might be easier with a Leonardo.

            1 Reply Last reply Reply Quote 0
            • M
              MacManus last edited by

              @Lokki what are your error messages in the arduino ide?
              @Nairod785 here are some pictures:


              1 Reply Last reply Reply Quote 1
              • Nairod785
                Nairod785 last edited by

                I know, the one I want to use, had the same ATMega 32U4, so it has the same abilities as a Leonardo. But smaller ;)

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

                  @MacManus, it's all sorted. Reinstalled the libraries again and it's happily compiling. Works well, nicely done.
                  @Nairod785, awesome. Sounds like I should try one of those, they're tiny.

                  1 Reply Last reply Reply Quote 0
                  • Lokki
                    Lokki Community Helper last edited by

                    As a suggestion for your code, it would be interesting if you could add a 'program' button for ring UIDs (enabled with pre-authorised master ring) and switch the code around a bit to grab the password from the ring?

                    1 Reply Last reply Reply Quote 0
                    • M
                      MacManus last edited by

                      Yeah - interesting idea - i will tinker with the code in my next spare time to improve the code.

                      1 Reply Last reply Reply Quote 0
                      • Lokki
                        Lokki Community Helper last edited by

                        Sounds cool. That way you could link 'allow authorisation' to UID and have the password grabbed from the ring so it's two part authentication. If you're really keen you could encrypt the stored password and have the arduino decrypt it.

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

                          Hehe this is cool, I actually wrote a bit about the security issues of doing this back in January after prototyping something similar myself.

                          Like @Lokki and others have said if you can resolve the security / implementation issues then you will be onto a huge winner with this! :)

                          1 Reply Last reply Reply Quote 0
                          • Lafunamor
                            Lafunamor Community Helper last edited by

                            Works fine for me. Thanks a lot!
                            I have a little question though
                            should the power (VCC pin) be connected to 3.3V or to 5V?
                            as you wrote

                            VCC <-> 3v3

                            but in the manual it says on page 5 for the Leonardo board you should connect it to 5V. As I'm new to those things I don't want to connect anything wrong and burn my board right after receiving it ;-)

                            Thanks for the help

                            1 Reply Last reply Reply Quote 0
                            • M
                              MacManus last edited by

                              it works both.
                              Connect it to 5v if it says in the manual.

                              1 Reply Last reply Reply Quote 0
                              • Lafunamor
                                Lafunamor Community Helper last edited by

                                OK, Thanks!

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