Spark Door access control system

Hi Spark community,

I just want to share with you my Spark Core project.
I created a Door access control system with the Spark Core. The door can be oppened by a secured web page, an Android widget or with a RFID tag where the reader is next to the bell button.

For this project I used:

  • A Spark Core
  • The Spark Relay Shield
  • A RDM6300 which is a 125kHz RFID cardreader (supporting EM4100 tags)

The RDM6300 sends the informations over Serial1 to the Spark Core.

  • Pin1 of P1 is connected to RX on the Spark Core.
  • It is connected trough a voltage divider of 10k Ohms (R1) and 20k Ohms (R2), because the Spark Core serial port is working with 3,3V and the RDM6300 with 5V TTL. On this photo, VCC would be the RDM6300 TX and Vout the Spark Core RX.
  • Pin4 of P1 is connected to Gnd on the Spark Core.
  • Pin5 of P1 is connected to Vin (+5V) on the Spark Core.
  • Pin 1 and 2 of P2 are connected to the RFID antenna.
  • The other pins are not used.

The door latch is connected to the Relay 1 of the Relay Shield.
Which is unlocked by supplying 12V AC to it.


And finnaly the Spark Core with the Relay Shield is placed in the ceiling above the door.

Cover off.


The door can be opened via a Android Widget via a simple POST request to the Spark Cloud or the same way on a web page.

The door can also be opened via the RFID tag reader next to the bell button.

The Spark Door code for the Spark Web IDE can be found: Here.

10 Likes

Awesome! This is maybe a silly question, do you have any info on what electronic door latch you used?

That’s awesome @Dragonsshout! With all these Ideas I may need a few more :spark:s…

Thank you guys! :smile: :smile:

@Dave The door latch was already incorpored to the door by the manufacturer. The door is a Hörmann door.
I don’t find either a lot of informations in the Door manual.
I don’t have more informations than that. Sorry.

@shocku992 Sure! The possibilities are endless! I want to put :spark:s everywhere! :smiley:

1 Like

hi Dragonsshout!

Really nice project! Congratulations!

I tried to use your code to make some testing with it, but the web ide is dropping error if i copypaste the shared code. (especially the includes, etc…)

How could i make it work, can you please help me?

Thanks in advance!

Hi @Noten!

Thank you very much! :smiley:

Sorry it was my fault, there was a missing */ on line 8.
But you can remove the following lines if your are compiling with the Spark Web IDE:

 /* Includes ------------------------------------------------------------------*/
#include "application.h"

and

/* Function prototypes -------------------------------------------------------*/
int openDoor(String command);
bool comparetag(int tag1[14], int tag2[14]);
int checkmytags(int newtag[14]);
void readTags();

I need those lines, because I actually compiling the whole firmware on my computer.
Here is the Spark Door code for the Spark Web IDE. :wink:

1 Like

Awesome! This one worked!

Can’t wait to check it out with the door on the weekend :wink:

cheers!

You welcome :blush:

Happy hacking weekend :wink:

1 Like

Hey Dragonsshout!

Started to put things together, but unfortunately i stuck at some point, in your code, line 61:

while (Serial.read() != -1); // stops multiple reads

Are you sure it’s Serial, not Serial1? (Serial is the usb port, Serial1 is the rx)

Also when i wire things, the reader is just reading a bunch of 0s, instead of the actual rfid’s number. I’m not a pro in wiring things, i started to think maybe i didn’t connect the rfid reader and the spark properly, so here is what i did:

I. I’m using the ID12 tag with a breakout board:
breakout: https://www.sparkfun.com/products/8423

id12 tag: https://sparkfun.com/products/8419

II. connected the spark with the id12 breakout on the following way: (rfid -> spark)
pin 1 -> gnd
pin 2 -> 3v3
pin 11 -> 3v3 (I hope it works with 3v3 as well, not just 5v, this is what they are saying on the website)
pin 9 -> rx
pin 7 -> gnd

Image on the same:

Maybe I’m not connecting the correct pins to the correct pins, tried to mimic this one http://www.instructables.com/id/Reading-RFID-Tags-with-an-Arduino/ but it’s also not working for me :frowning:

So if you/anyone could help first checking whether the wiring is ok, that would be a huge help for me.

Thanks in advance, and have a happy weekend sparkers :smile:

regards,
Noten

Hey @Noten!

You’ve right! It’s Serial1 and not Serial. It was a bad copy/paste sorry. The code was corrected on Pastebin.
Thank’s for the input!

The wiring seems to be correct, if it is really working with 3v3 as said on the website.
But after the datasheet it’s require a pull up resistor on pin 9.

Maybe that code can help you: ID12 code for Arduino, because my code is specific to the RDM6300 reader.

Have a nice weekend too :smile:

Please remove those two lines:

delay(200);
while (Serial1.read() != -1); // stops multiple reads

It make the code buggy. Actually I don’t know why, but I have to do some testing.

I tried with both with your code and with the other one from Arduino’s site, but Serial1.read() returns always just 0 for each characters.
So if i write Serial.println(Serial1.read()); the output is like this:
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Really don’t know what can be the issue, coz i followed the instructions from the table you linked (ASCII column). I assume it should write different numbers for different chars as it reads the rfid tag.

Tried even removing the delays and increased it, but same issue. 0s everywhere :frowning:

Did you add the 4k7 pull up resistor?

I didn’t add as under ASCII column it was not listed. Do you think that would do? Also the other problem is i don’t know what is that :S and how to wire it.

This means connecting the ID12 Pin 9 to VCC trough a 4k7 resistor.

But the pin 9 on the ID12 connects to the RX (Serial), not to the VCC i guess, also i can't see any VCC pin on the spark, only a VIN. I'm a bit confused, sorry :frowning:

If you don’t do that the Spark Core will read only zeros.
Maybe this can helps you to understand what a pull-up resistor is.

Sorry, VCC of the Spark Core is the Pin 3v3 for me or Pin11 on the ID12.

hey @Dragonsshout!

I think i made it work, thanks for your help!

I’m not sure, but i think my id12 rfid reader is not working properly, coz the values that it reads for the same card are always different. Wrote to the vendor, really not sure what’s going on with the reader.

Hopefully this will be sorted soon and can continue the project with the interesting part :smile:

Cheers,
Noten

Hey @Noten!

Nice! I’m glad that I could help you.

Maybe try to lower the resistor value. Instead of the 4k7 resistor put a 1k resistor, but not lower than 1k.
This will result that the voltage will going back faster to 3v3.

Regards,

DSS