I need to stop displaying "AT+CSQ, OK, commands" for SIM808

#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8);  //software serial instance for GPS/GSM module
String latlongtab[5];  // for the purpose of example let array be global
#define DEBUG true
String state, timegps, latitude, longitude;

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);           //open serial port
  delay(50);

  /*We can use old sendData function to print our commands*/
  sendData("AT+CGNSPWR=1", 1000, DEBUG);     //Initialize GPS device
  delay(50);
  sendData("AT+CGNSSEQ=RMC", 1000, DEBUG);
  delay(150);
}

void loop() {
  sendTabData("AT+CGNSINF", 1000, DEBUG);  //send demand of gps localization
  sendData("AT+CSQ", 1000, DEBUG);
  if (state != 0) {
    Serial.println("State: " + state + " Time: " + timegps + "  Latitude: " + latitude + " Longitude " + longitude);
  } else {
    Serial.println("GPS initializing");
  }
}

void sendTabData(String command, const int timeout, boolean debug) {
  mySerial.println(command);
  long int time = millis();
  int i = 0;

  while ((time + timeout) > millis()) {
    while (mySerial.available()) {
      char c = mySerial.read();
      if (c != ',') {                  //read characters until you find comma, if found increment
        latlongtab[i] += c;
        delay(100);
      } else {
        i++;
      }
      if (i == 5) {
        delay(100);
        goto exitL;
      }
    }
  }
exitL:
  if (debug) {
    /*or you just can return whole table,in case if its not global*/
    state = latlongtab[1];     //state = recieving data - 1, not recieving - 0
    latlongtab[1] = "";
    timegps = latlongtab[2];
    latlongtab[2] = "";
    latitude = latlongtab[3];  //latitude
    latlongtab[3] = "";
    longitude = latlongtab[4]; //longitude
    latlongtab[4] = "";
  }
}

String sendData(String command, const int timeout, boolean debug) {
  String response = "";
  mySerial.println(command);
  long int time = millis();
  int i = 0;

  while ( (time + timeout) > millis()) {
    while (mySerial.available()) {
      char c = mySerial.read();
      response += c;
    }
  }
  if (debug) {
    Serial.print(response);
  }
  return response;
}

for the purpose of storing the data in a cloud, i am looking for a way to not display the commands. I only need LAT and LON and the RSSI (signal strength) to display. i dnt want the bolded to be displayed.

OK
AT+CGNSSEQ=RMC

OK
,0.00,0.0,0,,,,,AT+CSQ

+CSQ: 6,0

OK
State: 0 Time: 19800105235948.000 Latitude:-33.933 Longitude:18.982,,,,,AT+CSQ

+CSQ: 6,0

Sending ATE0 will stop the echo but not stop the answers from the module.
The answers are important to know if your command has been handled.
you should have a way to process them


please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's unreadable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)

Noted Thank you!

I edited it a bit more (indentation, removed weird tags)

I only need LAT and LON and the RSSI (signal strength) to display. i dnt want the bolded to be displayed.

I would suggest to study Serial Input Basics to handle this

[quote="newcomer05, post:1, topic:863702"]

#define DEBUG true
.
.
.
  if (debug) {
    Serial.print(response);
  }

Maybe you need:
#define debug false
in place of
#define DEBUG true

Hy, thank you,
however it does not display anything when changed to #define DEBUG false mayb is because of my coverage.

Hint: we can't see your code.

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