调试SIM808 GPS功能遇到问题求助

2018-04-101.4万
AI 快速预览详细 收起
本文讨论了在使用Arduino UNO R3和DFRobot SIM808板调试GPS功能时遇到的问题。具体问题包括在loop函数中加入Serial.println("111")后一直输出111,加入delay(1000)后无输出,以及加入Serial.println(result)后一直输出0。文章提供了具体的解决方案,帮助用户正确获取GPS坐标信息。
大家好,我在调试SIM808 的GPS 功能时,遇到问题,如下:
1. 在loop函数中加入 Serial.println("111"); 这一段之后,在调试的时候一直输出 111,我的期望是输出 111 之后能继续输出 GPS 坐标信息
2. 在loop函数中加入 delay(1000); 这一段之后,在调试的时候什么都不输出了,我的期望是间隔1秒请求一次 GPS 数据
3. 在loop函数中加入 Serial.println(result); 这一段之后,在调试的时候一直输出 0,我的期望是能正常输出 GPS 坐标信息
4. 以上三段代码都注释掉的情况下能正确输出 GPS 坐标信息

我用的是 Arduino UNO R3 + DF SIM808板

以下是我的代码:

[mw_shl_code=cpp,true]
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

DFRobot_SIM808 sim808(&Serial);

void setup() {
  //mySerial.begin(9600);
  Serial.begin(9600);

  //******** Initialize sim808 module *************
  while(!sim808.init()) {
      delay(1000);
      Serial.print("Sim808 init error\r\n");
  }

//************* Turn on the GPS power************
  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else
      Serial.println("Open the GPS power failure");
}

void loop() {
//  加上这段就一直输出 111
//  Serial.println("111");

//  加上这段什么也不输出了
//  delay(1000);

  int result = sim808.getGPS();

   //************** Get GPS data *******************
   if (result) {
    Serial.println(result); // 这里输出 1
   
    Serial.print("latitude :");
    Serial.println(sim808.GPSdata.lat,6);
   
    Serial.print("longitude :");
    Serial.println(sim808.GPSdata.lon,6);
     
    //************* Turn off the GPS power ************
    sim808.detachGPS();
  }else{
//  加上这段就一直输出 0
//  Serial.println(result);
  }

}[/mw_shl_code]

创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

评论(1)
20060606
20060606
问大家一个问题,现在有没有北斗卫星的arduino模块?
- 没有更多了 -