0

I have a sim800l module connected to the Rpi pico hardware UART

/*
SIM800       RPi Pico
5v           *External 2A 5v supply*
GND          GND
VDD          3v3
TXD          GP1
RXD          GP0
*/

void setup()
{
  Serial.begin(115200);

  while (!Serial)
    ;

  Serial1.begin(9600);

  Serial.print("Initializing");
  delay(1000);
  Serial.print(".");
  delay(1000);
  Serial.print(".");
  delay(1000);
  Serial.println(".");

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);


  Serial1.println("AT"); //Once the handshake test is successful, it will back to OK
  updateSerial();
  delay(3000);

  Serial1.println("ATI"); //Returns the module name and revision.
  updateSerial();
  delay(3000);

  Serial1.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged
  updateSerial();
  delay(3000);

  Serial1.println("AT+COPS?"); //Checks which network you are connected to
  updateSerial();
  delay(3000);

  Serial1.println("AT+COPS=?"); //Returns the list of operators present in the network.
  updateSerial();
  delay(3000);

}

void loop()
{
  updateSerial();
}

void updateSerial()
{
  delay(200);
  while (Serial.available())
  {
    Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while (Serial1.available())
  {
    Serial.write(Serial1.read());//Forward what Software Serial received to Serial Port
  }

}

terminal response

AT
OK
ATI
SIM800 R14.18

OK
AT+CCID
XXXXXXXXXXXXXXXXXXXX
AT+COPS?
+COPS: 0,0,"Vodaa TelAT+COPS=?
+COPS: (2,"Vodaa Telecom","Ver

From what i know so far the SIM800L always ends its response with an "OK" but there are some commands that are cut short and not end with OK. such as AT+CDID and AT+COPS. I do not know if the problem is with the pico or with sim800l. The sim800l seems to be working fine so i suspect its with the pico but if so, it might be a problem with the internal libraries which is beyond me. To supoort that theory the number of characters that is being cut is about 20 characters, so it might be a setting i have to adjust

DrakeJest
  • 201
  • 1
  • 7
  • hint: `always ends its response with an "OK"` ... there is more than OK in the response ... count the number of characters that are actually received – jsotola Dec 09 '22 at 16:57
  • the 115200 baud is slow. there are gaps between bytes so `while (Serial1.available())` can end before the complete response is read – Juraj Dec 09 '22 at 18:09
  • @jsotola im sorry i dont get it.. I counted how many serial1.read() pe command. AT=9 character, ATI = 27 , AT+CCID=31, AT+COPS? = 31, AT+COPS=? is 9 followed by a long pause then responded with another 31. looks like 31 is the limit, – DrakeJest Dec 09 '22 at 18:10
  • @Juraj i dont think i can go any higher than that, i tried to explore that end thinking it was a baud rate issue, according to [this thread](https://arduino.stackexchange.com/questions/36039/sim800l-change-default-baud-rate) 115200 is the highest it can go – DrakeJest Dec 09 '22 at 18:13
  • I didn't suggest higher baud rate but proper reading of the input – Juraj Dec 10 '22 at 06:45

1 Answers1

0

Took me quite a while, but upon reading the pico's documentation

The size of the receive FIFO may also be adjusted from the default 32 bytes by using the setFIFOSize call prior to calling begin()

Serial1.setFIFOSize(128); 
Serial1.begin(baud);

settinng it to a much higher value like 256 solves the problem

DrakeJest
  • 201
  • 1
  • 7