The HC12 is a low-cost, low-power, 12-bit microcontroller with integrated RF communication capabilities. It is designed for wireless data transmission and is widely used in applications requiring reliable and efficient communication over medium distances. The HC12 operates in the 433 MHz frequency band and supports multiple communication modes, making it versatile for various use cases.
The HC12 microcontroller is equipped with features that make it suitable for wireless communication in embedded systems. Below are its key technical specifications:
Parameter | Value |
---|---|
Operating Voltage | 3.2V to 5.5V |
Operating Current | 16 mA (transmitting), 3.5 mA (receiving) |
Sleep Current | < 22 µA |
RF Frequency Range | 433.4 MHz to 473.0 MHz |
Communication Range | Up to 1,000 meters (line of sight) |
Modulation Method | GFSK (Gaussian Frequency Shift Keying) |
Baud Rate (Serial) | 1,200 bps to 115,200 bps |
RF Data Rate | 500 bps to 19,200 bps |
Output Power | -1 dBm to 20 dBm (adjustable) |
Operating Temperature | -40°C to +85°C |
Dimensions | 27.8 mm x 14.4 mm x 4 mm |
The HC12 module has a total of 4 main pins for interfacing. Below is the pinout and description:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply input (3.2V to 5.5V). |
2 | GND | Ground connection. |
3 | TXD | Serial data output (connects to RXD of the microcontroller). |
4 | RXD | Serial data input (connects to TXD of the microcontroller). |
5 | SET | Mode selection pin (used to configure the module or enter sleep mode). |
The HC12 module is straightforward to use in a circuit. Below are the steps and best practices for integrating it into your project:
To configure the HC12 module (e.g., change baud rate, RF power, or channel), follow these steps:
Pull the SET pin low to enter configuration mode.
Send AT commands via the serial interface to configure the module. For example:
AT+B9600
sets the baud rate to 9600 bps.AT+P8
sets the RF power to 8 (maximum).AT+C001
sets the communication channel to 1.Pull the SET pin high (or leave it unconnected) to exit configuration mode and resume normal operation.
Below is an example of how to use the HC12 module with an Arduino UNO for basic communication:
#include <SoftwareSerial.h>
// Define RX and TX pins for SoftwareSerial
SoftwareSerial HC12(2, 3); // RX = Pin 2, TX = Pin 3
void setup() {
Serial.begin(9600); // Start the hardware serial port
HC12.begin(9600); // Start the HC12 serial communication
Serial.println("HC12 Ready");
}
void loop() {
// Check if data is received from the HC12
if (HC12.available()) {
String receivedData = HC12.readString(); // Read data from HC12
Serial.print("Received: ");
Serial.println(receivedData); // Print received data to Serial Monitor
}
// Check if data is sent from the Serial Monitor
if (Serial.available()) {
String sendData = Serial.readString(); // Read data from Serial Monitor
HC12.print(sendData); // Send data to HC12
}
}
No Communication Between Modules
Short Communication Range
AT+P
command.Module Not Responding to AT Commands
High Power Consumption
AT+SLEEP
command.Q: Can the HC12 communicate with other RF modules?
A: No, the HC12 can only communicate with other HC12 modules configured to the same settings.
Q: What is the maximum range of the HC12?
A: The HC12 can achieve up to 1,000 meters in line-of-sight conditions with a proper antenna.
Q: How do I reset the HC12 to factory settings?
A: Enter configuration mode (SET pin low) and send the AT+DEFAULT
command.
Q: Can I use the HC12 with a 5V microcontroller?
A: Yes, but you must use a voltage divider or level shifter for the RXD pin to avoid damaging the module.
By following this documentation, you can effectively integrate and troubleshoot the HC12 module in your wireless communication projects.