AT command buffer

Hi, I started my journey with Arduino's and microcontrollers a few months ago. The learning curve has been steep since I have no prior knowledge, but over the past months I've been able to get a lot of programs working. However I'm now faced with a problem I'm unable to overcome so I'm reaching out to get some guidance/ assistance.

I've been working with a waveshare ESP32-S3 SIM7670G 4G development board to send sensor data over a sim connection to an api I created. The communication with the SIM7670G is working fine. But when I do a http read I'm only able to send short URL's,for example https://www.google.com to the sim. If I use a longer one the command gets truncated and returns an error.
I think it I the total length of the AT+PARRA command is limited to 64 bytes which is probably the buffer size. Unfortunately after reading the documentation of the board and the manufacturer of the SIM and searching the forum and internet I've not found a solution... can I increase the buffer size or is there another way to do this?

Here is the code I've been using

#include <Arduino.h>

static const int RXPin = 17, TXPin = 18;
static const uint32_t GPSBaud = 115200;

String rev;

void SentSerial(const char *p_char) {
  for (int i = 0; i < strlen(p_char); i++) {
    Serial1.write(p_char[i]);
    delay(10);
  }
  Serial1.write('\r');
  delay(10);
  Serial1.write('\n');
  delay(10);
}

bool SentMessage(const char *p_char, unsigned long timeout = 2000) {
  SentSerial(p_char);

  unsigned long start = millis();
  while (millis() - start < timeout) {
    if (Serial1.available()) {
      rev = Serial1.readString();
      if (rev.indexOf("OK") != -1) {
        Serial.println("Got OK!");
        return true;
      } else if (rev.indexOf("ERROR") != -1) {
        Serial.println("Got ERROR!");
        return false;
      }
    }
  }
  Serial.println("Timeout!");
  return false;
}

void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial1.begin(GPSBaud, SERIAL_8N1, RXPin, TXPin);

  // Initialize GSM module and set up SMS mode
  while (!SentMessage("AT", 2000)) {
    delay(1000);
  }

  SentSerial("AT+CGDCONT=1,\"IP\",\"https://iot.1nce.net\"");
  delay(500);
  SentSerial("AT+CGACT=1,1");
  SentSerial("AT+CSSLCFG=\"sslversion\",0,3");
  SentSerial("AT+CSSLCFG=\"authmode\",0,0");
  SentSerial("AT+HTTPINIT");

  SentSerial("AT+HTTPPARA=\"URL\",\"https://www.google.be\"");

  SentSerial("AT+HTTPACTION=0");
  SentSerial("AT+HTTPHEAD");
  SentSerial("AT+HTTPREAD=0,500");
  SentSerial("AT+HTTPTERM");
}

void loop() {
  if (Serial1.available()) {
    rev = Serial1.readString();
    Serial.println(rev);
  }
}

why do you mess with the timing when sending to the module char by char ? the 115200 bauds is managing the throughput.

try with just

void SentSerial(const char *p_char) {
    Serial1.println(p_char); // send the command followed by CR and LF
}

(the way you await for the answer is also not very robust as you depend on readString to timeout)

The SentSerial function was in the examples from the manufacturer of the board so I did not write that.

I just removed the delays in that function and this seems to have solved the problem. I just did a test with a 85 character URL and got the expected response.

Thanks for the advice !

use

void SentSerial(const char *p_char) {
    Serial1.println(p_char); // send the command followed by CR and LF
}

it does the same thing :wink:

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