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

    Switch Light with your NFC Ring

    Ideas for using NFC Rings
    nfc ring arduino
    3
    6
    10609
    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

      So here's a video of my prototype for a light switch with Arduino.
      Code, Tutorial and Images are following.
      https://mediacru.sh/uuF-Ulrhdwey

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

        Hi @MacManus that's a great prototype you've got going there, I notice you're having a bit of trouble using the PN532 v2 reader though. I really recommend the Elechouse V3 PN532 reader - it has far better sensitivity and can actually distance read the rings (short distance, but it'll allow you to put the reader in a housing and still read the ring).

        Here's a link to the reader that we recommend, it hooks up just the same as the one you've currently got but does a far better job of it - http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=90_93&products_id=2242

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

          Hi @Lokki thanks - I already ordered an Elechouse V3 Reader, but till it arrives i build the prototype with my v2 reader.

          So here's an Image:
          Light Switch

          The parts list:

          • An Arduino
          • Elechouse PN532 reader (V3 recommended - see @Lokki comment
          • 433Mhz Transmitter (e.g. from eBay)
          • a working outlet device (see here)

          And the source 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
          
          RCSwitch Library: https://code.google.com/p/rc-switch/
          
          */
          /**************************************************************************/
          
          #include <RCSwitch.h>
          
          RCSwitch mySwitch = RCSwitch();
          
          
          #include <Wire.h>
          #include <PN532_I2C.h>
          #include <PN532.h>
          
          PN532_I2C pn532i2c(Wire);
          PN532 nfc(pn532i2c);
          
          
          void setup(void) {
            mySwitch.enableTransmit(10);
          
            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 == "YourFrontRingUID"){
                Serial.println("public");
                mySwitch.switchOn("11111", 1);
              }
              else if (ringUid == "YourBackRingUID"){
                Serial.println("private");
                mySwitch.switchOff("11111", 1);
              }
            }
          }
          

          The schematics, an arduino diagram and a little howto is following.

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

            Now, here we go:

            Diagram

            Short Description:

            Connect the PN532 Module as follows:

            PN532 Module <-> Arduino

            GND <-> GND
            VCC <-> 3v3
            SDA <-> SDA (on Arduino Uno A4)
            SCL <-> SCL (on Arduino Uno A5)

            For TWI Pins of other Boards, see Arduino Boards Page

            Connect the 433Mhz Transmitter as follows:

            433Mhz Transmitter <-> Arduino

            DATA <-> Data Pin (i use Pin 10)
            VCC <-> 3v3
            GND <-> GND

            Do you have any questions? Feel free to ask!

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

              Interesting. Would be cool to see more pictures :)

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

                Here are more Pictures:



                Do you want pictures of anything in particular?

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