Elecrow: 32u4 with A7 GPRS/GSM/GPS Board

I bought the subjected board because it looked cheap for a gps/gsm + accelerator project. The vendor is elecrow: https://www.elecrow.com/32u4-with-a7-gprs-gsm-gps-board.html And they provide some code in their wiki which is not good (to the best of my knowledge): https://www.elecrow.com/wiki/index.php?title=32u4_with_A7_GPRS/GSM

I am on Ubuntu 16 / Arduino 1.8.1 The board is a Mega32u4 with an A7 (gps/gprs/gsm). So it is based on a Leonardo.

First of all, elecrow in their website says that a battery is needed, however at the moment i do not have one to connect to it. It LOOKS LIKE the board is still working with usb.

So, after spending some time with it (softwareserial, hardwareserial, tinygps, tinygpsplus, adafruitgps ...) i decided to go for "simple".

Here is my code:

void setup() { while (!Serial); while (!Serial1);

Serial.begin(115200); Serial1.begin(115200); }

void loop() { Serial1.println("AT+GPS=1"); int c = Serial1.read(); Serial.println(c); delay(3000); }

Explanation: the two whiles are there to check for the serial ports (at some point I was wondering if there are indeed two serial ports, one for monitoring, one for communication to the gps, right?) According to their code i initiallize the baud of the the two ports to 115200. Then, according to this pdf the AT command "AT+GPS=1" should turn the GPS on. At this point I would like to mention, that somewhere i read that issuing a simple "AT" command should result in a simple "OK" which i never was able to get. Afterwards, reading from the communication serial1 i should get info from the gps - i assume. However, all i get is -1, meaning no data available.

That is my descritption. Any help would be appreciated. N.

I'm interested in playing with this board too. Don't have it yet, but do have something related.

What happens when, after AT+GPS=1 you try AT+GPSRD=1? According to my understanding, this sends the GPS NMEA stream down the "main" (AT) serial port.

Also, I'm not sure that GPS serial port is 115200. Try some lower speeds like 9600 or 19200?

Hi mikalhart!

Very nice to see somebody else is also interested.

If you see their wiki they suggest using a battery because USB power is not enough. It turns out that this is the problem - i believe. I do not have a battery with a JST connector but i used one from a cellphone of mine. So that battery (3.7 volt , 400 mah / in their picture one can see that they are using a 3.7 volt 1500mah), with tape and cabling (AND BEING CALM WHILE KEEPING THIS ALL TOGETHER :) ) was able to 'start up' the gps. By starting it up, i mean i received some NMEA data. I am not familiar with them - this is my first project, but at the moment i believe it is working. I received some stuff like the ones they provide in their wiki: https://www.elecrow.com/wiki/index.php?title=File:32U4_with_A7_test.png To answer your second question, i did not have to change the buadrate, 115200 works.

I am in the process of ordering some batteries, and JST cabling. I have communicated with the vendor to provide some info about the JST connectors they are using (also how to access the different ports: I2C, Digital, Analog). At the moment, having done some search myself and taking a look in the eagle files they provide, i believe that: Battery is a JST PH 2pin connector Others are JST PA 2pin/3pin/4pin connector (Analog/Digital/I2C). Are you familiar with this? Could you maybe verify?

My next steps, ordering the batteries to be able to provide power (extra). I will wait for their answer on the types of JST connectors before ordering them (unless you have a clue :) )

Here is a NeoGPS sketch I threw together for Pieter3, but never posted… :confused: It’s a non-blocking FSM implementation that:

* puts the A7 into GPS mode (2 states for GPS=1 and GPSRD=1),

* gets a location,

* cancels the GPS mode (2 states for GPSRD=0 and GPS=0),

* “sends” an SMS, and

* waits 5 seconds before doing it again.

Total cycle time is about 12 seconds. It just echoes the A7 response so you can see it, but you could also parse it to see if it says “OK”.

#include <NMEAGPS.h>

#define A7board Serial1  // Best:  Serial1 on a Mega, Leo or Due
//      or
//#include <AltSoftSerial.h>
//AltSoftSerial A7board; Next best, but you must use pins 8 & 9!  This is very efficient.
//      or
//#include <NeoSWSerial.h>
//NeoSWSerial A7thinker( 10, 11 ); // 2nd best on whatever two pins you want.  Almost as efficient.

NMEAGPS gps;
gps_fix fix;

//  Finite-State Machine declarations
enum state_t
  {
    WAITING,           // until time to check again
    GPS_ON_WAIT,       // after AT+GPS=1
    GPS_READING,       // after AT+GPSRD=1
    GPS_READING_WAIT,  // after location received, AT+GPSRD=0
    GPS_OFF_WAIT,      // after AT+GPS=0
    SENDING_SMS
    // other states?
  };
state_t  state = WAITING; // start here
uint32_t stateTime      ; // used for timeouts, instead of delay

const uint32_t CHECK_LOCATION_TIME = 5000; // ms, how often to check

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

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

void setup()
{
  Serial.begin( 115200 );
  A7board.begin( 9600 );
  stateTime = millis();
}

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 data off
          A7board.println(  F("AT+GPSRD=0") );

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

      if (millis() - stateTime > 1000) {
        Serial.print( '.' ); // still waiting for fix, print a dot.
        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:
      ignoreA7chars();

      // Wait for the GPS data to stop
      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

        // GPS data stopped, now 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, or other states...
      }
      break;

    //  ... other states ...
  }
}

You can test it with a regular GPS device on Serial1, but it will echo all the GPS characters to Serial. That’s the extent of my testing. :smiley:

If you want to try it, NeoGPS is available from the Arduino IDE Library Manager, under the menu Sketch → Include Library → Manage Libraries.

Cheers,
/dev

Some more info:

I received 'some' answer from the vendor:

'The IIC port is Arduino IIC port(A4,A5) breakout . you can use it as a normal Arduino IIC communication, also the D6,D7 and A0 is Arduino standard port.'

So i tried the D7. Looking into the eagle files the provide this JST port has 3 pins as: GND, +5 volt, D7 . I do not have JST connectors yet, but i do have some jumper wires (female to male). So i tried the 'blink' sketch with D7 and it worked. == just verifying how D7 works actually.

I haven't tried A0 or D6 or IIC.

Also when asking about the type of the JSTs, again i got 'some' answer: 'The JST connector is PA.'

So I believe, the battery is of type PH and the rest of type PA (different number of pins for those..)

I have order batteries, JST cables (PH for the batteries), and a charger.

I received batteries and JST PH 2pin cables which fit the 2pin battery port of the board. So yes, the battery port of the board is of type JST PH. HOWEVER, the male soldered JST PH port ON the board has been soldered the other way around. To my understanding red should be positive, black should be negative. The JST female cable i received can only fit in the male when red part goes into the negative and black into the positive. Beware. (of course it can be that the JST cables i received are soldered the other way around..... ).

Today I was playing with the board and I was able to receive my location (and data/time). I used TinyGps++ . However, what I thought I resolved with the battery is not actually true. The problem was, from the very beginning, that GPS would not turn on (with the AT+GPS=1 command). I thought the missing battery was the issue. But it turns out that it "might" not be. At the moment I am not sure whether it is or not. Sometimes the GPS turns on, sometimes not. When it's not, i always have the impression I burned the board.... But then it might come back. I have been playing around with battery, a little with the pins, and a little with the commands. But with no luck. Any help would be appreciated.

I got a little closer to the issue. In my setup code I have the following lines:

pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(8, OUTPUT); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(8, HIGH);

unfortunately I do not know what 4,5,8 pins stand for (at the moment, I didn't spend time checking those yet) - I use it as is, taken from the wiki of the provider. It looks like something is wrong perceived at these lines of code. My problem actually occurs when I remove power (usb cable) and battery (PH cable) from the board. Until this point I can receive data from GPS. As soon as they are removed (to my understanding this restarts the board) then I loose GPS data, actually i think that GPS never turns on again after this. Commenting out the above lines of code, looks like it brings again a condition where GPS can be turned on again (with the AT+GPS=1 command). The interesting thing is that restarting once again the board (cable + battery), the issue is back. But this time, UNcommenting the code, again brings the condition where GPS can be turned on again (with the AT command). I will try to figure out this weird condition and come back. If anyone has a comment on that, do not hesitate!

Updates...

I contacted the vendor and received some response in regards to pins 4,5 & 8. They are used to power on, power off and put to sleep (or wake up) of the A7 processor. The answer is not THAT clear but based on it I used the pins as: 8 : power on 4 : power off 5 : sleep

First of all, I need to set all 3 pins to output . Then:

  1. Power on: set PIN 8 to HIGH wait 3000ms set PIN 8 to LOW wait 500ms

the power on looks like a switch, first HIGH then LOW. Also the timings are based a bit on the provided code and email/answer and a bit on my sence....

  1. Power off: set PIN 4 to HIGH wait 3000ms set PIN 4 to LOW wait 500ms

the power off looks like switch, first HIGH then LOW. Also the timings are based a bit on the provided code and email/answer and a bit on my sence....

  1. Wake up set PIN 5 to HIGH wait 500ms

this time, wake up is not like a switch, only set to HIGH. Again the timing a bit of the provided code and email/answer a bit of sense..

  1. Put to sleep set PIN 5 to LOW wait 500ms

this time, sleep is not like a switch, only set to LOW. Again the timing a bit of the provided code and email/answer a bit of sense...

IMPORTANT: it took me a while to figure out that sometimes A7 misbehaves, In that case i needed to power it off and on again. For this reason, I always power it off before anything else (power on, wake up ...) Also, all this power management happens in setup() (arduino's setup). Not sure if it would work in loop().

I am using TinyGPS++ and GPS gets a fix with 3 to 4 satellites. Not sure if 3 or 4, but after having a fix I could see that number of satellites could be 4 and sometimes 3.

I have also succeeded in sending SMS but as soon as i succeeded I had to go back and see this power on/off thing. Will come back for SMS. Also succeeded in using M6050 (accelerometer on a GY-521 board) with the I2C port. Will come back with that too.

Hey I've been testing this board and it says a wrong gps position... 40km away

Anyone had same results?

Hey @kosnick, Its nice practical study that you shared here. Technically if you send "AT+GPS=1" to A7, it should turn on the GPS, to read the GPS data you must send "AT+GPSRD=1" to command A7 module to send the NMEA sentences of GPS module. No rush to get a valid GPS data, see https://en.wikipedia.org/wiki/Time_to_first_fix,

@Genjii55, did you decode the NMEA sentences on your own? I recommend you visit: https://rl.se/gprmc

I purchased a version which includes an SD-Card slot, but it came without any documentation, any tip? https://www.ebay.de/itm/AI-Thinker-GPS-BDS-GPRS-A9G-Board-32Mbit-C-SDK-GPIO-UART-ADC-I2C-SPI-MQTT-TFCard-/282891177801

I can't even understand if there is an ESP32 onboard, current firmware is an AT-commands FW.