PROBLEMS with my Project on RFID + KEYPAD Door Lock

(Posting for the First time on the Forum, so don't get mad at me :slight_smile: . If there's a mistake, please let me know).

Hey Guys! I'm Somewhat new to programming and had started using Arduino IDE around 3-4 Months Ago.

I learned the Basics through Arduino Reference Pages, Forum, Google, Youtube, Etc.....

I was able to write the Following Code by myself (99%). First i will post the Full code, then the part of the code which have the issues. (Issues at the Bottom)

Parts Used:

  1. Arduino Mega 2560
  2. MFRC 522 RFID Module 13.56 Mhz
  3. 4x4 Keypad
  4. LCD 16x2
  5. Red & Green Leds
  6. 100E Resistor (Common for Leds)
  7. Push Button with 1K Pull down Resistor
  8. Simple Buzzer
  9. Single Channel Relay module (you might find some lines in the code where the relay is pulled LOW rather than HIGH, this is
    becuase my relay module is Active-low)
  10. EM Door Lock

I don't have a schematic for this as i made it myself so.. sorry! But it's easy to figure out the pins through the codes.
You can take a look at the MFRC522 Example sketches for it's Pinout and connection with the Mega.

The Basic Features like Keypad Unlock and RFID Unlock work Perfectly Fine but the Additional Features to Change Password & Programming Password Do not Work (Take a Look at the Code):

I can not paste the code here becuase it exceeds the character limit. Download the Ino files and open it up in your IDE.

The FULL CODE:
You will need to download it all, it Exceeds the Character Limit.

PARTS Of The CODE Where The PROBLEM Really Is:

PART 1: (The Access password and Programming password Changing Part)

So the Problem is that when i enter the programming mode and after successfully entering the programming code, when i try to choose what i want to edit (whether i want to change the Access code or the programming code). It just doesn't go any further.
It just Stops at the Selection Screen.

PART 2: (The Deactivation Part):

Here the Problem is that as soon as i Enter this mode to Deactivate the System, the LCD starts Flickering and after i successfully enter the password and deactivate the system the (ACTIVE == false) statement saying System Deactivated shows up for just a milli second or so and the display goes empty (Though the backlight stays on). But the Command works and it does turns off the Lock. After i Press the "A" button again to Activate the system, the System Activates and the Display comes Back On. (I think i might have chosen the wrong pins for the LCD).

An Additional Problem with my LCD is whenever the Relay turns on the Display Goes Dim (Not the Backlight but the Characters).

Thanks for Reading such a long long post, Hoping for a positive reply. :slight_smile:

PART_1.ino (5.71 KB)

PART_2.ino (2.41 KB)

THE_FULL_CODE.ino (14.6 KB)

All INO Files.zip (4.69 KB)

Take a pen, draw a picture of how things are connected and powered, take a picture and post it here

If your stuff is underpowered or badly protected (freewheel diode across inductive coil?) you’ll have issues that you can’t solve with programming

I don't have a schematic for this as i made it myself so.. sorry! But it's easy to figure out the pins through the codes.

So you want every one here to look at your code and draw a schematic based on what we see. What then? Do we post our schematics and then you tell us what you do not have? Not the most efficient way of going about things. Also it won’t actually work.

For example how can we tell from the code if you have a proper level converter between the 3V3 system of the RFID reader and the 5V system of the Arduino.

Okay I'll Draw a Schematic and Share it here with all the Components.

By the way a new problem has come up, the RFID Reader stopped working by itself. I turned off and on the power switch and it started working again. I looked through the code but i couldn't find any mistakes (as per my knowledge :o )

Uploading the Schematic Soon....

Here! I made it on Fritzing. The Schematic is in PDF Format for Better Picture Quality.

One Component I forgot to Mention is a 10k Pot for Contrast Adjustment.

Quick Connection Guide:

A. MFRC522:

VIN = 3.3V

RST = 5
SDA(SS) = 53
MOSI = 51
MISO = 50
SCK = 52

B. 4x4 KEYPAD:

1 = 13
2 = 12
3 = 11
4 = 10
5 = 9
6 = 8
7 = 7
8 = 6

C. LCD 16x2

RS = A0
EN = A1
D4 = A2
D5 = A3
D6 = A4
D7 = A5

D. Misc. :

INSIDE OPEN = 24

RELAY = 25

BUZZER = 26

RED LED = 27

GREEN LED = 28

For the Main Power Source i used a Samsung Usb Adapter rated at 5V 1A (This has been the most Friendly Power Supply as the RFID Reader stops working after 30 Hours or so..). (I tried using 5V 3A Adapter but it results in RFID Reader to Stop Working in around 1 Hour). It connects to the USB Port of the Mega through the Provided cable.

For Detailed Connections please refer to the Schematic Attached. (you can also download the Fritzing Project)

RK.pdf (1.36 MB)

RFID + KEYPAD.zip (121 KB)

the max current you can draw from the 3.3V pin is 50mA regardless of the capability of your power supply.

If you connect to the USB then you'll get fed only 500mA for the total of your board and full set-up.

if you power everything from the 5V and 3.3V pins you might run out of power (30mA for the RFID, 80-100 for the relay, up to 100+ for the LCD depending on your backlight, ...)

You should really separate powering your arduino and powering the other systems. If your power supply is really 5V and stable, you could consider powering the breadboard or your components straight from the power supply.

Alright! I'll try adding a discrete Power Supply.

What about the Programming mode error ?
Did you find any mistakes ?
I tried adding "while" statements rather than "if" statements but they resulted in never ending loop.

A new Issue just popped up..
After some time, the program starts to lag or something and i have to press the keypad buttons a lot of times for them to get registered.

Restarting Fixes it but Comes up again after some time of Running.

btw @jml i dont have a level shifter for the RC522 Board. They directly connect to the Digital Pins of the Arduino. Only the 3.3V Pin is Connected to the 3.3V Output of the Ardiuno.

I can't read your code from my smartphone/tablet... sorry

can you clarify how your button is wired? if it is in INPUT_PULLUP In the code, why do you have a resistor and all those wires? should be just PIN --> BUTTON --> GND (ideally going in diagonal across the button to ensure you don't pick the wrong pins)

dont have a level shifter for the RC522 Board. They directly connect to the Digital Pins of the Arduino. Only the 3.3V Pin is Connected to the 3.3V Output of the Ardiuno.

That was the point I was trying to make earlier. While many people do this it is outside the specifications of the chip on the reader board. That sort of thing is never good and can lead to latch up which is what you might be seeing. Level shifters should be used even if it is only a potential divider on all the output lines going from the Arduino to the reader. No need to do anything with the signals going from the reader to the Arduino.

@J-M-L

I know the code with INPUT_PULLUP for the Switch and the schematic for the same don't Technically match, but it works this way i don't why. After some trial and error this worked.

@GRUMPY_MIKE

(As you suggested) I just ordered some Logic Level Shifter Boards and they should be arriving tomorrow. I will let you know the Results soon after i test it.

But could someone check the code and tell me what's wrong with the PROGRAMMING Mode and why wouldn't it go any further ? I'm really eager to make this work.. Please!! :slight_smile: :slight_smile:

I just found The BottleNeck problem which was Causing issues like LCD Dimming, Relay not getting Triggered, Leds not Glowing together, etc..

The USB Cable which was powering the Arduino was Broken from Inside so even a small bang on the door would hinder the connection inside the cable and the Power would get cut. I always blamed my Breadboard for a broken connector in it.

Luckily i had a spare cable laying around so I replaced the old one with that. And now there's no LCD Dimming Issue when the relay would get triggered and stuff.

PROBLEMS that are Solved:

  1. LCD Dimming and other Power Issues (thanks to JML)

PROBLEMS that Still Exist are: (Refer to the other Posts of mine on this Thread)

  1. The Programming mode not working for Password change and stuff. (Post 0)
  2. LCD Flickering while in Deactivation mode. (Post 0)
  3. RFID Module Latchup (should be solved as soon as i add the Level Shifter - thanks to Mike)
  4. Program Starting to Lag after some time. (Post 7).

To Solve Problems 3&4 Temporarily, i used the Button "B" on the Keypad (Unused Button) as a Reset Button which Restarts the Program from zero. Doing this Removes the Latch Up and Lag problem for a short time.

siddhant_shah:
Luckily i had a spare cable laying around so I replaced the old one with that. And now there's no LCD Dimming Issue when the relay would get triggered and stuff.

Even the Second Cable failed.... :expressionless:

I finally Decided to go with a 12V 2A Power Supply and that worked way better than all of them. But.. this thing Heats up the Voltage Regulator on Arduino like Soldering Iron (Kinda :\ ).

Anyways, So the Power Issues are most probably Solved and now i do not need 2 Discrete Power Supplies to Power Arduino and other stuff Separately.