Hi All,
I am having difficulties getting my Arduino Uno to work with a SIM7600G-H CAT4 4G (LTE) shield.
Currently, I am trying to set it up to send/receive text messages with a push button. My code is below. I am using a Telstra SIM card.
#include <SoftwareSerial.h>
SoftwareSerial sim7600Serial(7, 8); // RX, TX
void setup() {
Serial.begin(9600);
while (!Serial); // Wait for Serial Monitor to open
sim7600Serial.begin(9600);
Serial.println("Initializing SIM7600...");
// Initialize SIM7600 module
sendATCommand("AT");
// Set SIM7600 to SMS text mode
sendATCommand("AT+CMGF=1");
// Set SIM7600 to show new SMS notifications
sendATCommand("AT+CNMI=1,2,0,0,0");
}
void loop() {
// Check for new SMS
if (sim7600Serial.available()) {
Serial.write(sim7600Serial.read());
}
// Example: Send SMS
sendSMS("+61(phonenumber)", "Hello from SIM7600!");
delay(10000); // Adjust delay as necessary between SMS sends
}
void sendATCommand(String command) {
sim7600Serial.println(command);
delay(500); // Adjust delay as necessary
while (sim7600Serial.available()) {
Serial.write(sim7600Serial.read());
}
}
void sendSMS(String phoneNumber, String message) {
// Set SMS text mode
sendATCommand("AT+CMGF=1");
delay(1000); // Wait for response
// Specify phone number and message
sim7600Serial.print("AT+CMGS=\"");
sim7600Serial.print(phoneNumber);
sim7600Serial.println("\"");
delay(1000); // Wait for response
// Send message content
sim7600Serial.print(message);
sim7600Serial.println((char)26); // End message with Ctrl+Z
delay(1000); // Wait for response
}