The HC-12 transceiver module uses AT commands to configure its operating parameters, such as baud rate, communication channel, and transmit power. To use these commands, the module's SET pin must be pulled to a logic low state.
Arduino Forum +2
How to Enter AT Command Mode
Power the module: Connect VCC and GND pins (operating voltage range 3.2V to 5.5V DC).
Pull the SET pin low: Connect the SET pin to GND. This puts the module into AT command mode.
Send commands: Send AT commands to the module's RXD pin using a serial terminal (default baud rate of 9600 bps for the configuration interface).
Exit command mode: Release the SET pin (or set it to logic high) to return the module to its normal operating mode with the new settings.
Arduino Forum +4
List of Common AT Commands
Commands are case-sensitive and must be in uppercase. Each command should be followed by a newline character. The module will typically respond with "OK" or "OK+".
YouTube +4
AT: Test command. The module returns OK to confirm it is in command mode and ready.
AT+V: Get firmware version. The module returns its current firmware version, e.g., HC-12_V1.1.
AT+Bxxxx: Set serial port baud rate. Sets the communication baud rate. Available rates include 1200, 2400, 4800, 9600 (default), 19200, 38400, 57600, and 115200 bps.
Example: AT+B9600 returns OK+B9600.
AT+Cxxx: Set wireless communication channel. Select a channel from 001 to 127. The default is 001 (433.4 MHz), with each channel stepping by 400 KHz. Both modules must be on the same channel to communicate.
Example: AT+C021 returns OK+C021.
AT+Px: Set transmission power level. x can be a number from 1 to 8, with 8 being the highest power (20dBm or 100mW) and 1 being the lowest (-1dBm or 0.8mW). The default is P8.
Example: AT+P5 returns OK+P5.
AT+FUx: Set the working/transparent transmission mode. x can be 1, 2, 3 (default), or 4. These modes offer different trade-offs between power consumption, data rate, and range.
Example: AT+FU3 returns OK+FU3.
AT+RX: Query all current parameters. The module returns all current settings in separate OK+... lines.
AT+SLEEP: Enter sleep mode. The module enters a low-power state (~22µA) and cannot transmit data. It exits sleep mode when the SET pin is pulled low again.
AT+DEFAULT: Restore factory default settings. This resets all parameters to their factory defaults (9600 bps baud rate, channel C001, FU3 mode, 20dBm power).
AT+UPDATE: Enter firmware update mode. The module stops responding to other AT commands until it is power-cycled.
Elecrow +4
Notes:
Look closely at this line in your receiver code: String incomingData = HC12.readStringUntil('\n');
This command tells the Arduino to wait and listen until it sees a "Newline" character (\n).
The Problem: If your transmitting Arduino is using HC12.print("Hello");, it never sends that newline character. Your receiver sits there waiting for a \n that never arrives, eventually times out, and drops the data.
The Fix: Ensure your transmitting code uses println() instead of print().
Change: HC12.print("Data"); -> HC12.println("Data");
#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 11); // RX, TX (Connect HC12 TXD to Arduino Pin 10, HC12 RXD to Arduino Pin 11)
int setPin = 9; // Connect HC12 SET pin to Arduino Pin 9
void setup() {
Serial.begin(9600); // Open serial port to computer
HC12.begin(9600); // Open serial port to HC-12, default baud rate is 9600
pinMode(setPin, OUTPUT);
digitalWrite(setPin, LOW); // Enter AT Command mode
delay(100); // Wait for the module to enter command mode
Serial.println("Enter AT commands:");
}
void loop() {
while (HC12.available()) { // If the HC-12 module sends data
Serial.write(HC12.read()); // Send the data to the Serial monitor
}
while (Serial.available()) { // If the Serial monitor sends data
HC12.write(Serial.read()); // Send the data to the HC-12 module
}
}