HC-12 3 seconds to receive message

I have a question in regards to my HC-12's. I noticed it takes about 3 seconds for one to receive a message from the other (loop delay is at 10ms). Sending a single character takes around the same amount of time as sending 600 and they are only 8 inches apart. I am using a baud rate of 9600 and FU3 with full power. I noticed even using AT commands took the same 3 seconds before it responded in the serial monitor. Any ideas what this may be? I would assume the time would be at most 100ms at this distance with my current settings. They seem to be working correctly as they were talking fine at around 420 meters (there was some trees and road in the way so they could not see each other at all). Could this be due to the serial monitor?

Edit: So I just tested by instead sending a bool and it sends/receives no problem at 40ms (didnt test lower). Is this just an issue with println or sending strings with arduinos? I know in general its slower but I dont see why its that much slower.

A bool is the same size as a char so sending a bool or a single char should not make a difference.
Note that functions like readString, readBytesUntil etc have a timeout; maybe that's your problem.

I'm not familiar with HC-12 but I suggest that you post both your sender code and receiver code.

I had a problem with my LoRa radios taking 600 ms to send 24 characters. When I shut off the OLED display and most Serial monitor messages that dropped to 7 ms.

Are you using .readString()? That doesn't end until a timeout. The default timeout is one second but you can set the number of milliseconds of timeout with .setTimeout().

Show your code.
I am using HC-12 and it received the message with 30 bytes in about of 30 milliseconds

Heres the current test logic for the receiver for reference

void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial1.setTimeout(10);
}

void HandleSendReceive()
{
  if(Serial.available() > 0)
  {
    String input = Serial.readString();
    Serial1.println(input);
  }
 
  if(Serial1.available() > 1)
  {
    String input = Serial1.readString();
    Serial.println(input);
  }
}

void loop()
{
  HandleSendReceive();
  delay(10);
  return;
}

and for the sender

void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial1.setTimeout(10);
}

void HandleSendReceive()
{
  if(Serial.available() > 0)
  {
    String Input = Serial.readString();
    Serial1.println(Input);
  }
}

void loop()
{
  HandleSendReceive();
  return;
}

Derp just figured it out, the I was setting the timeout everywhere except for the Serial of the sender that reads in the text, that explains why nothing was changing lol. Thanks guys.

If you want a quick response, it is better do not use readString() function at all.

Yep, will be sending a byte per command, just wasnt sure why it was doing that with strings but it makes sense now!

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