Hi everybody,
I was struggling with the A7670E module, but eventually, I got it working with the help of Minicom and ChatGPT. It took me a whole day, and since I couldn’t find many available information, I wanted to share my working code for both SMS and calling.
My SIM card didn’t have an SMSC number set, so I had to use Minicom to reset the SMS mode, look up the correct SMSC number for my operator, and set it manually using the following commands:
AT+CSCS="GSM"
AT+CMGF=1
AT+CSCA="+myOperatorSMSCnumber",145
You can find SMSC numbers here: SIM center numbers.
Connecting to Minicom depends on whether you're using Linux or Windows, but it’s pretty straightforward, and there are plenty of tutorials available online.
The module won't work connected to Arduino power pins, it needs is own power supply 5V 2Amp.
Here is my code used on Arduino UNO. Hope it works for you! Good luck!
#include <SoftwareSerial.h>
// GSM Module connection
SoftwareSerial gsmSerial(9, 10); // TX, RX pins
String PhoneNum = "+123456798";
//Setup
void setup() {
Serial.begin(9600); // Start Serial communication
gsmSerial.begin(115200); // Start GSM module communication
// Setup GSM module for SMS
sendATCommand("AT+CMGF=1", "OK", 30000); // Text mode
//sendATCommand("AT+CNMI=1,2,0,0,0", "OK", 2000); // New SMS indication
}
//Main loop
void loop() {
sendSMS("Test message from Arduino UNO!"); //send SMS
delay(30000);
checkAndHangup(); // Make sure no active call
delay(5000); // Give some time before calling again
sendCall(); //Dial a call
delay(10000);
}
//AT commands
void sendATCommand(String command, const char* expectedResponse, unsigned long timeout) {
Serial.print(command);
gsmSerial.println(command); // Send the AT command
long int time = millis();
while ((time + timeout) > millis()) {
while (gsmSerial.available()) {
if (gsmSerial.find(const_cast<char*>(expectedResponse))) {
Serial.println(command + ": SUCCESS");
return;
}
}
}
Serial.println(command + ": FAILED");
delay(1000);
}
//Send SMS
void sendSMS(String message) {
sendATCommand("AT+CMGS=\"" + PhoneNum + "\"", "OK", 2000); // Prepare to send SMS
gsmSerial.println(message); // Send the message content
delay(500);
gsmSerial.write(26); // ASCII code for CTRL+Z to send the SMS
Serial.println("SMS Sent: " + message);
}
//Dial a call
void sendCall() {
sendATCommand("ATD" + PhoneNum + ";", "OK", 2000);
Serial.println("Call outgoing...");
// Wait for call connection
unsigned long callStart = millis();
bool callConnected = false;
while (millis() - callStart < 20000) { // Wait up to 20 seconds for call to connect
sendATCommand("AT+CLCC", "0", 2000); // "0" means call is active
if (gsmSerial.find("1,0,0,0,0")) { // This means the call is connected
Serial.println("Call Connected!");
callConnected = true;
break;
}
delay(1000); // Check again in 1 second
}
if (callConnected) {
delay(30000); // Keep the call active for 30 seconds (adjust as needed)
Serial.println("Hanging up...");
sendATCommand("AT+CHUP", "OK", 5000); // Hang up call
} else {
Serial.println("Call was not answered.");
}
}
//Reset any active calls and Hangup
void checkAndHangup() {
sendATCommand("AT+CLCC", "OK", 2000); // Check active calls
sendATCommand("AT+CHUP", "OK", 5000); // Try to hang up if needed
}