Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GSM CALL RELAY
#1
Hello,

I am having difficulty for coding my script, I would like to make a GSM relay which activates the GPIO 15 relay upon the module receipt a call ! but I cannot do it can you help me?

I think my problem is from the command of call detection.

Thanks


Code:
#include <SoftwareSerial.h>

// Create software serial object to communicate with A6
SoftwareSerial mySerial(13, 34); // A6 Tx & Rx is connected to Arduino #3 & #2

int relayPin = 15; // GPIO 15 connected to the relay

void setup()
{
  // Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(115200);
 
  // Begin serial communication with Arduino and A6
  mySerial.begin(115200);

  Serial.println("Initializing...");

  pinMode(relayPin, OUTPUT); // Set the relay pin as an output
  digitalWrite(relayPin, LOW); // Initialize the relay as OFF
}

void loop()
{
  updateSerial();
  checkCall();
}

void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    mySerial.write(Serial.read()); // Forward what Serial received to Software Serial Port
  }
  while(mySerial.available())
  {
    Serial.write(mySerial.read()); // Forward what Software Serial received to Serial Port
  }
}

void checkCall()
{
  if (mySerial.available())
  {
    String response = mySerial.readString();
    if (response.indexOf("+CLCC: 1,1,2,4,0") != -1) // Check if "+CLCC: 1,1,2,4,0" is present in the response
    {
      activateRelay();
    }
  }
}

void activateRelay()
{
  digitalWrite(relayPin, HIGH); // Turn ON the relay
  delay(5000); // Keep the relay ON for 5 seconds
  digitalWrite(relayPin, LOW); // Turn OFF the relay
}
Reply


Messages In This Thread
GSM CALL RELAY - by Anthonio - 06-24-2023, 12:29 AM
RE: GSM CALL RELAY - by admin - 06-24-2023, 03:10 AM
RE: GSM CALL RELAY - by Anthonio - 06-24-2023, 08:22 AM
RE: GSM CALL RELAY - by admin - 06-24-2023, 11:18 AM
RE: GSM CALL RELAY - by Anthonio - 06-25-2023, 11:50 PM
RE: GSM CALL RELAY - by admin - 06-26-2023, 03:49 AM
RE: GSM CALL RELAY - by Anthonio - 06-26-2023, 05:47 AM
RE: GSM CALL RELAY - by admin - 06-26-2023, 10:14 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)