Serial Monitor only displaying 22 characters of longer strings. V. 2.3.2

Given my below code, with a Nano 328P:

#include <SoftwareSerial.h>
int i;
SoftwareSerial mySerial(3, 4);

void setup()
{
  mySerial.begin(9600);   // 4G LTE Module  
  Serial.begin(9600);    // Serial Monitor 
  delay(100);
}

void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
     Serial.println("Sending text Message through 4G LTE Module");
     mySerial.println("AT+CMGF=1\r");    //Set module Mode
     delay(100); 
     mySerial.println("AT+CMGS=\"727xxxxxxx\"\r");
     delay(100);
     mySerial.print("Hello Mom hope you are doing very well");
     delay(100);
     mySerial.write(0x1A); 
     delay(1000);
      break;

     case 'r':
      mySerial.println("AT+CNMI=2,2,0,0,0"); // To receive a live SMS
      delay(1000);
      break;

      case 'c':
      if(i==0)//i variable to ensure that only one call request will be sent by gsm during pressing and holding the pushbutton;
        {
          Serial.println("Calling through 4G LTE Module");
          delay(1000);
          mySerial.println("ATD727xxxxxxx;"); // ATDxxxxxxxxxx; semicolon should be at the last ;AT command that follows UART protocol;
          Serial.println("Calling 727xxxxxxx");
          delay(1000);
          i++;
         }
   i=0;
      
      break;
  }

 if (mySerial.available()>0)
   Serial.write(mySerial.read());
}

This is the result:

The full SMS text is sent to the recipient.
What might cause this?
Can it be corrected?

Please post your complete sketch and details of which Arduino board you are using

I note that in the code snippet that you posted there is only one print statement that outputs to the Serial monitor unless, of course, the mySerial interface is using the pins reserved for the Serial interface, which it should not be

Board type Nano, and full code added to original post.

How long is the receive buffer in SoftwareSerial?

And up your baud rate on Serial to 115200.

The receive buffer in Software Serial is 64 bytes.
The text: "Test from 4G LTE Longer message test" is 36 bytes.
Tested with baud at 115200 and has identical result.

Right, but how often is the code printing what's in the buffer? How many characters from the echoed commands are already in the buffer before your code gets around to emptying it?

Are you sure that you are actually receiving the characters that are not printing ?

No question Bob.
The full text is delivered in the SMS despite the serial monitor.
SMS

I was mainly very curious about this, not a deal breaker.

But, this text being cut-off matter is prying on my mind as I'm testing SMS message reception with SIM7600NA and SIM7670G modules, where the received SMS messages from the SIM7670G, using a certain library(Adafruit_Fona, not for SIM76XX) cuts off the last character of any length of SMS message. But works perfect for SIM7600. Very frustrating.

Let's do some counting.

  1. AT+CMGF=1 , a CR and another CR and LF. 12 characters.
  2. OK, a CR and LF. 4 more characters for a total of 16.
  3. AT+CMGS="727XXXXXXX", a CR and another CR and LF. 23 more characters for a total of 39.
  4. A 0x1A character, for a total of 40.
  5. > Hello from 4G LTE Modu, 24 more characters for a grand total of 64 characters in the receive buffer before your code gets around to printing anything that's in it.
2 Likes

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