Adafruit FONA 3G GPS无响应

时间:2016-06-22 21:59:14

标签: c++ gps 3g mbed adafruit

我目前正与我的一位朋友合作开展一项涉及GPS追踪的项目。这是我们从Adafruit使用的FONA 3G GPS板。 https://www.adafruit.com/product/3147

我们也在使用推荐的有源GPS天线。由于声誉不佳,我无法发布链接。

我们正在mbed LPC1768微控制器上对系统进行原型设计。我们编写了自己的mbed代码,通过mbed上的UART将AT命令发送到FONA,然后通过putty在计算机上显示回复。我们已经尝试了几个简单的AT命令,例如制造商信息和​​SIM卡信息,并且这些命令运行良好。我们还尝试了更复杂的AT命令,这些命令要求电池电量等,而且这些命令也有效。我们现在无法获得GPS响应。昨天凌晨1点左右,我们能够通过AT + CGPSINFO命令获得GPS响应,该命令向我们展示了经度,纬度,方位等。然而,它大约40英里是不准确的。今天当我们回到它试图解决这个问题时,我们无法从GPS接收到任何响应。我们仍然可以从电池电量和其他命令接收响应。只是GPS没有响应。我们已经在室内外尝试过,并且在GPSTEST模式下让模块运行了一个多小时,但无济于事。

这是我们到目前为止的代码。

#include "mbed.h"

#define FONA_RST p12
#define FONA_TX p13
#define FONA_RX p14
#define FONA_RI p11
Serial fona(FONA_TX, FONA_RX);

Serial pc(USBTX, USBRX);
Serial esp(p28, p27); // tx, rx
DigitalOut reset(p26);
Timer t;

int  count,ended,timeout;
char buf[4024];
char snd[255];

char ssid[32] = "ycp-web-wifi";     // enter WiFi router ssid inside the                  quotes
char pwd [32] = "YCPnet2005"; // enter WiFi router password inside the quotes

void   SendCMD(),getreply(),ESPconfig(),ESPsetbaudrate(),sendFONA(),getFONAreply(), FONAconfig(), FONAsetbaudrate();


int main()
{
    reset=0; //hardware reset for 8266
    pc.baud(9600);  // set what you want here depending on your terminal program speed
    pc.printf("\f\n\r-------------ESP8266 Hardware Reset-------------\n\r");
    wait(0.5);
    reset=1;
    timeout=2;
    getreply();

    esp.baud(115200);   // change this to the new ESP8266 baudrate if it is changed at any time.
    fona.baud(115200);
    //ESPsetbaudrate();   //******************  include this routine to set a different ESP8266 baudrate  ******************

    //ESPconfig();        //******************  include Config to set the ESP8266 configuration  ***********************
    FONAconfig();

    while(1) {  
    /* 
        pc.printf("\n---------- GPS Test ----------\r\n");
        strcpy(snd,"AT+CGPSFTM=1\r\n");
        sendFONA();
        timeout=10;
        getFONAreply();
        pc.printf(buf);

        wait(5);*/

        pc.printf("\n---------- Get Battery Information ----------\r\n");
        strcpy(snd,"AT+CBC\r\n");
        sendFONA();
        timeout=5;
        getFONAreply();
        pc.printf(buf);

        wait(1);

        pc.printf("\n---------- Get GPS Coordinates ----------\r\n");
        strcpy(snd,"AT+CGPSINFO\r\n");
        sendFONA();
        timeout=60;
        getFONAreply();
        pc.printf(buf);

        /*
        wait(2);
        pc.printf("\n---------- Get Connected Devices ----------\r\n");
        strcpy(snd, "AT+CWLIF\r\n");
        SendCMD();
        timeout=5;
        getreply();
        pc.printf(buf);
        wait(2);*/
    }

}

// Sets new ESP8266 baurate, change the esp.baud(xxxxx) to match your new setting once this has been executed
void ESPsetbaudrate()
{
    strcpy(snd, "AT+CIOBAUD=115200\r\n");   // change the numeric value to the required baudrate
    SendCMD();
}

void FONAsetbaudrate()
{
    strcpy(snd, "AT+IPREX=115200\r\n");   // change the numeric value to the required baudrate
    SendCMD();
}

// FONA Config
void FONAconfig()
{
    pc.printf("---------- Starting FONA Config ----------\r\n\n");

    strcpy(snd,"AT\r\n");
    sendFONA();
    timeout=1;
    getFONAreply();
    pc.printf(buf);

    wait(2);
    strcpy(snd,"ATI\r\n");
    sendFONA();
    timeout=1;
    getFONAreply();
    pc.printf(buf);

    wait(2);
    strcpy(snd,"AT+CGPSAUTO=1\r\n");
    sendFONA();
    timeout=1;
    getFONAreply();
    pc.printf(buf);

    // Test Mode (0=off / 1=on)
    strcpy(snd,"AT+CGPSFTM=0\r\n");
    sendFONA();
    timeout=1;
    getFONAreply();
    pc.printf(buf);

    /*
    wait(2);
    strcpy(snd,"AT+CGPS=0,1\r\n");
    sendFONA();
    timeout=1;
    getFONAreply();
    pc.printf(buf);

    wait(5);

    strcpy(snd,"AT+CGPSHOT\r\n");
    sendFONA();
    timeout=1;
    getFONAreply();
    pc.printf(buf);


    strcpy(snd,"AT+CGPS=1,1\r\n");
    sendFONA();
    timeout=1;
    getFONAreply();
    pc.printf(buf);*/

}

//  +++++++++++++++++++++++++++++++++ This is for ESP8266 config only, run this once to set up the ESP8266 +++++++++++++++
void ESPconfig()
{
    wait(5);
    strcpy(snd,"AT\r\n");
    SendCMD();
    wait(1);
    strcpy(snd,"AT\r\n");
    SendCMD();
    wait(1);
    strcpy(snd,"AT\r\n");
    SendCMD();
    timeout=1;
    getreply();
    wait(1);
    pc.printf("\f---------- Starting ESP Config ----------\r\n\n");

    pc.printf("---------- Reset & get Firmware ----------\r\n");
    strcpy(snd,"AT+RST\r\n");
    SendCMD();
    timeout=5;
    getreply();
    pc.printf(buf);

    wait(2);

    pc.printf("\n---------- Get Version ----------\r\n");
    strcpy(snd,"AT+GMR\r\n");
    SendCMD();
    timeout=4;
    getreply();
    pc.printf(buf);

    wait(3);

    // set CWMODE to 1=Station,2=AP,3=BOTH, default mode 1 (Station)    
    pc.printf("\n---------- Setting Mode ----------\r\n");
    strcpy(snd, "AT+CWMODE_CUR=3\r\n");
    SendCMD();
    timeout=4;
    getreply();
    pc.printf(buf);

    wait(2);

    pc.printf("\n---------- SoftAP Configuration ----------\r\n");
    strcpy(snd, "AT+CWSAP_CUR=\"ESP8266\",\"\",11,0\r\n");
    SendCMD();
    timeout=10;
    getreply();
    pc.printf(buf);

    wait(2);

    // set CIPMUX to 0=Single,1=Multi
    pc.printf("\n---------- Setting Connection Mode ----------\r\n");
    strcpy(snd, "AT+CIPMUX=1\r\n");
    SendCMD();
    timeout=4;
    getreply();
    pc.printf(buf);

    wait(2);

/*
    pc.printf("\n---------- Listing Access Points 2 ----------\r\n");
    strcpy(snd, "AT+CWLAP\r\n");
    SendCMD();
    timeout=15;
    getreply();
    pc.printf(buf);*/

    wait(2);

    pc.printf("\n---------- Connecting to AP ----------\r\n");
    pc.printf("ssid = %s   pwd = %s\r\n",ssid,pwd);
    strcpy(snd, "AT+CWJAP=\"");
    strcat(snd, ssid);
    strcat(snd, "\",\"");
    strcat(snd, pwd);
    strcat(snd, "\"\r\n");
    SendCMD();
    timeout=10;
    getreply();
    pc.printf(buf);

    wait(5);

    pc.printf("\n---------- Get IP's ----------\r\n");
    strcpy(snd, "AT+CIFSR\r\n");
    SendCMD();
    timeout=3;
    getreply();
    pc.printf(buf);

    wait(1);

    pc.printf("\n---------- Get Connection Status ----------\r\n");
    strcpy(snd, "AT+CIPSTATUS\r\n");
    SendCMD();
    timeout=5;
    getreply();
    pc.printf(buf);

    pc.printf("\n++++++++++ Pinging Site ++++++++++\r\n");
    strcpy(snd, "AT+PING=\"172.31.5.67\"\r\n");  
    timeout=5;
    SendCMD();
    getreply();
    pc.printf(buf);

    strcpy(snd, "AT+PING=\"www.google.com\"\r\n");  
    timeout=5;
    SendCMD();
    getreply();
    pc.printf(buf);

    pc.printf("\n++++++++++ List of APs ++++++++++\r\n");
        strcpy(snd, "AT+CWLAP\r\n");  
        timeout=5;
        SendCMD();
        getreply();
        pc.printf(buf);
}

void SendCMD()
{
    esp.printf("%s", snd);
}

void sendFONA()
{
    fona.printf("%s", snd);
}

void getreply()
{
    memset(buf, '\0', sizeof(buf));
    t.start();
    ended=0;
    count=0;
    while(!ended) {
        if(esp.readable()) {
            buf[count] = esp.getc();
            count++;
        }
        if(t.read() > timeout) {
            ended = 1;
            t.stop();
            t.reset();
        }
    }
}

void getFONAreply()
{
    memset(buf, '\0', sizeof(buf));
    t.start();
    ended=0;
    count=0;
    while(!ended) {
        if(fona.readable()) {
            buf[count] = fona.getc();
            count++;
        }
        if(t.read() > timeout) {
            ended = 1;
            t.stop();
            t.reset();
        }
    }
}

我们正在这里使用ESP模块的代码,但它被注释掉了,我不认为这是问题所在。

以下是我们运行此代码时获得的响应。 Output from the FONA

我们在室内和室外尝试过这种方式,并且在调用功能之间有不同程度的时间,似乎没有任何东西可以使它工作。这尤其令人愤怒,因为这至少在昨晚给了我们坐标,即使它是错误的。现在,正如你所看到的,它根本没有给我们坐标。

有谁知道这里可能存在什么问题?似乎因为这个板块相对较新且未经测试,所以对于这些问题没有非常大的支持组。感谢您提供任何帮助!

旁注:有谁知道AmpI / AmpQ值是什么意思?我们认为这与信号强度有关,但似乎相当随意。

2 个答案:

答案 0 :(得分:0)

这只是硬件故障。 Adafruit向我们发送了一个新的FONA模块作为免费更换,更换模块工作正常。输出为Degree Minutes,需要转换为Decimal Minutes。

答案 1 :(得分:0)

如果使用有源天线,则需要焊接称为“偏置”的跳线。该跳线位于GPS天线连接器旁边。

这立即为我解决了问题:)