0

println() function is being used to send AT commands to GSM module.

sim800l.println("AT+CLTS=1");
  delay(3000);
  sim800l.println("AT+COPS=2");
  delay(3000);
  sim800l.println("AT+COPS=0,0");
  delay(3000);

But problem is the output -

AT+CLTS=1

OK
AT+COP

The command AT+COP did not print fully? Why?
Minimal Reproducable Example -

#include <SoftwareSerial.h>    //Library required for serial communication
char MYDATA[18];
SoftwareSerial sim800l(3, 2); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted
void setup() {
  Serial.begin(9600); //Start the serial interface on 9600
  sim800l.begin(9600);
  delay(100);
  // AT command to set sim800l to SMS mode
  sim800l.println("AT+CMGF=1"); 
  //Serialcom();
  delay(100);
  // Set module to send SMS data to serial out upon receipt 
  sim800l.println("AT+CNMI=2,2,0,0,0");
  delay(100);
  sim800l.println("AT+CLTS=1");
  delay(3000);
  sim800l.println("AT+COPS=2");
  delay(3000);
  sim800l.println("AT+COPS=0,0");
  delay(3000);
   sim800l.println("AT+CCLK?");
  Serial.find("+CCLK: \"");
  Serial.readBytesUntil('\+', MYDATA, 17);

}

void loop() {
 Serial.print(MYDATA);
}
  • How / Where do you see the output and the response? – DataFiddler Jun 17 at 9:58
  • @DataFiddler Arduino Serial Monitor – Bhavya Gupta Jun 17 at 9:59
  • Could you provide a minimal, complete, reproducible example? stackoverflow.com/help/minimal-reproducible-example – Filip Franik Jun 17 at 10:00
  • ... please expand your code snippet to show this Serial Monitor output, too (at least). A minimal but complete test sketch were even better, of course. – DataFiddler Jun 17 at 10:02
  • Nothing in that code should print to the serial monitor. Show all your code. – Majenko Jun 17 at 10:02
0

You're overflowing the serial receive buffer. There's only a limited amount of space (64 bytes normally, maybe less in SoftwareSerial) for receiving data before you must read it or lose data. Since you are just blindly throwing commands at the SIM800 and not doing anything with its responses until right at the end all that incoming data fills the receive buffer to overflowing.

Your methodology is flawed (not your fault, the examples on the internet are all rubbish and teach you the wrong way of doing things). What you should be doing is issuing a command then receiving the response back and parsing it to see if the command was successful or not, and retrieve any information that the response may include that you would want to know.

| improve this answer | |
  • I do not want any info from the commands. I just want to blindly issue the command. How can I empty the buffer? – Bhavya Gupta Jun 17 at 10:14
  • Read it. Or if you don't care what it returns why are you even bothering to display anything at all? – Majenko Jun 17 at 10:15
  • Because the last command, I want to read the AT+CCLK result. My module does not gets latest time. So the all commands are neccessary so that AT+CCLK returns correct date. – Bhavya Gupta Jun 17 at 10:17
  • So you do want to read and interpret the responses then. At the very least you should be reading after every command and looking for either OK or ERR and discarding everything else. – Majenko Jun 17 at 10:19
  • 2
    Yes. read. while (sim800l.available()) { sim800l.read(); } – Majenko Jun 17 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.