HC-12 returns ERROR after sending "AT"

Hey, I just hooked up my HC12 module (not sure if it's a clone), to the Serial1 port of my Arduino mega.
Vcc - 5v
Gnd - Gnd
Rx - TX1
TX - RX1
Set - GND (for AT command mode)

void setup() {
Serial.begin(9600);
Serial1.begin(9600); // HC-12
}

void loop() {
      if (Serial1.available()) {
        Serial.write(Serial1.read());
    }
    if (Serial.available()) {
        Serial1.write(Serial.read());
    }
}

When I type "AT" into my serial monitor, i get
"ERROR
ERROR
ERROR"

I've tried changing the "no line ending", "new line", "Carriage return", "both new line and CR", but i get the same response each time.
I'm worried about trying to change the baud rate because from a previous post (Solved! HC-12 ERROR) one person had trouble getting it working again. But i'm assuming the baud rate (9600) is working because the "ERROR" msg is coming back fine.
i've tried "AT", and "AT+", same results

this looks OK - check cables for continuity
a ~50µF between Vcc and GND could help

1 Like

OK! i got it working, but only when i use the minimum code (the one i used above), i shoud have tested this before posting. I was testing it in a bigger program, where i have lots of other serials going on. I think i have another "if serial.available(), Write to serial3" hidden somewhere, do you think that could be the problem? Does the buffer get deleted straight after it is used? but then what is it sending?

as soon as you read, the byte is removed from the buffer

1 Like

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