Switch Light with your NFC Ring

  • So here's a video of my prototype for a light switch with Arduino.
    Code, Tutorial and Images are following.

  • Community Helper

    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

  • 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) {
      uint32_t versiondata = nfc.getFirmwareVersion();
      if (! 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.
      // configure board to read RFID tags
      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(uid[i], HEX);
          ringUid += String(uid[i], HEX);
        //Serial.println(ringUid + "\n");
        if(ringUid == "YourFrontRingUID"){
          mySwitch.switchOn("11111", 1);
        else if (ringUid == "YourBackRingUID"){
          mySwitch.switchOff("11111", 1);

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

  • Now, here we go:


    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!

  • Interesting. Would be cool to see more pictures :)

  • Here are more Pictures:

    Do you want pictures of anything in particular?