Get Location from GSM module via GNSS

I am working with A7672s with Esp32, At commands are working fine but getting location from gnss.
Testing code:

// #define TINY_GSM_MODEM_SIM7600  // SIM7600 AT instruction is compatible with A7670
#define SerialMon Serial
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_TEST_BATTERY true
#define TINY_GSM_TEST_GPS true
#define RXD2 27
#define TXD2 26
char a, b;
#define Power_pin 4
#define gsm_rst 25
#define TINY_GSM_MODEM_A7672X


float gps_latitude  = 0;
float gps_longitude = 0;
float gps_speed     = 0;
int8_t  chargeState   = -99;
int8_t  chargePercent = -99;
int16_t milliVolts    = -9999;
float lat,lon;

#include <TinyGsmClient.h>
// #include<SoftwareSerial.h>
// SoftwareSerial SerialAT(27, 26);

TinyGsm modem(Serial1);
const char apn[]      = ""; //APN automatically detects for 4G SIM, NO NEED TO ENTER, KEEP IT BLANK

void setup()
{
  Serial.begin(9600);
  Serial1.begin(115200, SERIAL_8N1, RXD2, TXD2);

  Serial.println("\nconfiguring the GSM Module. Kindly wait");
  delay(1000);
  // pinMode(Power_pin,OUTPUT);

  // digitalWrite(Power_pin, HIGH);
  pinMode(gsm_rst,OUTPUT);
  delay(1000);
  digitalWrite(gsm_rst,LOW);
  delay(1000);
  digitalWrite(gsm_rst,HIGH);

  DBG("Initializing modem...");
  if (!modem.init()) {
    DBG("Failed to restart modem, delaying 10s and retrying");
    return;
  }

  String name = modem.getModemName();
  DBG("Modem Name:", name);

  String modemInfo = modem.getModemInfo();
  DBG("Modem Info:", modemInfo);


  Serial.println("Waiting for network...");
  if (!modem.waitForNetwork()) {
    Serial.println(" fail");
    delay(5000);
   
  }
  Serial.println(" success");

  if (modem.isNetworkConnected()) {
    Serial.println("Network connected");
  }


  // GPRS connection parameters are usually set after network registration
  Serial.print(F("Connecting to "));
  Serial.print(apn);
  if (!modem.gprsConnect(apn)) {
    Serial.println(" fail");
    delay(5000);
    return;
  }
  Serial.println(" success");
  delay(1000);

  if (modem.isGprsConnected()) {
    Serial.println("LTE module connected");
  }

  Serial.println("Enter Standard AT commands like AT, AT+CPIN?, AT+CCLK?, etc.");
  Serial.println("SELECT SERIAL PORT MONITOR AS \"BOTH NL & CR\" TO VIEW COMMAND RESPONSE CORRECTLY IF YOU ARE USING ARDUINO IDE");
  Serial.println("Refer A7600 series datasheet for entire list of commands");
  Serial.println("Understand the AT Commands properly");
  Serial.println("Incorrect AT commands can corrupt the 4G module memory!!!");

}


void loop()
{
 
  
  if (Serial.available() > 0) // read AT commands from user Serial port and send to the Module
  {
    a = Serial.read();
    Serial1.write(a);
    // Serial.print(modem.getGsmLocation());
  }
  if (Serial1.available() > 0) //read Response commands from module and send to user Serial Port
  {
    b = Serial1.read();
    Serial.write(b);
  }
}

Output:
AT+CGNSSTST=1

OK
AT+CGPSINFO

ERROR
AT+CGPSINFO=?

+CGPSINFO: (0-255)

OK
AT+CGPSINFO?

+CGPSINFO: 0

OK
AT+CGPSINFO

ERROR

try to send AT+CGPSINFO=1 prior to AT+CGPSINFO

getting only Ok response

Your equipment needs an unobstructed view of the sky.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.