Go Down

Topic: Get GPS Long & Lat and send loc by sms (Read 199 times) previous topic - next topic

charlilio

Hi all, i am newbies on arduino and i want make some tool's for my thesis, hope somebody can help me to solved my problem, and here the feature hope i can to created :

- when i send sms to number on module a7 example : "GIVE ME POSITION"

and then the a7 module can send current or last position to my number with a link that can be opened by google map or other map.

- when i send sms to number on module a7 example : "TRUN OFF THE LIGHT"

and then relay will trun off the light or lamp.


here my tools :

- Arduino Uno
- AI Thinker A7 quad band GPRS GSM SMS GPS MODULE 5V SERIAL TTL
- relay 2 channel
and some other stuff like, breadboard cable jumper male,female.

and here the config :

Ai A7 ------ Arduino Uno
U_TXD ==> PIN 10
U_RXD ==> PIN 11
GND    ==> GND

power arduino uno use with usb cable
power ai a7 with external power (adaptor 9v) and here is my a7-module

i've been looking couple days for module a7 but i stil have not found how to use this module
i was try some example code like tiny gsm but still not work and i try to follow the code from this forum on thread #10 about how to use gps with a7 module.

and these last code i try but gps data still not showing, i follow these code from this thread #10 
i am really sorry if there any mistake or wrong setting to make this tools, hopefully somebody can help me out and thank you in advance for your help.

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

//#define A7board Serial  // Best would be to connect to the Serial pins 0 & 1
//      or
//#include <AltSoftSerial.h>
//AltSoftSerial A7board; //Next best, but you must use pins 8 & 9!  This is very efficient.
//      or

#include <NeoSWSerial.h>
NeoSWSerial A7board( 10, 11 ); // 2nd best on whatever two pins you want.  Almost as efficient.
// DO NOT USE SoftwareSerial!

NMEAGPS gps;
gps_fix fix;

enum state_t { WAITING, READING_GPS, GPS_ON_WAIT, GPS_READING, GPS_READING_WAIT, GPS_OFF_WAIT, SENDING_SMS }; // other states?
state_t state = WAITING;
uint32_t stateTime;
const uint32_t CHECK_LOCATION_TIME = 5000; // ms

void echoA7chars()
{
  while (A7board.available())
    Serial.write( A7board.read() ); // just echo what we are receiving
}

void ignoreA7chars()
{
  while (A7board.available())
    A7board.read(); // ignore what we are receiving
}

void setup()
{
  Serial.begin( 115200 );
  A7board.begin( 115200 );
}

void loop()
{
  switch (state) {

    case WAITING:
      echoA7chars();

      if (millis() - stateTime >= CHECK_LOCATION_TIME) {

        // Turn GPS data on
        A7board.println( F("AT+GPS=1") );

        stateTime = millis();
        state     = GPS_ON_WAIT;
      }
      break;

    case GPS_ON_WAIT:
      echoA7chars();

      // Wait for the GPS to turn on and acquire a fix
      if (millis() - stateTime >= 5000) { // 5 seconds

        //  Request GPS data
        A7board.println( F("AT+GPSRD=1") );
        Serial.print( F("Waiting for GPS fix...") );

        stateTime = millis();
        state     = GPS_READING;
      }
      break;

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

        if (fix.valid.location) {
          Serial.println();

          // Now that we have a fix, turn GPS mode off
          A7board.println(  F("AT+GPSRD=0") );

          stateTime = millis();
          state     = GPS_READING_WAIT;
        }
      }

      if (millis() - stateTime > 1000) {
        Serial.print( '.' ); // if still waiting for fix, print a dot.
        Serial.print('\n');
        stateTime = millis();
      }
      break;

    case GPS_READING_WAIT:
      ignoreA7chars();

      // Wait for the GPS data to stop
      if (millis() - stateTime >= 1000) {

        // Turn GPS power off
        A7board.println(  F("AT+GPS=0") );

        stateTime = millis();
        state     = GPS_OFF_WAIT;
      }
      break;


    case GPS_OFF_WAIT:
      echoA7chars();

      // Wait for the GPS to power off
      if (millis() - stateTime >= 1000) {

        // Show the location we will send via SMS
        Serial.print( F("loc: ") );
        Serial.print( fix.latitude(), 6 ); // use the latitude field of the fix structure
        Serial.print( F(", ") );
        Serial.println( fix.longitude(), 6 ); // use the longitude field of the fix structure

        // Send SMS with location values ?
        //A7board.print( SMS commands? );
        //A7board.print( F("lat=") );
        //A7board.print( fix.latitude(), 6 ); // use the latitude field of the fix structure
        //  ...

        stateTime = millis();
        state     = SENDING_SMS;
      }
      break;
      
    case SENDING_SMS:
      echoA7chars();

      if (millis() - stateTime >= 2000) {
        stateTime = millis();
        state     = WAITING; // start over
      }
      break;

    
  }
}

jremington

You must be outside, with a clear view of the sky, for GPS to work.

charlilio

You must be outside, with a clear view of the sky, for GPS to work.
hi sir jremington,


thank you for reply my post :)

i've try on out side with clear view of sky but it's still not working, do you have any solution?

or some example code to get gps data with A7 module?

because i've been looking for couple days but still not get the example or solution to get gps fix data with this module.

thank you :)

jremington

#3
Oct 12, 2017, 10:35 pm Last Edit: Oct 12, 2017, 10:36 pm by jremington
Quote
but it's still not working,
Define "not working".

Describe what do you expect your program to do, and what it does instead. Post an example of the output.

charlilio

Define "not working".

Describe what do you expect your program to do, and what it does instead. Post an example of the output.
here are the serial monitor show :

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

and it loop never ending ...

as I said in the first post. I want to create a tool that can transmit gps location data on the tool by:

I send an sms to the phone number in module a7, for example:

"get position"

and can turn off the electric current by sms also to the existing phone number dimodul a7, for example:

"turn off the electric current"

but until now i don't know how to get the a7 module get work and get gps data sir, is it clear sir?


jremington

#5
Oct 13, 2017, 05:42 pm Last Edit: Oct 13, 2017, 05:43 pm by jremington
Are you doing these tests outside, with a clear view of the sky?

It can take up to 15 minutes for a "cold start" satellite fix to be successful.

charlilio

Are you doing these tests outside, with a clear view of the sky?

It can take up to 15 minutes for a "cold start" satellite fix to be successful.
i've try this but still not working, serial monitor just showing :


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

can you give example how to use Ai Thinker A7 module to get gps data sir, please...


Thank You

Go Up