💬 RFID Lock Sensor


  • Admin

    This thread contains comments for the article "RFID Lock Sensor" posted on MySensors.org.



  • Hi Hek,
    Thanks for sharing. It looks like a useful addition to my openhab system.
    Can you tell me if it is possible to WRITE to the cards and tags? Some of them are being sold as 'white' cards. I am worried I have to program the tags myself.


  • Admin

    Yes, but you would need a re-writable tag. Here's an example:

    http://www.allaboutcircuits.com/projects/read-and-write-on-nfc-tags-with-an-arduino/



  • @hek
    Thanks for quick reply. Is your example Mifare One S51 readonly?



  • This post is deleted!


  • Hi, I have a MFRC522 module, and I would like to implement it with 2.0 library. could I use this code?



  • I think this needs an update... The declaration is not complete for all users I think!


  • Mod

    @miro could you describe the problem you are experiencing and what you expected to happen?



  • @mfalkvidd

    I have followed the guide here (https://www.mysensors.org/build/rfid) to the letter. Yes, it could be me that have problems but this isn´t so hard project. Feels like something is missing?

    In the description it says:

    "To find out the unique ID of your tag just run the example while looking at serial monitor. Hold tag in front of reader and your identifier should pop up."

    This I did, but the monitor don`t show anything, just this

    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 255-255-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
    

    ... And yes, I have switched the little pin to I2C on my PN532 RFID reader.


  • Mod

    @miro the node is unable to connect to your gateway. What type of gateway are you using? Could you post the debug log from the gateway?



  • @mfalkvidd I`m using nano as serial GW. I didn´t have any trouble with GW for a long time now.

    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSM:RADIO:OK
    0;255;3;0;9;TSM:GW MODE
    0;255;3;0;9;TSM:READY
    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.0.0
    0;255;3;0;9;No registration required
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
    

    Should I install some XML in my vera edge to get this sensor to work?
    If I read the guide for this I will take it as GW has nothing to do with RFID until I have set the key code for the tags in the scetch and after that I implement the sensor to my vera?



  • It was just that easy as a broken radio. Thank you for your help to get me think in other ways 🙂


  • Mod

    Great work @miro, thanks for reporting back.



  • Has anyone got this http://www.ebay.com/itm/271316626820?rmvSB=true to work with NFC and Android phone?



  • Hi all,
    I can not get status of my doorlock node... begging for help! 😉
    Got myself bits and pieces as per "build" page :

    • arduino micro
    • NRF24
    • PN532
    • relay
      Raspberry SGtw works fine with another node (temp, motion and hum)
      RFID node "speaks" with Raspberry as follows (IDE serial monitor) :
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=10)
    TSM:FPAR
    TSP:MSG:SEND 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-10 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=10)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:MSG:READ 0-0-10 s=255,c=3,t=25,pt=1,l=1,sg=0:1
    TSP:MSG:PONG RECV (hops=1)
    TSP:CHKUPL:OK
    TSM:UPL:OK
    TSM:READY
    Found NFC chip PN532
    Firmware ver. 1.6
    close lock
    NODE:!REG
    TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    TSP:MSG:SEND 10-10-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
    TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
    TSP:MSG:READ 0-0-10 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    TSP:MSG:READ 0-0-10 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=11,pt=0,l=9,sg=0,ft=0,st=ok:RFID Lock
    TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.0
    TSP:MSG:SEND 10-10-0-0 s=1,c=0,t=19,pt=0,l=0,sg=0,ft=0,st=ok:
    Request registration...
    TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
    TSP:MSG:READ 0-0-10 s=255,c=3,t=27,pt=1,l=1,sg=0:1
    Node registration=1
    Init complete, id=10, parent=0, distance=1, registration=1
    Found tag id: 0x35,0xA8,0xF5,0xAA,0x00,0x00,0x00
    open lock
    TSP:MSG:SEND 10-10-0-0 s=1,c=1,t=36,pt=1,l=1,sg=0,ft=0,st=ok:1
    

    That's my things file :

    
    Bridge mysensors:bridge-eth:gateway [ ipAddress="127.0.0.1", tcpPort=5003, sendDelay=200 ] {
            lock            hallRfid01              [ nodeId="10", childId="1" ]    }
    

    And my items file :

    Contact         hallRfid01      "Front door lock"                 <frontdoor>             (gHall)                                 { channel="mysensors:lock:gateway:hallRfid01:lock" }
    

    This is the openhab "mysensors log tail" when powering node on (presenting to gateway)

    06:48:57.990 [DEBUG] [al.protocol.ip.MySensorsIpConnection] - Bridge is connected, connection skipped
    06:49:05.585 [DEBUG] [rs.internal.protocol.MySensorsReader] - 10;255;0;0;17;2.0.0
    06:49:05.597 [ERROR] [rs.internal.protocol.MySensorsReader] - (java.lang.IllegalStateException: Could not update state, because callback is missing) on reading from serial port, message: class org.openhab.binding.mysensors.internal.protocol.ip.MySensorIpReader
    06:49:05.600 [DEBUG] [rs.internal.protocol.MySensorsReader] - 10;255;3;0;6;0
    06:49:05.603 [DEBUG] [al.protocol.ip.MySensorsIpConnection] - I_CONFIG request received from M, answering: (is imperial?)false
    06:49:05.606 [DEBUG] [rs.internal.protocol.MySensorsWriter] - Sending to MySensors: 10;255;3;0;6;M
    06:49:05.609 [ERROR] [rs.internal.protocol.MySensorsReader] - (java.lang.IllegalStateException: Could not update state, because callback is missing) on reading from serial port, message: class org.openhab.binding.mysensors.internal.protocol.ip.MySensorIpReader
    06:49:05.632 [DEBUG] [rs.internal.protocol.MySensorsReader] - 10;255;3;0;11;RFID Lock
    06:49:05.636 [ERROR] [rs.internal.protocol.MySensorsReader] - (java.lang.IllegalStateException: Could not update state, because callback is missing) on reading from serial port, message: class org.openhab.binding.mysensors.internal.protocol.ip.MySensorIpReader
    06:49:05.679 [DEBUG] [rs.internal.protocol.MySensorsReader] - 10;255;3;0;12;1.0
    06:49:05.683 [ERROR] [rs.internal.protocol.MySensorsReader] - (java.lang.IllegalStateException: Could not update state, because callback is missing) on reading from serial port, message: class org.openhab.binding.mysensors.internal.protocol.ip.MySensorIpReader
    06:49:05.684 [DEBUG] [rs.internal.protocol.MySensorsReader] - 10;1;0;0;19;
    06:49:05.696 [DEBUG] [ternal.handler.MySensorsThingHandler] - Setting last update for node 10 to 2016-12-19T06:49:05.687+0000
    06:49:05.712 [INFO ] [marthome.event.ItemStateChangedEvent] - mysensors_lock_gateway_hallRfid01_lastupdate changed from 2016-12-18T21:14:31.444+0000 to 2016-12-19T06:49:05.687+0000
    06:49:07.991 [DEBUG] [al.protocol.ip.MySensorsIpConnection] - Bridge is connected, connection skipped
    06:49:17.992 [DEBUG] [al.protocol.ip.MySensorsIpConnection] - Bridge is connected, connection skipped
    

    And last when RFID tag is presented to reader

    06:49:47.996 [DEBUG] [al.protocol.ip.MySensorsIpConnection] - Bridge is connected, connection skipped
    06:49:49.305 [DEBUG] [rs.internal.protocol.MySensorsReader] - 10;1;1;0;36;1
    06:49:49.310 [ERROR] [rs.internal.protocol.MySensorsReader] - (java.lang.IllegalStateException: Could not update state, because callback is missing) on reading from serial port, message: class org.openhab.binding.mysensors.internal.protocol.ip.MySensorIpReader
    06:49:57.998 [DEBUG] [al.protocol.ip.MySensorsIpConnection] - Bridge is connected, connection skipped
    06:49:58.567 [DEBUG] [rs.internal.protocol.MySensorsReader] - 10;1;1;0;36;0
    06:49:58.572 [ERROR] [rs.internal.protocol.MySensorsReader] - (java.lang.IllegalStateException: Could not update state, because callback is missing) on reading from serial port, message: class org.openhab.binding.mysensors.internal.protocol.ip.MySensorIpReader
    06:50:07.999 [DEBUG] [al.protocol.ip.MySensorsIpConnection] - Bridge is connected, connection skipped
    

    On the bright side, the relay attached to arduino opens and closes as i present RFID tag in front of reader... 🙂

    Unfortunately i don't get the lock status (locked or unlocked) in PaperUI nor openHab for iOS...
    I don't get "open" or "closed" status as i do with motion sensor. I also don't get any change to the door icon (door_closed and door_opened)

    Thanks a lot for your help 🙂

    Best Regards,

    Ben



  • @miro said in 💬 RFID Lock Sensor:

    @mfalkvidd

    I have followed the guide here (https://www.mysensors.org/build/rfid) to the letter. Yes, it could be me that have problems but this isn´t so hard project. Feels like something is missing?

    In the description it says:

    "To find out the unique ID of your tag just run the example while looking at serial monitor. Hold tag in front of reader and your identifier should pop up."

    This I did, but the monitor don`t show anything, just this

    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 255-255-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
    

    ... And yes, I have switched the little pin to I2C on my PN532 RFID reader.

    @mfalkvidd said:

    @miro the node is unable to connect to your gateway. What type of gateway are you using? Could you post the debug log from the gateway?

    I had the same question as @miro however my node is communicating and connected to the gateway correctly.
    I only see the mysensors radio debug info on the serial monitor, and no application serial prints eg (Serial.print("Couldn't find PN53x board");) doesn't show up in the serial monitor at all.
    Neither does "Found NFC chip" or anything else in the main code...
    My radio is working and as I said no errors in the radio debug.
    Is the main application even running?
    I cannot get it to scan a card at all.

    However if I comment out the <MySensors.h> library along with its dependencies in the main program, it works and I can scan cards, and get the Uid from them...

    Any clues?
    Thanks.



  • Hi.

    Started using mysensors with RFID readers.
    I have a suggestion by I am bad code programmer.

    Is better to save the RFID tag key in the EPROM approved.
    And If you want to add a key/tag with special tag which add new or remove tag.

    What do you think?



  • Hi can you modify scetch for spi interface??



  • PN532.h: No such file or directory
    Is driving me crazy ... I have Downloaded the zip file and extracted the 4 folders(PN532, PN532_SPI, PN532_I2C and PN532_HSU) into Arduino's libraries.
    Same error.
    I've tried adding the library as .zip : it says not a valid library file
    what could be the problem ?



  • @DirkB19
    Nevermind, I placed the PN532 related folders into the C:\Program Files (x86)\Arduino\libraries folder and now it works.
    Before, I placed them into the \libraries folder where all my sketches are which does not work for this libary .



  • @Michel---It said in 💬 RFID Lock Sensor:

    Hi, I have a MFRC522 module, and I would like to implement it with 2.0 library. could I use this code?

    I would also really like to know how to use a RFID-RC522 module instead of the PN532 NFC RFID Reader/Writer Module used in the example! The RC522 is included in a lot of different beginner kits.


  • Contest Winner

    It would make much sense if this example used signing.



  • Hallo,
    I like this example of RFID Lock Sensor.
    But I`m not able to change it for my aim myself (just a user and beginner).
    Here my imaginations:

    1. There should be always a default after switching on, after calling seriell monitor or after power cut.
      This should be "Sensor Locked"
    2. Every change to "Sensor open" should be for only let`s say 3 seconds or another adjustable time and than fall back to Default = "Sensor Locked" . Time enough e.g. to open the door or s.e.
      Is there anybody who can give me some hints how to ad this features into the given sketch?
      Thank You in advance
      Jopebe


  • This post is deleted!


  • @jopebe said in 💬 RFID Lock Sensor:

    1. Every change to "Sensor open" should be for only let`s say 3 seconds or another adjustable time and than fall back to Default = "Sensor Locked" . Time enough e.g. to open the door or s.e.
      Is there anybody who can give me some hints how to ad this features into the given sketch?
      Thank You in advance
      Jopebe

    Hello,
    i have the same problem.
    Does anyone have a solution? The relay should only put on for 3 seconds.
    Greeting Holger


Log in to reply
 

Suggested Topics

  • 3
  • 347
  • 584
  • 5
  • 10
  • 164

4
Online

11.4k
Users

11.1k
Topics

112.7k
Posts