0

I am currently working on a project with a friend of mine that involves GPS tracking. This is the FONA 3G GPS board that we are using from Adafruit. https://www.adafruit.com/product/3147

We are also using the recommended active GPS antenna with it. I can't post a link to it because of my low reputation.

We are prototyping the system on an mbed LPC1768 microcontroller. We wrote our own mbed code that sends AT commands to the FONA through the UART on the mbed, and then displays the reply on the computer through putty. We have tried several AT simple AT commands, such as manufacturer information and SIM card information, and those have worked fine. We have also tried more complex AT commands that request battery level and such, and those also worked. We are now having trouble with getting a GPS response. Last night at around 1 am we were able to get a GPS response with the AT+CGPSINFO command that shows us longtitude, latitude, bearing, and such. However, it was inacurrate by about 40 miles. Today when we went back to it to try and fix this, we are unable to receive any response whatsoever from the GPS. We can still receive responses from the battery level and other commands. It's just the GPS that is not responding. We have tried this indoors and out, and left the module running for over an hour in the GPSTEST mode, to no avail.

This is the code that we have so far.

#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();
        }
    }
}

There's also code for the ESP module that we're working with in here, but it's commented out and I don't believe that to be the issue.

Here is the response that we get when we run this code. Output from the FONA

We have tried this indoors and outdoors, and with varying degrees of time between calling functions, and nothing seems to make it work. This is especially infuriating because this was at least giving us coordinates last night, even though it was the wrong ones. Now, as you can see, it's not giving us at coordinates at all.

Does anyone have any idea what might be the issue here? It seems that because this board is relatively new and untested, there is not a very big support group for these problems. Thank you for any help you could give!

Sidenote: Does anyone know what the AmpI/AmpQ values mean? We figured it had something to do with signal strength, but it seems rather arbitrary.

2 Answers2

0

It was just a hardware failure. Adafruit sent us a new FONA module as a free replacement, and the replacement module worked fine. The output was in Degree Minutes and needs to be converted to Decimal Minutes.

0

if you are using an active antenna you need to solder the jumper called 'bias'. This jumper is next to the GPS antenna connector.

This fixed the problem straight away for me :)