我的项目有问题。我正在将SIM800L和GPS Neo6MV2与arduino真正的uno一起使用。我的项目正在通过消息发送GPS位置。但是,我收到的消息仅包含long = 0,000000 lat = 0,000000。 这是我的代码:
#include <TinyGPS++.h>
TinyGPSPlus gps;
//float latitude, longitude;
int myled=13;
#include <SoftwareSerial.h>
SoftwareSerial SIM800L(7, 8);
//SoftwareSerial gps_serial(2,3);
String response;
int lastStringLength = response.length();
String latitude, longitude;
String link;
void setup() {
Serial.begin(9600);
Serial.println("GPS Mulai");
SIM800L.begin(9600);
SIM800L.println("AT+CMGF=1");
Serial.println("SIM800L started at 9600");
delay(1000);
Serial.println("Setup Complete! SIM800L is Ready!");
SIM800L.println("AT+CNMI=2,2,0,0,0");
gps.encode(Serial.read());
latitude = gps.location.lat();
longitude = gps.location.lng();
}
void loop() {
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 6);
Serial.print(F(","));
Serial.print(gps.location.lng(), 6);
}
else
{
Serial.print(F("INVALID"));
}
if (SIM800L.available()>0){
response = SIM800L.readStringUntil('\n');
}
if(lastStringLength != response.length()){
}
if(response.indexOf("ON") == 4){
SIM800L.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
SIM800L.println("AT+CMGS=\"082232949301\"\r"); // Replace x with mobile number
delay(1000);
SIM800L.println("https://www.google.com/maps?q=" + latitude+","+longitude) ;// The SMS text you want to send
delay(100);
SIM800L.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
}
您能帮我解决这个问题吗?