Go Down

Topic: GPS vs Ai Thinker A7 module (Read 16012 times) previous topic - next topic

-dev

The code from that other thread assumes that you are not connecting the GPS_TXD line.

I would suggest connecting the GPS_TXD line to an Arduino receive pin, because you can get GPS information even when the A7 is busy doing something else, and you don't have to send special commands to make the A7 "forward" the GPS information to the U_TXD pin.

Did you try anything I suggested in reply #28?

charlilio

#31
Oct 12, 2017, 07:30 pm Last Edit: Oct 12, 2017, 07:43 pm by charlilio
The code from that other thread assumes that you are not connecting the GPS_TXD line.

I would suggest connecting the GPS_TXD line to an Arduino receive pin, because you can get GPS information even when the A7 is busy doing something else, and you don't have to send special commands to make the A7 "forward" the GPS information to the U_TXD pin.

Did you try anything I suggested in reply #28?
hi sir -dev

i've try what you said on reply #28 but the data gps still not showing.

on serial monitoring just show message like this :

AT+GPS=1
AT+GPSRD=1
Waiting for GPS fix...............................................................................................

and here my config pin

A7 ===== Uno

GND======> GND
GPS_TDX===> PIN 0
U_RXD ====> PIN 8
U_TXD ====> PIN 9

and for the code i still use this thread on reply #10

and i use :

#include <AltSoftSerial.h>
AltSoftSerial A7board;

is it there something wrong sir?
because i still not get gps data

-dev

Unfortunately, I see that GPS_TXD may not provide NMEA data (see reply #20).

If you tried this:

Code: [Select]
#include <AltSoftSerial.h>
AltSoftSerial A7board;

#define gpsPort Serial // just an alias so it is easier to read below

void loop()
{
  switch (state) {

      ...

    case GPS_READING:
      while (gps.available( gpsPort )) { // parse the NMEA data from pin 0
        fix = gps.read(); // this structure now contains all the GPS fields

... and did not get any GPS data, then GPS_TXD does not work.

You may have to try the command sequence in reply #25.

You could try the NeoGPS example NMEA.ino.  It expects to receive GPS data on Arduino pin 8, if you can connect it to the GPS_TXD pin.  If you don't want to move wires, you must edit GPSport.h to use Serial (see Installation instructions).

Or try a simple echo test:

Code: [Select]
void setup()
{
  Serial.begin( 9600 );
}

void loop()
{
  if (Serial.available()) // any GPS characters?
    Serial.write( Serial.read() ); // echo to Serial Monitor window
}

If you see NMEA sentences, like $GPRMC or $GPGGA, then GPS_TXD does work.

tcotduino01

#33
Oct 13, 2017, 01:07 am Last Edit: Oct 13, 2017, 01:22 am by tcotduino01
Well... there is a lot of things going wrong according to my experiments of today.

I have the exact same module as charlilio.

1 - The provided antenna is super weak, there is no way you could lock a signal indoors. I had to go outdoors to acquire a signal and finally see it working. Even outdoors, it take ages to acquire the satellites and sometimes, the signal drops and go to acquiring forever.

2 - The way the sketch works is not helping either. It sends commands to the GPS module which blocks everything on it until it get a proper GPRMC. Then it sends a AT+GPS=0, then eratic commands if I refer to the TTY output where I got a series of random OK OK OK OK OK OK OK *OK OK * GPSRD=5 OK ....etc....
At some point, it resends the AT+GPS=1 followed by AT+GPSRD=1 and... you wait forever because the module is stuck.

3 - Using the GPSRD method adds an annoying +GPSRD: in front of the first line $GPGGA, parsers cannot understand that line.

Finally I ended up with a very basic setup to make sure that the GPS is working properly and I will see later how I could automate and parse that nicely with an Arduino UNO. I never achieved to lock a signal indoors though.

My goal is to make it working with an arduino mini pro or even an ATtiny.

Hardware:

- Arduino UNO R3
- A7 GPRS/GPS/GSM module (if you don't want to press that *$$$##@@ button everytime you power it, you can short v_BAT and PWR_KEY. It is documented ....in chinese...

Connections:

A7                UNO

U_TXD          TX (pin1)
U_RXD          RX (pin 0)
GND             GND

Sketch:

Load a new blank sketch on the Arduino and once done, open a monitor at 9600 bauds.


Commands:

AT    check connection, should reply OK

AT+GPS=1       start the GPS module, powers the GPS antenna at 1.79 V, start searching satellites and push data to GPS_TXD

AT+GPSRD=1   forwards the GPS data to the UART ports whilst still pushing the data on GPS_TXD

GPS_TXD can be connected to TX on UNO once the GPS module has been started.

AT+GPS=0        stops the GPS module and stops the power on the GPS antenna

AT+GPSRD=0   stops the forwarding of GPS data to the console while keeping the data flow to GPS_TXD

If you want to check the data, there is a free online parser here


charlilio

Hi sir  tcotduino01 and -dev

I've tried the suggestions from both of you, but it does not work both...

so i've another sample from this but i stuck on "AT+CPIN?" and wait forever because the module is stuck.

Connection :

A7 ====== UNO

GND        ==> GND
GPS_TXD ==> PIN 10
U_TXD     ==> PIN 0
U_RXD     ==> PIN 1

for power A7 i use external power adaptor 9v also i connected the pwr_key pin to v_bat pin.
for power uno i use usb cable.

here the following my code :
Code: [Select]

#include <NeoSWSerial.h>
NeoSWSerial gps(10,11); // RX, TX

//String str="";
char str[70]; //is used for storing received message from GSM module
String gpsString=""; //is used for storing GPS string

char *test="$GPGGA"; //is used to compare the right string that we need for coordinates.

String latitude="No Range      ";
String longitude="No Range     ";

int temp=0,i;
boolean gps_status=0;

void setup()
{
 
  Serial.begin(9600);
  gps.begin(9600);

  Serial.println("Vehicle Tracking");
 
  delay(2000);
  gsm_init();
 
  Serial.println("AT+CNMI=2,2,0,0,0");
  Serial.println("GPS Initializing");
 
  Serial.println("  No GPS Range  ");
  get_gps();
  delay(2000);
 
  Serial.println("GPS Range Found");
 
  Serial.println("GPS is Ready");
  delay(2000);
 
  Serial.println("System Ready");
  temp=0;
}

void loop()
{
  serialEvent();
  if(temp)
  {
    get_gps();
    tracking();
  }
}

void serialEvent() //is used for receiving message from GSM and comparing the received message with predefined message (Track Vehicle).
{
  while(Serial.available())
  {
    if(Serial.find("Track Vehicle"))
    {
      temp=1;
      break;
    }
    else
    temp=0;
  }
}

void gpsEvent() // is used for receiving GPS data into the Arduino.
{
  gpsString="";
  while(1)
  {
   while (gps.available()>0)            //checking serial data from GPS
   {
    char inChar = (char)gps.read();
     gpsString+= inChar;                    //store data from GPS into gpsString
     i++;
     if (i < 7)                     
     {
      if(gpsString[i-1] != test[i-1])         //checking for $GPGGA sentence
      {
        i=0;
        gpsString="";
      }
     }
    if(inChar=='\r')
    {
     if(i>65)
     {
       gps_status=1;
       break;
     }
     else
     {
       i=0;
     }
    }
  }
   if(gps_status)
    break;
  }
}


// gsm_init() is used for initialising and configuring the GSM Module, where firstly, GSM module is checked whether it is connected or not by sending 'AT' command to GSM module.
// If response OK is received, means it is ready. System keeps checking for the module until it becomes ready or until 'OK' is received.
// Then ECHO is turned off by sending the ATE0 command, otherwise GSM module will echo all the commands.
// Then finally Network availability is checked through the 'AT+CPIN?' command, if inserted card is SIM card and PIN is present, it gives the response +CPIN: READY.
// This is also check repeatedly until the network is found. This can be clearly understood by the link Video : https://www.youtube.com/watch?v=2Ud6sB3A8j0

void gsm_init()
{
 
  Serial.println("Finding Module..");
  boolean at_flag=1;
  while(at_flag)
  {
    Serial.println("AT");
    while(Serial.available()>0)
    {
      if(Serial.find("OK"))
      at_flag=0;
    }
   
    delay(1000);
  }

 
  Serial.println("Module Connected..");
  delay(1000);
 
  Serial.println("Disabling ECHO");
  boolean echo_flag=1;
  while(echo_flag)
  {
    Serial.println("ATE0");
    while(Serial.available()>0)
    {
      if(Serial.find("OK"))
      echo_flag=0;
    }
    delay(1000);
  }

 
  Serial.println("Echo OFF");
  delay(1000);
  Serial.println("Finding Network..");
  boolean net_flag=1;
  while(net_flag)
  {
    Serial.println("AT+CPIN?");
    while(Serial.available()>0)
    {
      if(Serial.find("+CPIN: READY"))
      net_flag=0;
    }
    delay(1000);
  }
  Serial.println("Network Found..");
  delay(1000);
 
}

void get_gps() //has been used to extract the coordinates from the received string.
{
   gps_status=0;
   int x=0;
   while(gps_status==0)
   {
    gpsEvent();
    int str_lenth=i;
    latitude="";
    longitude="";
    int comma=0;
    while(x<str_lenth)
    {
      if(gpsString[x]==',')
      comma++;
      if(comma==2)        //extract latitude from string
      latitude+=gpsString[x+1];     
      else if(comma==4)        //extract longitude from string
      longitude+=gpsString[x+1];
      x++;
    }
    int l1=latitude.length();
    latitude[l1-1]=' ';
    l1=longitude.length();
    longitude[l1-1]=' ';
    Serial.println("Lat:");
    Serial.println(latitude);
    Serial.println("Long:");
    Serial.println(longitude);
    i=0;x=0;
    str_lenth=0;
    delay(2000);
   }
}

void init_sms() //used to initialising and sending message
{
  Serial.println("AT+CMGF=1");
  delay(400);
  Serial.println("AT+CMGS=\"+62**********\"");   // use your 10 digit cell no. here
  delay(400);
}

void send_data(String message)
{
  Serial.println(message);
  delay(200);
}

void send_sms() //used to initialising and sending message
{
  Serial.write(26);
}

void lcd_status()
{
 
  Serial.println("Message Sent");
  delay(2000);
  Serial.println("System Ready");
  return;
}

void tracking()
{
    init_sms();
    send_data("Vehicle Tracking Alert:");
    send_data("Your Vehicle Current Location is:");
    Serial.print("Latitude:");
    send_data(latitude);
    Serial.print("Longitude:");
    send_data(longitude);
    send_data("Please take some action soon..\nThankyou");
    send_sms();
    delay(2000);
    lcd_status();
}


is there something wrong with the code ?

charlilio

hi guys

but when i use this code

Code: [Select]
#include <SoftwareSerial.h>

byte RX = 10; // This is your RX-Pin on Arduino UNO,connect with A7 UTXD pin
byte TX = 11; // This is your TX-Pin on Arduino UNO,connect with a7 URXD pin
SoftwareSerial *A7board = new SoftwareSerial(RX, TX);

void print_result()
{
  Serial.print("A7 board info: ");
  while( A7board->available() != 0)
    Serial.write( A7board->read());
   
  Serial.println(); 
}
//--------------------------------------------------------------------

void setup() {
  Serial.begin(115200);
  A7board->begin(115200);
  delay(200);

  Serial.println("Send AT command"); 
  A7board->println("AT");
  delay(25000);
  print_result();
 
  Serial.println("AT+GPS turn on"); 
  A7board->println("AT+GPS=1"); 
  delay(10000);
  print_result();
 
  Serial.println("AT+GPSRD turn on"); 
  A7board->println("AT+GPSRD=1"); 
  delay(10000);
  print_result();






 
}
//--------------------------------------------------------------------

void loop() {
  print_result();
  delay(2000);
}
//--------------------------------------------------------------------


serial monitor showing this :

Code: [Select]

Send AT command
A7 board info: OK


)⸮TZV:17/10/0n,14:25:36,)`7


⸮⸮RQ⸮'⸮⸮⸮٥⸮⸮⸮⸮j

AT+GPS turn on
A7 board info: AT+GPS=1
OK


AT+GPSRD turn on
A7 board info: AT+GPSQD=1

OK

)⸮PSRD:$GPGT⸮bbbbb⸮b⸮⸮babj⸮bj⸮b⸮⸮⸮⸮R⸮⸮j
$GP


A7 board info:
+GPSRD:$G⸮GGA,,,,,,0.00,,,M,,M,,0000*66
$GPQMC,,V,,,,,,&,,,N


A7 board info:
)⸮PSRD:$GPGG@\,,,,,0,00,.,M,,M,,0000)66
$GPGSA,P)bbbbbbbbbab


A7 board info:
+GPSRB:$GPGGA,,,.,,0,00,,,M,.M,,0000*66
$GPRMC,,V,,.,,,,,,,N
A7 board info:
+GPSRD:$u⸮bbbbb⸮b⸮⸮bbbj⸮bj⸮b⸮⸮⸮⸮R⸮⸮j
$GPQMC,,V,,,,,,.,,,N*


A7 board info:
+GPSRD:$G⸮GGA,,,,,,0.00,,,M,,M,,0000*66
$GPG⸮A,A,1,,,,,.,,,,




what is this, it is mean gps data ???

Go Up