RAK3272 AT_PARAM_ERROR with AT+SEND

I’m struggling to successfully use the AT+SEND command. For example, my RAK3272s Ver. B Arduino AT Command mode software works with “AT+SEND” command when sending a fixed test message of Serial2.print(“AT+SEND=7:”); Serial2.println(“12345678901234567890123456789012”);
However, it results in AT_PARAM_ERROR when sending Serial2.print(“AT+SEND=7:”); Serial2.println(ctrCycles);

Response with Fixed Test data:
Data cycle count of 0

Data Send Number: 0
AT+SEND=7:12345678901234567890123456789012
OK
+EVT:SEND_CONFIRMED_OK

Response with Variable data:
Data cycle count of 0

Data Send Number: 0
AT+SEND=7:1
AT_PARAM_ERROR

Here is the full Arduino Code with “AT+SEND” (key AT+SEND section with RED Font):

#include <Arduino.h>

static char recv_buf[512];

volatile uint32_t startMillis = 0; // timer for LoRa upload response
const int timeout_ms = 10000; //timeout for LoRa upload response
const int join_timeout_ms = 20000; //timeout for JOIN
bool join = true;
bool stop = false;
volatile int ctr = 0;
const uint32_t timeLoopCycle = 30 * 60 * 1000; //repeat series of data sends every 30 minutes
volatile uint32_t timeNextDataSend = millis();
const uint32_t timePerDataSend = 2 * 60 * 1000; // time between each data send
const uint32_t numbDataSends = 10; // number of data sends per cycle
int ctrCycles = 0;

// RX TX Establish SWAN SERIAL2 port for the RAK3272 module
HardwareSerial Serial2(PA10, PA9); // This works to connect SWAN TX, RX pins to RAK3272S UART2 (which accepts AT commands)

//--------------------------------------------------------------------------------------------------------------
void setup()
{

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

Serial.begin(115200);
delay(1000);

Serial2.begin(115200);
delay(1000); //Serial port for RAK3272
Serial.println(“Setup started”);
delay(100);
Serial2.println(“AT”);
delay(100);
Serial2.println(“AT+BAND=5”);
delay(100);
Serial2.println(“AT+CLASS=A”);
delay(100);
Serial2.println(“AT+MASK=0002”);
delay(100);
Serial2.println(“AT+CHE=1:2”);
delay(100);
Serial2.println(“AT+CFM=1”);
delay(100);
Serial2.println(“AT+ADR=1”);
delay(100);

int ch;
int index;
startMillis = millis();
do
{
while (Serial2.available() > 0)
{
ch = Serial2.read();
recv_buf[index++] = ch;
Serial.print((char)ch);
delay(20);
}
} while (millis() - startMillis < join_timeout_ms);

delay(5000);

digitalWrite(LED_BUILTIN, LOW); // turn off LED to indicate Setup completed
}

//-------------------------------------------------------------------------------------------------------------
void loop()
{
int ch;
int index;

// Join Network if needed
if(join==true)
{
Serial.println(“send JOIN command”);
Serial2.println(“AT+JOIN=1:1:8:3”); //Set for confirmed data download and 3 retries
delay(5000);
startMillis = millis();
do
{
while (Serial2.available() > 0)
{
ch = Serial2.read();
recv_buf[index++] = ch;
Serial.print((char)ch);
delay(20);
}
} while (millis() - startMillis < join_timeout_ms);
Serial.println(" ");
Serial2.println(“AT+SEND=6:00”);
startMillis = millis();
index = 0;
do
{
while (Serial2.available() > 0)
{
ch = Serial2.read();
recv_buf[index++] = ch;
Serial.print((char)ch);
delay(20);
}
} while (millis() - startMillis < join_timeout_ms);

Serial.println(" ");
join = false;
delay(2000);

}

// Determine if data to be sent to the gateway now
if (timeNextDataSend < millis()) //test if time to send next data series
{
ctr=0;
stop = false;
Serial.print("Data cycle count of ");
Serial.println(ctrCycles);
ctrCycles++;
timeNextDataSend = millis()+timeLoopCycle; // set time for next loop cycle
}

// Send data to Gateway at interval
while (ctr < numbDataSends)
{
digitalWrite(LED_BUILTIN, HIGH); // Turn on LED when data to send to Gateway
Serial.println("…");
Serial.print("Data Send Number: ");
Serial.println(ctr);
delay(500);

  Serial2.print("AT+SEND=7:"); 
  Serial2.println("12345678901234567890123456789012");
  delay(500);
  //Serial2.print("AT+SEND=7:"); Serial2.println(ctrCycles);
  delay(100);


  startMillis = millis();
  index = 0;
  do
  {
    while (Serial2.available() > 0)
    {
      ch = Serial2.read();
      recv_buf[index++] = ch;
      Serial.print((char)ch); 
      delay(20);
    } 
  } while (millis() - startMillis < join_timeout_ms);

  digitalWrite(LED_BUILTIN, LOW);
  delay(timePerDataSend);
  ctr++;
}

if(ctr >= numbDataSends)
{
ctr = 0;
}
}

Hi Jim,

You show AT+SEND=7:1 which is causing the Parameter Error. The payload is in ascii hex and has to be an even number. E.g if you want to send the value of 1 the command would be AT+SEND=7:01

Check in our documentation for AT+SEND:

@beegee Bernd, thank you for the prompt response and guidance! I tried the following code revision but get the same error. I am still learning Arduino coding and have yet to figure out how to successfully convert the value of an int variable to hexidecimal value for the AT+SEND command:
String ctrCyclesHEX = String(ctrCycles,HEX);
Serial.print(“AT+SEND=7:”); Serial.println(ctrCycles, HEX);
Serial2.print(“AT+SEND=7:”); Serial2.println(ctrCyclesHEX);

Output:
AT+SEND=7:1
AT+SEND=7:1
AT_PARAM_ERROR

By the way, the documentation on AT+SEND at the 3272 product link doesn’t mention the value needs to be in HEX. RAK3272S Breakout Board AT Command Manual | RAKwireless Documentation Center.

Hi @jmeck

The link you shared is going to the old documentation, we have to change this.
The RAK3172 are today used with our RUI3 firmware and the correct documentation is RUI3.

For your code, I am not sure whether the two consecutive Serial2.print are working.

If your payload is a single integer, can you try to change this to

Serial2.printf("AT+SEND=7:%04X\r\n",ctrCycles);

If ctrCycles is 2569, this sends the string AT+SEND=7:0A09

@beegee. Bernd, my issue with the 3272S module is solved with your guidance on the AT+SEND value formatting and example Arduino printf code. I can now move forward with our application. Your prompt responsiveness and guidance is much appreciated.

I will also check that I using the current on-line documentation!

Thank-you!
Jim M

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