Arduino 我的GPS可以';t通过短信共享位置

Arduino 我的GPS可以';t通过短信共享位置,arduino,gsm,Arduino,Gsm,我的项目有些问题。我正在使用SIM800L和GPS Neo6MV2与arduino正版uno。我的项目正在通过消息发送GPS位置。但是,我收到的消息只包含long=0000000 lat=000000。 这是我的密码: #include <TinyGPS++.h> TinyGPSPlus gps; //float latitude, longitude; int myled=13; #include <SoftwareSerial.h> SoftwareSerial SI

我的项目有些问题。我正在使用SIM800L和GPS Neo6MV2与arduino正版uno。我的项目正在通过消息发送GPS位置。但是,我收到的消息只包含long=0000000 lat=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);
      }
  }
#包括
TinyGPSPlus gps;
//浮动纬度、经度;
int myled=13;
#包括
软件串行SIM800L(7,8);
//软件串行gps_串行(2,3);
字符串响应;
int lastStringLength=response.length();
弦纬度、经度;
串链;
无效设置(){
Serial.begin(9600);
序列号.println(“GPS Mulai”);
SIM800L.begin(9600);
SIM800L.println(“AT+CMGF=1”);
Serial.println(“SIM800L从9600开始”);
延迟(1000);
Serial.println(“安装完成!SIM800L准备就绪!”);
SIM800L.println(“AT+CNMI=2,2,0,0,0”);
编码(Serial.read());
纬度=gps.location.lat();
经度=gps.location.lng();
}
void循环(){
if(gps.location.isValid())
{
Serial.print(gps.location.lat(),6);
连续打印(F(“,”);
Serial.print(gps.location.lng(),6);
}
其他的
{
连续打印(F(“无效”));
}
如果(SIM800L.available()>0){
response=SIM800L.readStringUntil('\n');
}
if(lastStringLength!=response.length()){
}
if(response.indexOf(“ON”)==4){
SIM800L.println(“AT+CMGF=1”);//将GSM模块设置为文本模式
延迟(1000);//延迟1000毫秒或1秒
SIM800L.println(“AT+CMGS=\”082232949301\“\r”);//用手机号替换x
延迟(1000);
SIM800L.println(“https://www.google.com/maps?q=“+纬度+”,“+经度);//要发送的短信文本
延迟(100);
SIM800L.println((char)26);//CTRL+Z的ASCII码
延迟(1000);
}
}

您能帮我解决这个问题吗?

您只能将字节(可能无效)输入到解析器中。你认为这将如何工作?我想,当我发送消息“GPS开启”时,他会回复当时GPS坐标的位置