Serial Issues with HC12 Module

Hi All,

I have been working on a project where we want to use an HC-12 to send data to another device. After some tinkering, we get the device to start up and work. Just to test the protocols, we make up a message, print this message on the serial monitor, and then transmit the same message over the HC-12. We were getting gibberish often on the receiver side, so we thought it must be some issue with antennas, timing in the transmit, etc... Then we actually checked the monitor for the transmitter side, and this is what was printed:
image

Now, this is weird.. Here is the code for the loop function:

byte Message[15] = " RM+RGB ";
const int Sendd = 0x38;
Message[0] = Sendd;
int ID = 0x0;
int R = 0x0;
int G = 0x60;
int B = 0x60;
Message[7] = ID;
Message[8] = R;
Message[9] = G;
Message[10] = B;
for (int i = 0; i<Max_Transfer_Size; i++){
outgoingBuffer[i] = Message[i]; //copy
}
Serial.println(outgoingBuffer);
bool succ = HandleCommsBasic();

Does anyone have any clue why the message gets messed up? My USB wire is but a foot long, and is shielded. It could be that the transmission interferes with the wire, and messes up the bits. Anyone have any idea?

Thanks in advance :slight_smile:

Check the baud rate

Could be a problem in the rest of the code or related to the type of Arduino you are using.

But, if you look at the lines of interest, there is no code that messes with the Message being compiled for sending, up until Serial.println... Even so, the message would have come out consistent surely?

There seems to alot of message[ ..] that are not initialized.
Also the message contains '\0' (0x0) at [7] which will interfere with the Serial.println()

To anyone with similar issues in the future, what fixed it for me was to add a small delay after transmitting, and only then printing to serial... I suspect that the transmission was actually causing interference on the wire, or that perhaps the transmission requires enough current that it destabilizes the 5V line... Either way, adding a short delay after transmitting helps a ton.

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