SIM7000A Problem

Greetings All,

I hope everyone is having a joyful Christmas season, and I wish you all good health and fortune in the future.

My problem:

I recently integrated a SIM7000A GSM module into my project. It can send and receive with no problems. Below is my code so you will see that when I send the "ON" command via text message, the SIM7000A is supposed to reply that the "Vehicle Starter ENABLED" which works flawlessly. It's actually much faster that the old SIM800 2G module that I was using. When I send the "OFF" command, again it works flawlessly.

But when I send the "GETLOC" command, I can see in the serial monitor that the SIM7000A received the command. and the LED lights up like it is supposed to, but the SIM7000A never replies back. I also ran some tests and attached the data in the serial monitor. I have two (2) SIM7000A modules that I tested with and it seems that they both work fine. I'm not very good at writing code, in fact I got lots of help from users right here on this forum for which I am forever grateful. I was forced to upgrade the module due to the 2G shutdown. Any help would be appreciated. I'm sure it's probably something stupid but I know very little about troubleshooting code. Thank you all in advance.

It seems to be breaking on this piece of code; GSM.print(pesan);
When this line is commented out, I get the demographics but no map or coordinates. It looks like this line of code works with this string; String pesan = "https://maps.google.com/?q=" + String(lati, 8) + "," + String(longi, 6);

Here is the SIM7000A that I'm using

And some pictures of the ACTUAL board.


CODE

#include <TinyGPS++.h>
#include <Wire.h>
#include <SoftwareSerial.h>

int thermistorPin = A0;
float R1 = 100000;
float R2, logR2, logR2Cube, tK, tC, tF;
float A = 1.958207e-03, B = 4.097654e-04, C = -21.767827e-07;

SoftwareSerial GSM(10, 11);
SoftwareSerial neo(8, 9);
String textMessage;
String lampState;
String weekday = "";

double lati = 0;
double longi = 0;
double speed = 0;
uint32_t direction = 0;
uint32_t num_sat = 0;
double elevation = 0;

#define redLed    3
#define greenLed  5
#define blueLed   6
#define fan       13
const int relay = 12;
TinyGPSPlus gps;
const int timezone_hours = -4;
const int timezone_minutes = 0;

int utcsecond = 0;
int utcminute = 0;
int utchour = 0;
int utcday = 1;
int utcmonth = 1;
int utcyear = 2021; // obviously wrong (I am writing this in the year 2024)

int localminute = 0;
int localhour = 0;
int localday = 1;
int localmonth = 1;
int localyear = 2021; 

uint32_t daycount = 0;

void setup() {

  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(relay, OUTPUT);
  pinMode(fan, OUTPUT);
  digitalWrite(fan, HIGH);
  digitalWrite(redLed, HIGH);
  delay(500);
  digitalWrite(redLed, LOW);
  digitalWrite(greenLed, HIGH);
  delay(500);
  digitalWrite(greenLed, LOW);
  digitalWrite(blueLed, HIGH);
  delay(500);
  digitalWrite(blueLed, LOW);
  digitalWrite(relay, LOW);
  Serial.begin(115200);
  GSM.begin(9600);
  neo.begin(9600);
  GSM.listen();
  delay(5000);
  digitalWrite(greenLed, HIGH);
  Serial.print("GSM ready...\r\n");
  GSM.print("AT+CMGF=1\r\n");
  delay(1000);
  GSM.print("AT+CNMI=2,2,0,0,0\r\n");
  delay(1000);
  digitalWrite(greenLed, LOW);
  digitalWrite(fan, LOW);
  delay(3000);
  digitalWrite(fan, HIGH);
  
}

void loop() {
int Vout = analogRead(thermistorPin);

R2 = R1 * (1023.0 / Vout - 1.0);
logR2 = log(R2);
logR2Cube = pow(logR2, 3);

tK = (1.0 / (A + B * logR2 + C * logR2Cube));
tC = tK - 273.15;
tF = (tC * 9.0) / 5.0 + 32.0;

// Serial.print("Temperature: ");
// Serial.print(tF);
// Serial.println(" F");
// delay (1000);

if (tF > 100.0) {
  
  // Serial.print("Temperature is: ");
  // Serial.print(tF);
  // Serial.println("° F");  
  digitalWrite(fan, LOW);
}
 if (tF < 85.0) {
  digitalWrite(fan, HIGH);
 }

  GSM.listen();
  delay(2);


  while (GSM.available() > 0) {
    analogWrite(blueLed, 255);
    analogWrite(redLed, 100);
    textMessage = GSM.readString();
    Serial.print(textMessage);
    delay(10);
    analogWrite(blueLed, 0);
    analogWrite(redLed, 0);
  }
  neo.listen();
  if (textMessage.indexOf("ON") >= 0) {
    String array_string[20];
    string_splitting(textMessage,array_string,'\"');
    String NUMBER = array_string[1];
    digitalWrite(relay, HIGH);
    lampState = "ON";
    Serial.println("Vehicle Starter ENABLED\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + NUMBER + "\"\r");
    delay(500);
    GSM.print("Vehicle Starter ENABLED\r");
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
    digitalWrite(redLed, LOW);
    digitalWrite(greenLed, HIGH);
    delay(5000);
    digitalWrite(greenLed, LOW);

  }
  if (textMessage.indexOf("OFF") >= 0) {
    String array_string[20];
    string_splitting(textMessage,array_string,'\"'); 
    String NUMBER = array_string[1]; 
    digitalWrite(relay, LOW);
    lampState = "OFF";
    Serial.println("Vehicle Starter DISABLED!\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + NUMBER + "\"\r");
    delay(500);
    GSM.print("Vehicle Starter DISABLED\r");
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
    digitalWrite(greenLed, LOW);
    digitalWrite(redLed, HIGH);
    delay(5000);
    digitalWrite(redLed, LOW);
  }
    
  if (textMessage.indexOf("GETLOC") >= 0) {
    Serial.println("_____________________________________");
    smartDelay(1000);
    String array_string[20];
    string_splitting(textMessage,array_string,'\"'); // 
    String NUMBER = array_string[1];  
    Serial.println("GPS data Recived\r\n");
    textMessage = "";

    speed = gps.speed.mph();
    direction = gps.course.value();
    num_sat = gps.satellites.value();
    elevation = gps.altitude.feet();
    
    Serial.print("Speed: ");
    Serial.print(speed);
    Serial.println(" Miles Per Hour");
    Serial.print("Number of Satellites: ");
    Serial.println(num_sat);
    Serial.print("Raw course in 1/100 degrees = "); 
    Serial.println(direction);
    Serial.print("Elevation: ");
    Serial.print(elevation);
    if (elevation > 0) Serial.println(" ASL");
    if (elevation < 0) Serial.println(" BSL");
    if (elevation = 0) Serial.println(" AT SEA LEVEL");
    Serial.println("_____________________________________");
    GSM.println("AT+CMGS=\"" + NUMBER + "\"\r");
    delay(500);
    String pesan = "https://maps.google.com/?q=" + String(lati, 8) + "," + String(longi, 6);

    if (gps.time.isValid()) {
      utcyear = gps.date.year();
      utcmonth = gps.date.month();
      utcday = gps.date.day();
      utchour = gps.time.hour();
      utcminute = gps.time.minute();
      utcsecond = gps.time.second();

      Serial.println("UTC =  "+String(utchour)+":"+String(utcminute)+":"+String(utcsecond));

      localyear = utcyear;
      localmonth = utcmonth;
      localday = utcday;
      localhour = utchour + timezone_hours;
      localminute = utcminute + timezone_minutes;
      doLocalTimeCarries();
    }

    GSM.print("Date: ");
    daycount =  (localyear - 1601) * ((uint32_t)365);
    daycount += (localyear - 1601) / 4;
    daycount -= (localyear - 1601) / 100;
    daycount += (localyear - 1601) / 400;
    for (int i = 1; i < localmonth; i++) {
      daycount += days_in_month(localyear, i);
    }
    daycount += localday;
    switch (daycount % 7) {
      case 0:
        GSM.print("Sun  ");
        break;
      case 1:
        GSM.print("Mon   ");
        break;
      case 2:
        GSM.print("Tue   ");
        break;
      case 3:
        GSM.print("Wed   ");
        break;
      case 4:
        GSM.print("Thu   ");
        break;
      case 5:
        GSM.print("Fri   ");
        break;
      case 6:
        GSM.print("Sat   ");
        break;
      default:
        GSM.print("Bad   ");
        break;
    }
    GSM.print(localmonth);
    GSM.print("/");
    GSM.print(localday);
    GSM.print("/");
    GSM.println(localyear);
    GSM.print("Time: ");
    if (localhour < 10) GSM.print("0");
    GSM.print(localhour);
    GSM.print(":");
    if (localminute < 10) GSM.print("0");
    GSM.print(localminute);
    GSM.print(":");
    if (utcsecond < 10) GSM.print("0");
    GSM.println(utcsecond);
    GSM.print("Speed: ");
    GSM.print(speed);
    GSM.println(" MPH");
    GSM.print("Direction: ");
    // GSM.println(direction / 100.0);
    if  (direction < 1125) GSM.println("North");
else if (direction < 3375) GSM.println("NNE");
else if (direction < 5625) GSM.println("NE");
else if (direction < 7875) GSM.println("ENE");
else if (direction < 10125) GSM.println("East");
else if (direction < 12375) GSM.println("ESE");
else if (direction < 14625) GSM.println("SE");
else if (direction < 16875) GSM.println("SSE");
else if (direction < 19125) GSM.println("South");
else if (direction < 21375) GSM.println("SSW");
else if (direction < 23625) GSM.println("SW");
else if (direction < 25875) GSM.println("WSW");
else if (direction < 28125) GSM.println("West");
else if (direction < 30375) GSM.println("WNW");
else if (direction < 32625) GSM.println("NW");
else if (direction < 34875) GSM.println("NNW");
else GSM.println("North");
    GSM.print("Number of Satellites: ");
    GSM.println(num_sat);
    GSM.print("Elevation: ");
    if (elevation >= 0) {
      GSM.print(elevation);
      GSM.println(" Feet ASL");
    }
    else {
      GSM.print(-elevation);
      GSM.println(" Feet BSL");
    }
    GSM.print(pesan);
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");

    
  }
}


static void smartDelay(unsigned long ms) {
  unsigned long start = millis();
  do {
    neo.listen();
    delay(2);
    while (neo.available())
      gps.encode(neo.read());
  } while (millis() - start < ms);
  lati = gps.location.lat();
  longi = gps.location.lng();
  Serial.println(lati, 8);
  Serial.println(longi, 6);
}

void string_splitting(String splitMsg, String bb[], char delimiter) {
  int counter = 0 ;
  for ( int i = 0 ; i < splitMsg.length() ; i ++ ) {
    if ( splitMsg.charAt(i) == delimiter ) {
      counter++;
    }
    else {
      bb[counter] +=  splitMsg.charAt(i) ;
    }
  }
}


void doLocalTimeCarries() {
    if (localminute < 0) {
    localminute += 60;
    localhour--;
  }
  else if (localminute >= 60) {
    localminute -= 60;
    localhour++;
  }
  if (localhour < 0) {
    localhour += 24;
    localday--;
  }
  else if (localhour >= 24) {
    localhour -= 24;
    localday++;
  }
  if (localday < 1) {
    localmonth--;
    if (localmonth < 1) {
      localmonth += 12;
      localyear--;
    }
    localday += days_in_month(localyear, localmonth);
  }
  else if (localday > days_in_month(localyear, localmonth)) {
    localday -= days_in_month(localyear, localmonth);
    localmonth++;
    if (localmonth > 12) {
      localmonth -= 12;
      localyear++;
    }
  }
}

int days_in_month (int y, int m) {
  if ((m==4)||(m==11)||(m==9)||(m==6)) return 30; 
  if (m!=2) return 31;
  if ((y%400)==0) return 29; // leap year
  if ((y%100)==0) return 28; // not a leap year
  if ((y%4)==0)   return 29; // leap year
  return 28; // not a leap year 
}

SERIAL MONITOR DATA

GSM ready...
AT+CMGF=1
OK
AT+CNMI=2,2,0,0,0
OK
+CMT: "+12345678901",,"24/12/22,08:18:02-32"
ON
+CMT: "+12345678901",,"24/12/22,08:18:35-32"
ON
Vehicle Starter ENABLED
+CMT: "+12345678901",,"24/12/22,08:19:07-32"
OFF
Vehicle Starter DISABLED!
AT+CNMI=2,2,0,0,0
OK

GSM ready...
AT+CMGF=1
OK
AT+CNMI=2,2,0,0,0
OK
+CMT: "+12162884282",,"24/12/22,09:54:32-32"
GETLOC


41.20671844
-81.974182
GPS data Received
Speed: 2.62 Miles Per Hour
Number of Satellites: 5
Raw course in 1/100 degrees = 0
Elevation: 1006.56 ASL


UTC = 17:54:35

AT+CMGD=1,4

OK

Are you finding every "direction" is "NNW" or "North"?

Did you find when typing all those directions that they are all 2250 apart, so modulus, division and an element in an array of directions can do the same?

Hello and thanks for responding. No, actually the direction works great.

I see now. It does.

So I narrowed it down to the double spacing, which I have no idea why it's doing that. It didn't do that before so is there any reason that it's happening?

Here's how it worked under the SIM800L v2:

And here's what it's doing now:

I've found that I need to remove one of the lines in order for it to work. But all I need to do is get rid of the double spacing and everything will work great.

And just FYI, the map is actually a link to where I'm located at the time I get pinged. See this picture:

Today is my birthday and I'd love it if someone could help me out :slightly_smiling_face:

If the HTML is double-spacing, check that the return <BR> have not been replaced by a second <BR> or <P> ... <P> cause a paragraph separation (or change all the <P> and second <BR> back to <BR>)

Do not bump (add a post to bubble up) your topic.
Most who use sympathy for attention on this forum are lying or lazy... you are not, so do not.

Lol, okay I apologize. I will keep it in check. I was just being silly while I was working on this project. It's not HTML that I know of, it's when I use the GSM print command that it does the double spacing. I was just wondering if inside an at command or a GSM print command if there was any way to stop that from happening. It didn't happen with the old module but it is with the new module and it seems that the documentation is limited. I can't find any for this specific one.

Does the receive system you are using have a "No New Line" or "No CRLF" setting?

The GSM is using GSM.println()... is there a GSM.print() to eliminate the linefeed?

:birthday:

Yes but then everything goes on one line.

I do not follow this.

If a method of viewing data changed, the issue is in that change.

If i don't use GSM.println then all of the demographics go on one line insteal of separate single spaced lined. Any yes, i upgraded from a SIM800L v2, to a SIM7000A.

Ah. Use "\n" (that's a newline character) where you want line breaks in your GSM.print()

Perfect! As soon as i get home ill try it. Thanks!