DIY electronic RFID Door Lock with Battery Backup

Status
Not open for further replies.

Elmue

Well-known member
Hello

I want to present my latest electronic development to the public:

A do-it-yourself electronic RFID door opener.

You just mount the Adafruit PN532 RFID reader on the inside of the door which reads the RFID card through the closed door.

Mifare.jpg

A powerfull backup battery assures that the device is working even after a power failure of several days.
The Teensy microprocessor detects when the battery needs charging.

Provides a very easy to use interface accessible through an USB cable with a terminal program which lets you add or remove users within a few seconds.
You can store 64 users with their card ID's in the EEPROM of the microprocessor.

If you lose the RFID card or token, you can easily remove the old one and add the new one without changing the lock.

I designed a layout for the board that can be soldered by an electronics beginner

You find circuit diagram, layout diagram, source code and a detailed description in my article on Codeproject:
http://www.codeproject.com/Articles/1096861/DIY-electronic-RFID-Door-Lock-with-Battery-Backup
 
Seems like a nice project. I understand it is supposed to be short range like 10 cm. But if you carry this card / keyfob with you everywhere, I wonder if it is possible for the well-equipped burglar to read it out remotely as you pass by, then construct his own passcard. Or is the readout process encrypted?

It sounds like you are cycling the lead-acid battery down to 12.0 V every 4 days. That will result in much shorter battery life than if you simply keep it on a float charge all the time, about 13.6 V (the exact optimum float voltage changes slightly depending on battery details, and the ambient temperature). For best lifetime (avoiding "sulfation"), you should not routinely discharge lead-acid batteries below 50% of capacity and a terminal voltage of 12.0 V is well below 50%.
 
Last edited:
Hello JBeale

Thanks for sharing your thoughts.

> ...to read it out remotely as you pass by...

It is not very probable that a thief runs behind you in the street and puts a reading device at a near distance of your pocket to read your card and then clone your card to later break into your house.

But you are right: the current concept would require that you buy a "Stainless Steel Wallet" (search for that in Google Images) to avoid that scenario.
This is a wallet with a metal shield that blocks any HF frequency to arrive at the RFID cards in your pocket.

As Mifare Classic has been broken I'm currenly working on a second version that uses Desfire EV1 cards with AES encryption.
I will store an encrypted value in the EEPROM of the card that cannot be read without knowing the 128 bit encryption key.
If a clone of your card does not have the same value the door will not open.

> .... all the time, about 13.6 V ....

Do you have a link with more details about this ?

I decided against a circuit that permanently loads the battery because I don't want that my device permanently consumes energy from the power line (for energy saving).

You can configure the thresholds for the battery voltage in source code.
You could configure an ON-threshold and an OFF-threshold for the charger that lies near to 13,6V.

But I think that this is not a good idea because (as I wrote in the article) the battery has a very non-linear voltage curve.
After charging it to 14,0 Volt the voltage falls very quickly to 12,8V (in a few hours) and then it falls very slowly to 12,0V (within some days).
So if you would try to hold the voltage near 13,6V the charger would turn on very frecuently.
 
Last edited:
I decided against a circuit that permanently loads the battery because I don't want that my device permanently consumes energy from the power line (for energy saving). [...] After charging it to 14,0 Volt the voltage falls very quickly to 12,8V (in a few hours) and then it falls very slowly to 12,0V (within some days). So if you would try to hold the voltage near 13,6V the charger would turn on very frequently.
Neglecting quiescent current losses in the charger itself, you will use less power overall running the battery at a constant float voltage near 13.6 V or 2.266 volts per cell (where it draws very little current), than you will constantly charging and discharging, because the battery charge/discharge cycle loses between 10 and 30% of the energy. In other words if you use 10 watt-hours of energy charging your battery, you will only get maybe 8 watt-hours out before it must be recharged again. With very slow charge rates I have seen up to 95% efficiency reported, but anyway maximum lifetime of lead-acid batteries will be when they are not discharged.

Yes, lead-acid batteries have a "surface charge" right after charging to 14 V and that drops quickly below 13 V as you start to use it, but that doesn't affect the notes about total energy usage above.

http://batteryuniversity.com/learn/article/can_the_lead_acid_battery_compete_in_modern_times
A periodic fully saturated charge is essential to prevent sulfation and the battery must always be stored in a charged state. Leaving the battery in a discharged condition causes sulfation and a recharge may not be possible.

Finding the ideal charge voltage limit is critical. A high voltage (above 2.40V/cell) produces good battery performance but shortens the service life due to grid corrosion on the positive plate. A low voltage limit is subject to sulfation on the negative plate. Leaving the battery on float charge for a prolonged time does not cause damage.

Lead-acid does not like deep cycling. A full discharge causes extra strain and each cycle robs the battery of some service life. This wear-down characteristic also applies to other battery chemistries in varying degrees. To prevent the battery from being stressed through repetitive deep discharge, a larger battery is recommended. Lead-acid is inexpensive but the operational costs can be higher than a nickel-based system if repetitive full cycles are required.

Depending on the depth of discharge and operating temperature, the sealed lead-acid provides 200 to 300 discharge/charge cycles. The primary reason for its relatively short cycle life is grid corrosion of the positive electrode, depletion of the active material and expansion of the positive plates. These changes are most prevalent at higher operating temperatures. Cycling does not prevent or reverse the trend.
 
Last edited:
Hello

Thanks for the link.

1.)
Where did you find that "12.0 V is well below 50%"

2.)
So what about starting to charge at 13,0V and stopping to charge at 14,0V ?
This would be better for battery life time ?
 
Here is one curve for open-circuit voltage vs. % charge, In this case 12.0 V => 35 % full. http://homepages.which.net/~paul.hills/Batteries/Image132.gif you can do a search for lead-acid discharge curve and find more.
If you have a high discharge current, the number changes, but I don't think that's the case here.

Yes you could cycle the battery between 13.0 and 14.0 V, although if you spend too much time at 14.0 V you will also shorten the lifetime at least a little bit. Maybe not significantly, but AFAIK the optimum point really is around 13.6 V, assuming you are near 25 C.

from: http://www.powerstream.com/SLA.htm
Cyclic versus Standby charging.
Some lead acid batteries are used in a standby condition in which they are rarely cycled, but kept constantly on charge. These batteries can be very long lived if they are charged at a float voltage of 2.25 to 2.3 volts/cell (at 25 degrees C) (13.5V to 13.8V for a 12V battery).
 
Last edited:
I was also wondering about having the charging circuit versus using a simple trickle charger.

For example I have a gate at the entrance to our property that runs on a deep cycle 12v battery. The battery is probably a little bigger than your motorcycle battery. The company who installed the gate simply placed a small trickle charger on the battery, which is always running.

So far this battery has worked for maybe 8 years. I purchased a backup battery for it a couple of years ago, but so far have not needed it...
 
Hello JBeale

Thanks for the infos.
Following the diagram the battery is at 100% of charge at 12,8V.
So with 13,6V it would be above 100%.

> Yes you could cycle the battery between 13.0 and 14.0 V

I tested that yesterday.
At this voltage the impedance of the battery is already so extremely high that the charger relay turns on and after 30 seconds the voltage reaches 14,0V.
Then it turns off and after another 30 seconds it already has fallen to 13,0V.
It is impressing how fast the voltage changes. The relay is switching twice per minute!

I don't know if this mode would shorten the life of the battery?



Hello Kurt

> I was also wondering about having the charging circuit versus using a simple trickle charger

I decided this for 3 reasons:

Because I want the electronic to be as robust and long living as possible.
I have repaired electronic devices for many many years and my experience is that all semiconductors that work with high current and that become hot will have a short life.

So if I use a linear regulator that permanently delivers 13,6V to the battery, this chip will be the first to die after a few years.
On the contrary a relay is so robust that it will live many many years.

Additionally my circuit is simple and I can control everything in software in the microcontroller.
An anlog regulator for 13,6V would have to be adjusted externaly.

Another reason was that with my design the power consumption from the power line will be exactly zero for 3-4 days.
On the other hand a trickle charger consumes energy permanently.
The transformator and the analog regulator become worm and this energy is lost.

But I will think about it.
 
> Following the diagram the battery is at 100% of charge at 12,8V. So with 13,6V it would be above 100%.

That diagram is showing resting voltage of the battery. Meaning, what is the voltage after you disconnect from any charger or load and let it reach a steady-state voltage. You can get a charged battery to rest above 12.8 V for a while, but that extra voltage is from the so-called "surface charge" (like a capacitor) which goes down quickly once you start to draw even a little current. Strictly speaking for your case, you should use the voltage under load instead of resting voltage, but if your load takes 3-4 days to drain the battery that is a very small current, and measured terminal voltage should be still be very close to resting voltage.

Your float circuit can turn a trickle charge on and off with a FET instead of relay. If designed correctly, it should be very efficient, never get hot, and both circuit and battery should deliver a long lifetime. I have a number of such trickle chargers on 12V 7AH batteries and they have lasted for some years already.

A 15 V switching power supply doesn't use much AC power when you aren't drawing current from it. I like low-power, efficient designs also but I don't want to replace my battery more frequently just to avoid a 0.1 watt quiescent power draw. A DC-DC step-down converter based on MP1584 is cheap, claims > 90% efficiency, it can take 15V in and you can set it to 13.6 V for float, for small currents I think you can get away with a 1.4 V dropout voltage (Vin - Vout).
 
Last edited:
Again looks great. For me, might be fun to try one of these somewhere. Not sure I would trust it as my only way to enter my house as I am sort of old fashioned. Also I have several different entrances into my house.

It would also be interesting to see some pictures of your complete setup, where it shows where you mount your circuit board and battery and run any cables to the lock.

One thing I meant to ask. I am assuming you are using a deep cycle battery and not a starter battery? Your picture shows one labeled Quick start, which leads me to believe it is a starter battery.

Again nice project.
 
Hello Kurt

> where it shows where you mount your circuit board and battery and run any cables to the lock.

When the Adafruit board it is mounted on the door you don't see it anymore.
And the mainboard does not look different than on the foto in the article.


I went to a motorcycle shop and bought any battery they had there, which was a starter battery.

I think the difference is not really relevant:
The starter battery delivers high currents which is not needed for my project.
And the deep cycle battery allows discharging deeply (like in wheelchairs) but this is also not needed because the battery is permanently charged at 13,6V.
It will only be discharged in the case of a power failure.
And even in that case it takes several days to discharge the battery.

In my opinion both types of batteries should do the job.
 
Hello Paul

My Teensy RFID project on Codeproject
http://www.codeproject.com/Articles/1096861/DIY-electronic-RFID-Door-Lock-with-Battery-Backup
was growing much in the last months.
It has about 43000 views yet and the actual version works with Desfire cards using DES or AES encryption.
Many people have given their positive feedback and thanked me for the great work.

But it is strange that you ignored an email that I sent you some months ago where I asked you to add this project to your projects page:
https://www.pjrc.com/teensy/projects.html

You can use this one as picture:
http://www.codeproject.com/KB/system/1096861/Mainboard.jpg
or this one:
http://www.codeproject.com/KB/system/1096861/PN532.jpg


Apart from that: I found your projects page only via Google.
Why is your Projects page not accessible from te main menu on pjrc.com?

When I open
https://www.pjrc.com/teensy/projects.html
I see a completely different menu than on
http://pjrc.com/

Apart from that it is very confusing that you have THREE menus: One at the side and two above the page.

I think your menus need a redesign!
 
you could go the keyless route which also interfaces with your alarm system like me. DEI's PKE 2012T, it uses encryption and probably costs less
 
Hello KateKitty

If you have read the article you know that my project is DIY.
You cannot buy it ready.

Hi tonton

It is a bad joke to compare my doorlock with such a primitive circuit.
It is known that these are very unsafe.
The Chaos Computer Club has published videos on Youtube that show how easy it is to crack these types of systems.
 
better get your research done again
viper uses them.
and if rolling code were breached everyone even without keyless would have their cars stolen on an hourly basis.

ive listed a specific model, not a generic device.

it is a bad joke to compare a DIY device to a commercial product sold and used with several clifford/viper/compustar/autostart security systems

but what the heck, you've got a supposedly unbreakable plastic card that people love to hack just for fun

props.
:)
 
Last edited:
None of the following is intended as professional design or construction or test advice; and all European users are strongly encouraged to read the Low Voltage Directive and IEC60364 and consult a National Body; and all North American users are strongly encouraged to read building code scoped by your AHJ (typically NFPA70 or CSA No C22.1).

Have a clever accountant neighbor that is into this arduino stuff. Last year, he did an electronic door lock to his garage side-door, which eventually resulted in a 'small' fire. His insurance carrier refused coverage, for reasons that were obvious (to me).

1. Resistors, where used as a fuse, are an extreme fire hazard, and are not a reliable current interrupt device. Resistors, where intended to be fusible shall meet UL1412 and/or IEC60127-8 and have a flame rating equivalent to 94V-0. Rather than a fuse-type current interrupt, recommend a PTC certified per EN60730-1 or UL1434. Do not use AC fuses to interrupt DC unless so rated.

2. Batteries not fused with a hi-interrupt component and/or not properly terminated, are high-risk fire hazard.

3. Battery chargers shall have back-feed protection that conform to scoped performance requirements under single-fault conditions.

4. Because there is no ground bond, spacings and di-electric withstand ratings for the transformer and the secondary side must meet Class II construction requirements (3000Vac and 6.4mm).

5. Building access, where not keyed and electronic-only controls, should either have multiple portals using separate control system; or a separate and redundant control system where there is only a single portal available.

6. Some jurisdictions require fail-safe override and/or an interior fire-bar where electronic control system used. While (hopefully) not a class B or C installation and not an industrial environment, IEC/EN/UL 60730-x series are a good reference for the design of mission-critical systems that may affect human safety or building fire code. Would recommend annex H of IEC60730-1 as a place to start.
 
Thanks for your comments.
But if you have really studied my electronic design you will have noticed that it complies with all your requirements.

I have no idea what your neighbour did. And it seems that you also don't have detailed information what exactly happened.
But he must be a very ignorant electronics beginner if he designed a cricuit that resulted in a fire.

I have designed tons of electronic devices in the past decades and I have never seen one of them not even with a tiny flame.

And the fact that insurances refuse to pay is absolutely NORMAL.
They ALWAYS search for an excuse not to pay.
They have empoyees who receive their salary just to refuse the claims of their clients!
You pay years and years into an insurance and when the day comes when THEY should pay, they refuse.
Are really surprised about that?
It is better to put your money on a bank account than into an insurance.
If some day you need it, you will have it immediately without filling hundreds of forms and needing a lawyer.


1.
Resistors used as fuse are absolutely common in electronics.
I have seen them in thousands of televisions, video recorders, switched power supplies and other devices that I have repaired for decades.
In my circuit there is a small 0,22 Ohm resisitor of 1/4 W used as fuse.
You can try it on your own: Connect a 0,22 Ohm 1/4W resistor to a 12V battery and it will die in a few milliseconds with a cloud of smoke.
But you will NOT see a flame! That is nonsense.

Well, if you are still concerned about that, you can replace this resistor with a fuse.
No problem.


2.
Lead-Acid Batteries deliver a very high current, and there must be a protection against shortcut, that is correct.
But this protection EXISTS in my circuit.
My battery is by purpose only connected to 3 resistors.
One is 220kOhm which will never be any problem.
The second is the above mentioned 0,22 Ohm which you can replace with a fuse if you think that this is really necessary.
And the third limits the current through the door opener solenoid.
There is NOTHING more directly connected to the battery.
So a direct shortcut of the 12V to Ground is IMPOSSIBLE in my design.
As you see I designed that circuit with my electronic experience of decades to avoid a shortcut of the battery.


3.
This comment is completely out of topic here. I use a transformator to charge the battery!


4.
Absolutely no problem. If you study my board design you will see that the 220V lines are
far enough away from the rest of the circuit to even withstand 5 kV.
Also this has been designed by purpose.


5.
That is out of the scope of my project. Obviously you can install two door openers in your home. So if one fails you take the other door.


6.
This also is out of the scope of my article. Everybody who builds my circuit must have enough intelligence to build the mechanical part.
There are millions of options how to install a lock. It depends on the type of door and on the type of lock and more factors.
My article is primarily about the electronics and the software.



As you see, none of your concerns applies to my design.
It seems obvious to me that your neighbour was lacking the knowledge to build his door opener correctly.
So may be you recommend him my project, that surely NEVER will produce a fire.
Because it is simply impossible.
 
Last edited:
Status
Not open for further replies.
Back
Top