Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. RFID v2

RFID v2

Scheduled Pinned Locked Moved My Project
12 Posts 4 Posters 4.0k Views 4 Watching
  • 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.
  • D Offline
    D Offline
    davedeluxe
    wrote on last edited by
    #3

    THANK YOU!!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #4

      Has anyone got this working.

      I have connected as instructed, in the sketch and upload the sketch from the link. But my sensor I just trying to connect.

      Starting sensor (RNNNA-, 2.0.0)
      TSM:INIT
      TSM:RADIO:OK
      TSP:ASSIGNID:OK (ID=1)
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      Starting sensor (RNNNA-, 2.0.0)
      TSM:INIT
      TSM:RADIO:OK
      TSP:ASSIGNID:OK (ID=1)
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      !TSM:FPAR:FAIL
      !TSM:FAILURE
      TSM:PDT
      TSM:INIT
      TSM:RADIO:OK
      TSP:ASSIGNID:OK (ID=1)
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      !TSM:FPAR:FAIL
      !TSM:FAILURE
      TSM:PDT
      

      can anyone help here?

      mfalkviddM 1 Reply Last reply
      0
      • ? A Former User

        Has anyone got this working.

        I have connected as instructed, in the sketch and upload the sketch from the link. But my sensor I just trying to connect.

        Starting sensor (RNNNA-, 2.0.0)
        TSM:INIT
        TSM:RADIO:OK
        TSP:ASSIGNID:OK (ID=1)
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        Starting sensor (RNNNA-, 2.0.0)
        TSM:INIT
        TSM:RADIO:OK
        TSP:ASSIGNID:OK (ID=1)
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        !TSM:FPAR:FAIL
        !TSM:FAILURE
        TSM:PDT
        TSM:INIT
        TSM:RADIO:OK
        TSP:ASSIGNID:OK (ID=1)
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        TSM:FPAR
        TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
        !TSM:FPAR:FAIL
        !TSM:FAILURE
        TSM:PDT
        

        can anyone help here?

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #5

        @fleshfear what do the logs from your gateway say?
        The node is onable to get a response from the gateway. See https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help for information on how to read the debug log.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #6

          im not getting anything from the logs on the gateway, so I seems that the node is not getting connected to the gateway.

          but if I swap the RFID with a pir instead same wiring and all, only added the wire to the pir and swapped the power wires to the pir. Then it works perfectly.

          The setup is:
          Arduino Pro Mini 328 3.3v
          NRF24L01+
          PN532 NFC RFID Reader/Writer Module V3
          1Pc DC-DC Boost Converter Step Up Module 1-5V to 5V 500mA

          and this is the sketch, where you can see the RFID should connect to A4, A5, which i have solder on to the pro mini.

          /**
           * The MySensors Arduino library handles the wireless radio link and protocol
           * between your home built sensors/actuators and HA controller of choice.
           * The sensors forms a self healing radio network with optional repeaters. Each
           * repeater and gateway builds a routing tables in EEPROM which keeps track of the
           * network topology allowing messages to be routed to nodes.
           *
           * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
           * Copyright (C) 2013-2015 Sensnology AB
           * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
           *
           * Documentation: http://www.mysensors.org
           * Support Forum: http://forum.mysensors.org
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * version 2 as published by the Free Software Foundation.
           *
           *******************************
           *
           * REVISION HISTORY
           * Version 1.0 - Henrik Ekblad
           * 
           * DESCRIPTION
           * RFID Lock sensor/actuator
           * 
           * Use RFID tag to lock/unlock a door or trigger a scene on your controller.
           * This example sketch allows you to add an optional relay or solenoid 
           * which can be activated/opened by RFID or controller.  
           *
           * Use the I2C wiring option for your RFID module and connect to the following Arduino pins.
           * 
           * RFID       Arduino
           * -----      -------
           * GND   ->   GND
           * VCC   ->   +5V
           * SCL   ->   A5
           * SDA   ->   A4
           * 
           * Use normal wiring for NRF24L01 radio
           * 
           * Attach a optional relay or solonoid lock to pin 4
           * http://www.mysensors.org/build/rfid 
           */
          
          // Enable debug prints to serial monitor
          #define MY_DEBUG 
          
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          //#define MY_RADIO_RFM69
          
          #include <SPI.h>
          #include <MySensors.h>  
          #include <Wire.h>
          #include <PN532_I2C.h>
          #include <PN532.h>
          
          
          // Add your valid rfid keys here. To find you your key just run sketch; hold your new RFID tag in fron ot the reader; 
          // and copy the key from serial output of this sketch.
          const uint8_t maxKeyLength = 7;
          uint8_t validKeys[][maxKeyLength] = {
                              { 0xB3, 0xC6, 0xD9, 0x80, 0x00, 0x00, 0x00 },
                              { 0, 0, 0, 0, 0, 0, 0 },    // ADD YOUR KEYS HERE!
                              { 0, 0, 0, 0, 0, 0, 0 }};
          int keyCount = sizeof validKeys / maxKeyLength; 
          
          
          #define CHILD_ID 10   // Id of the sensor child
           
          // Pin definition
          const int lockPin = 4;         // (Digital 4) The pin that activates the relay/solenoid lock.
          bool lockStatus;
          MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
          PN532_I2C pn532i2c(Wire);
          PN532 nfc(pn532i2c);
           
          void setup() {
            
            pinMode(lockPin, OUTPUT);
          
            nfc.begin();
            uint32_t versiondata = nfc.getFirmwareVersion();
            if (! versiondata) {
              Serial.print("Couldn't find PN53x board");
              while (1); // halt
            }
            Serial.print("Found NFC 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(0x3);
            
            // configure board to read RFID tags
            nfc.SAMConfig();
          
            lockStatus = loadState(0);    // Read last lock status from eeprom
            setLockState(lockStatus, true); // Now set the last known state and send it to controller 
          }
          
          void presentation()  {
            sendSketchInfo("RFID Lock", "1.0");
            present(CHILD_ID, S_LOCK);
          }
           
          void loop() {
            bool success;
            uint8_t key[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
            uint8_t currentKeyLength;                        // 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, &key[0], &currentKeyLength);
            
            if (success) {
              Serial.print("Found tag id: ");
              for (uint8_t i=0; i < currentKeyLength; i++) 
              {
                if (i>0) Serial.print(",");
                Serial.print("0x");Serial.print(key[i], HEX); 
              }
              for (uint8_t i=currentKeyLength; i < maxKeyLength; i++) 
              {
                Serial.print(",0x00"); 
              }
          
          
              Serial.println("");
          
              bool valid = false;
              // Compare this key to the valid once registered here in sketch 
              for (int i=0;i<keyCount && !valid;i++) {
                for (int j=0;j<currentKeyLength && !valid;j++) {
                  if (key[j] != validKeys[i][j]) {
                    break;
                  }
                  if (j==currentKeyLength-1) {
                    valid = true;
                  }
                }
              }
              if (valid) {
                // Switch lock status
                setLockState(!lockStatus, true);       
              }
              
              // Wait for card/tag to leave reader    
              while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength));
            } 
          } 
           
           
           
          // Unlocks the door.
          void setLockState(bool state, bool doSend){
            if (state) 
               Serial.println("open lock");
            else
               Serial.println("close lock");
            if (doSend)
              send(lockMsg.set(state));
            digitalWrite(lockPin, state);
            saveState(0,state);
            lockStatus = state;
          }
           
          void receive(const MyMessage &message) {
            // We only expect one type of message from controller. But we better check anyway.
            if (message.type==V_LOCK_STATUS) {
               // Change relay state
               setLockState(message.getBool(), false); 
            
               // Write some debug info
               Serial.print("Incoming lock status:");
               Serial.println(message.getBool());
             } 
          }
          
          
          
          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by A Former User
            #7
            This post is deleted!
            J 1 Reply Last reply
            0
            • ? A Former User

              This post is deleted!

              J Offline
              J Offline
              jeti
              wrote on last edited by
              #8

              @fleshfear sorry that i can not help, but i just ran into the very same issue... any solutions yet or at least reasons for the

              Couldn't find PN53x board
              
              ? 1 Reply Last reply
              0
              • J jeti

                @fleshfear sorry that i can not help, but i just ran into the very same issue... any solutions yet or at least reasons for the

                Couldn't find PN53x board
                
                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #9

                @jeti the first thing was not enough power to the radio, and i think the next thing is the I2C mode. But it seems that i have set that one up correctly also so im not sure now.

                Im download a raw PN532 Libary with exemples to see if it the board, or maybe something with mysensors.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #10

                  i got it working.

                  i sat the board in I2C Mode, channel1 = on and channel2 = off.
                  Then i powered the PN532 board on a external power source.

                  Before i did a step up to 5V, that was wrong it should only get 3.3V.
                  And the arduino GND should be connected to the external power sources GND as well, to make a common ground.

                  Hope it helps.

                  J 2 Replies Last reply
                  0
                  • ? A Former User

                    i got it working.

                    i sat the board in I2C Mode, channel1 = on and channel2 = off.
                    Then i powered the PN532 board on a external power source.

                    Before i did a step up to 5V, that was wrong it should only get 3.3V.
                    And the arduino GND should be connected to the external power sources GND as well, to make a common ground.

                    Hope it helps.

                    J Offline
                    J Offline
                    jeti
                    wrote on last edited by
                    #11

                    @fleshfear great! I will try it as soon as i can!

                    1 Reply Last reply
                    0
                    • ? A Former User

                      i got it working.

                      i sat the board in I2C Mode, channel1 = on and channel2 = off.
                      Then i powered the PN532 board on a external power source.

                      Before i did a step up to 5V, that was wrong it should only get 3.3V.
                      And the arduino GND should be connected to the external power sources GND as well, to make a common ground.

                      Hope it helps.

                      J Offline
                      J Offline
                      jeti
                      wrote on last edited by
                      #12

                      @fleshfear: ok got it also working. Thanks. mine works with 3.3V and 5V

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      26

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular