Nfc-ing a lock

I’ve read it her somewhere but I’ve not found the actual process, including parts and software, of getting a smart lock like the Danalock to act when a certain NFC card is swiped…

Hope the guys who’ve done it read this post!

I live in Spain and have a mortise for of lock…

So far I’ve only seen the Danalock as compatible… But if you have other options, feel free to write them here too!

Thanks!

Off the top of my head…

Use an spare “old” Android phone as the NFC reader. Lots of Apps available that can call Tasker upon sensing registered cards and then it uses SmartThings App to open lock.

1 Like

Item checklist

SmartThings hub - check!
Old Android - check!
NFC card - check!
Tasker app on old phone - check!
NFC to Bluetooth or microusb interface - failed!

Any idea how to get NFC to the old phone? I once saw a Bluetooth/NFC device but it wasn’t available to regular consumers… :cry:

I don’t know about Spain.

In the US, most android phones sold in the last two years have an NFC chip and reader built in, that’s how Google Pay works. Nothing to do with bluetooth. So you just pick an app you like.

1 Like

Spain is waaaaay behind in that sense… Ooh well… I’ll have to keep looking for a solution…

Thanks!!!

Bingo!!!

I had it there all the time!

http://thinkmakelab.com/2014/10/22/rfid-and-smartthings-how-to/#more-213

Now if only @juano2310 would help in pointing out which arduino to get… That would be awesome…

And if he or anyone can then help creating a smartapp that will unlock a given lock if x cards show up…

Ahhh… Wish I knew how to code in groovy…

Any cool tutorials out there?

I hesitate to recommend any project that requires the ThingShield because those are frequently out of stock for a long time. I guess it would be a very helpful project for someone to create a WiFi (LAN) based library and Device Handler.

Anyhow… You can start learning Groovy for SmartApps and Device Handlers by following the new SmartThings documentation, as they’ve really improved over the past few months. This project won’t require too complicated code.

One common starting place is also:
http://learnxinyminutes.com/docs/groovy/

And Google: “Groovy web console”.

And drop me a PM anytime with questions.

1 Like

Hi @danielccm,
I did an integration, for an other project, using a https://store.particle.io/?product=particle-photon and a NFC reader. It works great with SmartThings. I can try to dig the code if you are interested :slight_smile:

3 Likes

@juano2310, which hardware did you use for the NFC reader?

1 Like

You can use any NFC I2C or UART reader.
For my project I used this one http://www.stronglink-rfid.com/en/rfid-modules/sl030.html

5 Likes

Mine is more of a mid term project but yeah! Would be cool to see the code! Thanks!

@juano2310 I was researching for NFC and ST integration and i ran across your post here on this thread.
I am trying to use an NFC reader that when approached by an NFC ring will turn a switch off that controls a magnet lock. I am pretty sure it needs a NFC reader and something in between ST and the reader such as a Raspberry Pi or a ESP8266 or a Photon in your case ( i have personally never used a Photon) but i will be very interested on how to achieve this. Please let me know if you have any pointers for me it is beyond my programming capabilities to write a SmartApp that will store nfc values and match them when scanned from a server of sorts and than react to i.
I did not mention that i have achieved this with my android phone already with Josh’s help and SharpTools where you approach the phone that you carry to a static nfc than the phone through tasker takes care of the rest but i want to do it with the reader being static and other people to use their nfc tags as they get close to it.
let me know if you can help anything is greatly appreciated
Denis

Hi Denis!
I used a particle Photon and a http://www.stronglink-rfid.com/en/rfid-modules/sl030.html

Photon to SL030 wiring:

  • A3/TAG 5
  • A4/SDA 3
  • A5/SCL 4
  • 5V -
  • GND 6
  • 3V3 1

Here is the code I used to capture the ID :slight_smile: If I’m correct you should see the ID in particle console. There is an IFTTT and SmartThings integration, I imagine you can open an lock or turn a light on with this :slight_smile:

int led = D7; 
int TAG = A3; 

char* mifare[] = { "1K", "Pro", "UltraLight", "4K", "ProX", "DesFire" };

void setup()
{
  // Init serial port to host and I2C interface to SL018/SL030
  Serial.begin(19200);
  Wire.begin();

  // Initialize D0 pin as an output
  pinMode(led, OUTPUT);
  pinMode(TAG, INPUT);
  
  // Prompt for tag
  Serial.println("Show me your tag");
}

void loop()
{
  // Wait for tag
  //while(digitalRead(TAG));
  if (digitalRead(TAG) == LOW) {   
    // Read tag ID
    readID();
  } 
  // Wait until tag is gone
  //while(!digitalRead(TAG));
}

int readID()
{
  digitalWrite(led, HIGH);
  
  // Send SELECT command
  Wire.beginTransmission(0x50);
  Wire.write(1);
  Wire.write(1);
  Wire.endTransmission();
  
 // Wait for response
  while(!digitalRead(TAG))
  {
    // Allow some time to respond
    delay(5);
    String ID;
    
    // Anticipate maximum packet size
    Wire.requestFrom(0x50, 11);
    if(Wire.available())
    {
      // Get length of packet
      byte len = Wire.read();
      
      // Wait until whole packet is received
      while(Wire.available() < len)
      {
        // Quit if no response before tag left
        if(digitalRead(TAG)) { return 0; digitalWrite(led, LOW);}
      }

      // Read command code, should be same as request (1)
      byte command = Wire.read();
      if(command != 1) { return -1; digitalWrite(led, LOW);}
      
      // Read status
      byte status = Wire.read();
      
      switch(status)
      {
        case 0: // Succes, read ID and tag type
        {
          len -= 2;
          // Get tag ID
          while(--len)
          {
            byte data = Wire.read();
            
            if(data < 0x10) {
                Serial.print(0);
                ID += "0"; 
            }    
            
            ID += String(data);
            Serial.print(data, HEX);
          }


          Serial.println(ID);
          Spark.publish("update", ID);
          
          // Get tag type
          byte type = Wire.read();
          if(type > 0 && type < sizeof(mifare))
          {
            Serial.print(" Mifare ");
            Serial.print(mifare[type - 1]);
          }
          Serial.println();
        }
        digitalWrite(led, LOW);
        delay(700);
        return 1;

      case 0x0A: // Collision
        Serial.println("Collision detected");
        break;

      case 1: // No tag
        Serial.println("No tag found");
        break;

      default: // Unexpected
        Serial.println("Unexpected result");
      }
      digitalWrite(led, LOW);
      return -1;
    }
  }
  // No tag found or no response
  digitalWrite(led, LOW);
  return 0;
}
1 Like

Thank you fr your reply buddy
i am going to order the parts and try it out
i will e bothering you some more if i get stuck please forgive me LOL :slight_smile:
Denis

No problem at all! I’m here to help :slight_smile:

@juano2310 Ok so i just received the Photon in the mail and i am fixing to order the reader.
I do have 2 preliminary questions is the reader device in your post capable of NFC or is it RFID only??

I want to be able to use something like this https://www.amazon.com/gp/product/B07BDJ6FPD/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

So if i were to buy this reader do you think it will work the same with your code or not really ??? http://www.stronglink-rfid.com/en/rfid-modules/sl060.html

My other question is this : I was reading through your Proton code trying to understand it but with my limited coding ability i was unable to fully comprehend it …what i want it to do is this: If one of 5 rfid rings or tags that i have 1 of each of my family members get scanned than send a message to IFTTT to tell SmartThings to open lock X.

Is that something that the code you have written can do and where do i enter those tag values??

I am really excited about getting this going :slight_smile:
Denis

Hi! The Stronglink module is a NFC Reader/Writer Module SL060 so I can definitely do anything you need regarding NFC/RFID.

The only consideration is to make sure that both the RFID device and your reader are in the same frequency. For example the reader works at 13.56MHz and support all this tags MIFARE Ultralight®, NTAG203, MIFARE Mini, MIFARE Classic® 1K, MIFARE Classic® 4K, FM11RF08, DESFire®.

After looking at the ring that you shared on the comments it looks like it is compatible.

I think that is the same reader I used and for sure the same communication protocol so yes that reader should work with my code.

Regarding the code modification the easiest way would be to have an array with all the IDs that are allowed and if it match send the command :slight_smile:

I would recommend to start the project and we can work on the details later!
Happy holidays!

OK very nice and thank you :slight_smile: so to recap … i should order the SL060 NFC/RFID reader/writer and not the SL030 that you mentioned in the first post which i think is only RFID

Thanks again
Merry Christmas and Happy New years
Denis

For the projects I worked on the SL030 was more than enough. The ring should work with both. RFID is NFC but NFC can also mean that you can read other data like an URL or contact information.
That said if there isn’t a significant price difference and you don’t care about being energy efficient the SL060 sound like a good idea.

Ahhh thank you for your input … we do not need no URL or anything like that so i am ordering the SL030 :slight_smile:
Talk to you soon
Happy new year
Denis