Arduino Uno 3 way security door lock need help

Help pleasez my Arduino project won't work if I combine all code in one

It consists of: RFID, Keypad password, GSM Module

Everything is working well except for the module, it won't sent a message through my cellphone

Welcome! I will take a guess and say you did not read the forum guidelines. Guidelines: Please read the advice in the topic "How to get the best from this forum". How to get the best out of this forum Aparently you did not use the correct code combiner. The one requires you to post your code as we are not clairvoyant so we do not have a clue as to what you have.

1 Like

I can see a PP3 9V battery… that won’t run either of your lock, or cell modem for more than a few seconds.

Start again - after reading asking and testing.

Yes, this is the problem. You should start with one device and make it work. Next you should add a second device and make the two devices work. Continue this until you are finished.

That's what I've been doing but when I get to the Gsm module it doesn't work

You should show your working program and its wiring diagram.

So I'll be specific on what I did earlier,

First I made the Keypad and Servo motor work, next was the LED and Buzzer work, everything was working well, but after is the Infrared Sensor and GSM Module, now the Gsm module doesn't send message through my cellphone,

IR sensor's role is to detect if someone is trying to force enter the door and if it does detect something it should be sending signal to my Gsm module and send me a message, in my serial monitor it says It has sent me a message but I don't receive it. note: my Gsm sim has prepaid load as well, and is connected to the network.

If anyone needs images that I could send or my code I did pls tell me.

Here's my code for the project

#include <SPI.h>
#include <MFRC522.h>
#include <Keypad.h>
#include <Servo.h>
#include <SoftwareSerial.h>

#define SS_PIN 10
#define RST_PIN 9
#define SERVO_PIN 8
#define GREEN_LED_PIN A1
#define RED_LED_PIN A2
#define BUZZER_PIN A3
#define IR_SENSOR_PIN A5

MFRC522 mfrc522(SS_PIN, RST_PIN);
String authorizedRFID = "43c74c25";
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {A0, 2, 3, 4};
byte colPins[COLS] = {5, 6, 7};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
Servo myServo;
SoftwareSerial gsmSerial(0, 1);
String phoneNumber = "+639658158281";
bool RFIDScanned = false;
bool infraredEnabled = true;

void setup() {
Serial.begin(9600);
Serial.println("System Ready.");

SPI.begin();
mfrc522.PCD_Init();

myServo.attach(SERVO_PIN);
pinMode(GREEN_LED_PIN, OUTPUT);
pinMode(RED_LED_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(IR_SENSOR_PIN, INPUT);
gsmSerial.begin(9600);
gsmSerial.println("AT+CMGF=1");
}

void loop() {

if (mfrc522.PICC_IsNewCardPresent()) {
if (mfrc522.PICC_ReadCardSerial()) {
RFIDScanned = true;
infraredEnabled = false;
String rfidTag = getRFIDTag();
Serial.println("RFID Card Detected: " + rfidTag);

  if (rfidTag.equals(authorizedRFID)) {

    Serial.println("Authorized RFID Card Detected.");
    digitalWrite(GREEN_LED_PIN, HIGH);
    tone(BUZZER_PIN, 1000);
    delay(1000);
    digitalWrite(GREEN_LED_PIN, LOW);
    noTone(BUZZER_PIN);

    String passcode = getPasscode(keypad);
    Serial.println("Entered Passcode: " + passcode);

    if (passcode.equals("3333")) {

      Serial.println("Passcode Correct. Access Granted!");
      digitalWrite(GREEN_LED_PIN, HIGH);
      tone(BUZZER_PIN, 1000);
      delay(1000);
      digitalWrite(GREEN_LED_PIN, LOW);
      noTone(BUZZER_PIN);
      rotateServo(180);
      delay(1000);
      rotateServo(0);
      delay(2000);
      digitalWrite(GREEN_LED_PIN, LOW);
      infraredEnabled = true; 
    } else {

      Serial.println("Incorrect Passcode. Access Denied!");

      digitalWrite(RED_LED_PIN, HIGH);
      tone(BUZZER_PIN, 200);
      delay(300);
      digitalWrite(RED_LED_PIN, LOW);
      noTone(BUZZER_PIN);
      delay(300);
      digitalWrite(RED_LED_PIN, HIGH);
      tone(BUZZER_PIN, 200);
      delay(300);
      digitalWrite(RED_LED_PIN, LOW);
      noTone(BUZZER_PIN);
    }
  } else {

    Serial.println("Unauthorized RFID Card Detected. Access Denied!");
    for (int i = 0; i < 4; i++) {
      digitalWrite(RED_LED_PIN, HIGH);
      tone(BUZZER_PIN, 200);
      delay(300);
      digitalWrite(RED_LED_PIN, LOW);
      noTone(BUZZER_PIN);
      delay(300);
    }
  }

  delay(1000);
}

}

if (infraredEnabled && detectObject()) {
Serial.println("Object Detected by IR Sensor!");
sendSMSAlert();
delay(5000);
}
}

bool detectObject() {
return digitalRead(IR_SENSOR_PIN) == LOW;
}

String getRFIDTag() {
String tag = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : ""));
tag.concat(String(mfrc522.uid.uidByte[i], HEX));
}
mfrc522.PICC_HaltA();
Serial.println("RFID Tag: " + tag);
return tag;
}

String getPasscode(Keypad &keypad) {
String pass = "";
while (pass.length() < 4) {
char key = keypad.getKey();
if (key && isDigit(key)) {
pass += key;
Serial.print(key);
}
}
Serial.println();
return pass;
}

void rotateServo(int angle) {
myServo.write(angle);
delay(5000);
Serial.println("Servo rotated to " + String(angle) + " degrees.");
}

void sendSMSAlert() {
Serial.println("Sending SMS Alert...");

String phoneNumber = "+639658158281";
String message = "Intruder Alert";

gsmSerial.print("AT+CMGS="");
gsmSerial.print(phoneNumber);
gsmSerial.println(""");

delay(500);

Serial.println("Sending message: " + message);

gsmSerial.print(message);
gsmSerial.write(26);
delay(500);

Serial.println("SMS sent successfully!");
}

I did, also, and still need your wiring diagram.

Get the GSM working how you need it to work first.

My GSM Module works fine when I upload only the code for Gsm module, but it doesn't if I upload the code for all of them.

Cool. Add that to the drawing.

I'm sorry but I don't have a wiring diagram for it yet.

I'll wait.

1 Like

Please confirm that all works properly and ONLY the GSM module has problems. There is no need to work on tested and proven code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.