after send sms "get" to Program:
it 's show on serial monitor
......
wdt reset
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v00044e70
~ld
..........................code program.................
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
const String PHONE_NUMBER = "+66935474953";
// Define RX/TX pins for GSM Module
#define GSM_RX_PIN D5
#define GSM_TX_PIN D6
SoftwareSerial sim800(GSM_RX_PIN, GSM_TX_PIN);
// Define RX/TX pins for GPS Module
#define GPS_RX_PIN D7
#define GPS_TX_PIN D8
SoftwareSerial neogps(GPS_RX_PIN, GPS_TX_PIN);
TinyGPSPlus gps;
String receivedCommand = "";
void setup() {
Serial.println("Start of setup");
Serial.begin(115200);
Serial.println("Arduino serial initialize");
sim800.begin(9600);
Serial.println("SIM800L serial initialize");
neogps.begin(9600);
Serial.println("GPS serial initialize");
sim800.listen();
neogps.listen();
sim800.println("AT+CMGF=1\r"); // Set SMS mode to text
delay(1000);
Serial.println("Setup complete.");
Serial.println("End of setup");
}
void loop() {
ESP.wdtFeed(); // āļŦāļĢāļ·āļ ESP8266.wdtFeed()
while (sim800.available()) {
parseSMS(sim800.readString());
}
// āļĢāļāļĢāļąāļāļāļģāļŠāļąāđāļāļāļēāļāļāļđāđāđāļāđ
if (receivedCommand == "get") {
checkGPSCommand();
// āļĢāļĩāđāļāđāļāļāļģāļŠāļąāđāļāļāļĩāđāđāļāđāļĢāļąāļ
receivedCommand = "";
//delay(1000); // āļāļąāļāđāļāļ·āđāļāļāđāļāļāļāļąāļāļāļēāļĢāļāļģāļāļēāļāđāļāļāđāļĄāđāļāļ
}
}
void parseSMS(String sms) {
Serial.println("Received SMS: " + sms); // Display the received SMS in Serial Monitor
sms.trim();
if (sms.startsWith("+CMTI")) {
int index = sms.indexOf(",");
String temp = sms.substring(index + 1);
temp.trim();
temp = "AT+CMGR=" + temp + "\r";
sim800.println(temp);
} else if (sms.startsWith("+CMGR")) {
extractSMS(sms);
}
}
void extractSMS(String sms) {
int index = sms.indexOf(",");
String senderNumber = sms.substring(index + 2, index + 15);
senderNumber.trim();
index = sms.indexOf("\n");
String message = sms.substring(index + 1);
message.trim();
Serial.println("Sender Number: " + senderNumber);
Serial.println("Message: " + message);
if (senderNumber == PHONE_NUMBER) {
processCommand(message);
}
}
void processCommand(String command) {
// āđāļŦāđāļāļģāļāļēāļĢ trim() āļāđāļāļāđāļāļĢāļĩāļĒāļāđāļāļĩāļĒāļ
command.trim();
if (command.equalsIgnoreCase("get")) {
receivedCommand = command;
Serial.println("Received command: " + receivedCommand);
}
}
void checkGPSCommand() {
Serial.println("Checking GPS Command");
// āļāļĢāļ§āļāļŠāļāļāļ§āđāļēāļĄāļĩāļāļģāļŠāļąāđāļ "get" āļāļđāļāļŠāđāļāļĄāļēāļŦāļĢāļ·āļāđāļĄāđ
if (receivedCommand == "get") {
// āļĢāļĩāđāļāđāļāļāļģāļŠāļąāđāļāļāļĩāđāđāļāđāļĢāļąāļ
receivedCommand = "";
// āļāļĢāļ§āļāļŠāļāļ GPS Data āđāļĨāļ°āļŠāđāļ SMS āļāļĩāđāļĄāļĩāļāđāļāļĄāļđāļĨāļāļģāđāļŦāļāđāļ GPS
while (neogps.available()) {
if (gps.encode(neogps.read())) {
if (gps.location.isValid()) {
Serial.println("Sending Location SMS");
sendLocationSMS();
} else {
Serial.println("Invalid GPS Location");
}
} else {
Serial.println("GPS Data Not Received");
}
}
}
}
void sendLocationSMS() {
Serial.print("Sending Location SMS...");
if (gps.location.isValid()) {
sim800.print("AT+CMGS="" + PHONE_NUMBER + ""\r");
delay(1000);
sim800.print("Google Maps");
sim800.print(gps.location.lat(), 6);
sim800.print(",");
sim800.print(gps.location.lng(), 6);
sim800.write(0x1A); // āđāļĄāđāļāđāļāļāđāļāđ delay āļŦāļĨāļąāļāļāļēāļāļāļēāļĢāļŠāđāļāļāđāļāļĄāļđāļĨ
unsigned long startMillis = millis();
while (millis() - startMillis < 10000) { // āļĢāļāļāļēāļĢāļāļāļāļāļĨāļąāļāļāļēāļāđāļĄāļāļđāļĨ GSM āļ āļēāļĒāđāļ 10 āļ§āļīāļāļēāļāļĩ
if (sim800.available()) {
String response = sim800.readString();
Serial.println("Response from GSM module: " + response);
break;
}
}
Serial.println("GPS Location SMS Sent Successfully.");
} else {
Serial.println("Invalid GPS data");
}
}