I have been using a SIM800L GSM for my project and it seems like the call does not go.
I'm using an Airtel (Indian) 4G sim, I used this code to test, but it seems that it would not work.
After some time the led on the SIM800L was blinking every 1 second, and I could not get it to get the signal, I even tried going outside. My doubt is with the code, I'm frankly going to say I'm new.
I'm windows 11, using arduino IDE 2.2.1, If I have any updates, I will notify.
And yes I did put a real phone number there.
I bought my GSM from here: https://amzn.eu/d/8PmVSPz
#include <SoftwareSerial.h>
SoftwareSerial sim800lSerial(7, 8);
void setup() {
Serial.begin(9600);
sim800lSerial.begin(9600);
delay(1000);
Serial.println("Initializing...");
}
void loop() {
if (sendATCommand("AT")) {
Serial.println("SIM800L is ready.");
String phoneNumber = "845xxxxxxx";
// Make a call
if (callPhoneNumber(phoneNumber)) {
Serial.println("Calling " + phoneNumber);
} else {
Serial.println("Call failed.");
}
}
}
bool sendATCommand(String command) {
sim800lSerial.println(command);
delay(1000);
while (sim800lSerial.available()) {
char c = sim800lSerial.read();
Serial.print(c);
if (c == 'O' || c == 'o') {
delay(1000);
return true;
}
}
return false;
}
bool callPhoneNumber(String phoneNumber) {
sim800lSerial.println("ATD" + phoneNumber + ";");
delay(1000);
while (sim800lSerial.available()) {
char c = sim800lSerial.read();
Serial.print(c);
if (c == 'C' || c == 'c') {
delay(1000);
return true;
}
}
return false;
}
void hangUpCall() {
sim800lSerial.println("ATH");
delay(1000);
}