HC-12 Wireless Serial Port Communication Module
User Manual version 2.3B
- Wireless sensor
- Community building security
- Robot wireless control
- Industrial remote control and telemetry
- Automatic data acquisition
- Container information management
- POS system
- Wireless acquisition of gas meter data
- Vehicle keyless entry system
- PC wireless networking
- Long-distance wireless transmission (FU3: 1000m in open space, baud rate 5000bps in the air. FU4: 1800m in open space, baud rate 500bps in the air)
- Working frequency range (433.4-473.0MHz, with 100 communication channels)
- Maximum 100mW (20dBm) transmitting power (8 levels of power can be set)
- Four working modes, adapted to different application situations
- Built-in MCU performs communication with external device through serial port, no programming or configuration required for basic use
- The number of bytes transmitted continuously is unlimited (FU1 and FU3 modes only)
- Update software version through the serial port
The HC-12 wireless serial port communication module is a new generation of multi-channel embedded wireless data transmission module. Its wireless working frequency band is 433.4-473.0MHz. Multiple channels can be set, with a channel stepping of 400kHz and a total of 100 channels. The maximum transmitting power of the module is 100mW (20dBm), the receiving sensitivity is -117dBm at a baud rate of 5000bps in the air. Communication distance is 1000m (FU3 mode at 4800bps serial speed) in open space, 1800m in FU4 mode at reduced baud rate and volume of data.
The module uses stamp hole packaging to allow for patch soldering, with dimensions of 27.8mm ×14.4mm ×4mm (including antenna cap, excluding spring antenna), making it is very convenient for incorporate into user specific applications. There is a PCB antenna socket ANT1 on the module, so an external 433MHz frequency band antenna can be attached via a coaxial cable; there is also an antenna solder eyelet ANT2 on the module, convenient to solder a spring antenna to. Select one of these antenna options according to usage requirements.
The module has an onboard MCU, eliminating the need for user to program the radio section separately, with transparent half-duplex serial transmission provided for receiving and sending serial port data. This making the HC-12 very easy to interface with. The module adopts multiple serial port transparent transmission modes that are user selected by AT commands according to usage requirements. The average working current of the four modes FU1, FU2, FU3, and FU4 in idle state are: 3.6mA, 80uA, 16mA, and 16mA respectively, while the maximum working current in any mode is 100mA (in the transmitting state).
Standard configuration of the HC-12 module only contains one 433MHz-frequencyband wireless communication module with IPEX20279-001E-03 standard RF socket. Optional accessories are 433MHz frequency band spring antenna, or IPEX-to-BNC coaxial cable and matching 433MHz frequency band omni-directional rubber antenna with BNC connector base. The user can purchase these according to their application requirements.
The HC-12 module uses a Silicon Labs Si4463 to provide the RF communications link. This is a high performance, low current, single-chip “EZRadioPRO” family transceiver with up to 20dBm (100mW) transmitting output power. The Si4463 communicates through an SPI bus with an STMicroelectronics STM8S003F3 8-bit MCU that runs the HC-12 firmware. The STM8S provides a transparent serial data interface for interfacing to the module, allowing two HC-12 modules to act like a wired TTL level serial cable without any attached hardware devices needing to be aware of the RF link. Serial port and transceiver configurations are held in onboard non-volatile flash memory.
Definition of Pins
The HC-12 module can be patch soldered, or have a 2.54mm-spacing pin header attached and directly inserted onto the user’s PCB. The module has nine pins in total, and one RF antenna socket (ANT1), with definitions as shown in the table below:
|1||Vcc||Power supply input, DC3.2V-5.5V, with load capacity not less than 200mA. Note: if the module is working in the transmitting state for an extended time, it is suggested that a 1N4007 diode be connected in series if the supply voltage is greater than 4.5V, so as to avoid overheating the onboard LDO regulator|
|3||RxD||Input (weak pullup)||UART data input, TTL level. 1k resistor connected in series inside the module|
|4||TxD||Output||UART data output, TTL level. 1k resistor connected in series inside the module|
|5||SET||Input (10k pullup)||Parameter setting control pin, active low level. 1k resistor connected in series inside the module|
|6||ANT||Input/Output||433MHz antenna pin|
|9||NC||No connection, used in mechanical fixing, compatible with HC-11 module pin position|
|ANT1||ANT||Input/Output||IPEX20279-001E-03 antenna socket|
|ANT2||ANT||Input/Output||433MHz spring antenna solder eyelet|
Pins 1-6 each have two bonding pads, with the outer half-hole bonding pads intended for patch soldering. When the inner bonding pad ANT2 of Pin 6 is used for connection, the spring antenna can be soldered here by hand. The inner round-hole bonding pads of Pins 1-5 may then be used to solder a 2.54mm-spacing pin header that can be plugged into a PCB socket.
Wireless Serial Port Transparent Transmission
(1) Simple introduction of working principle
As shown in the above diagram, two HC-12 modules can be used in place of physical wiring to replace a wired half-duplex serial communications link carrying TTL level signals. The left device sends serial port data to the module, and after the RxD port of the left module receives the serial port data, it will automatically send the data over the air via radio wave. The right module receives the data, and restores the serial port data originally sent by the left device and sends it out TxD. It is the same from right to left. Only a half-duplex link is available between modules, as they can not receive and send data over the air at the same time.
(2) Serial port transparent transmission
The HC-12 module has four serial port transparent transmission modes, expressed as FU1, FU2, FU3, and FU4. In operation, these modes hide all the details of wireless communications from attached devices. The factory default working mode of the system is FU3 full-speed mode, and in this mode the baud rate in this air is automatically adjusted according to baud rate that the serial port has been set to. The usable communication distance will be the farthest at the lowest baud rate. Different modes can not transmit data to each other, and the user should select the optimal mode according to practical circumstances.
The modules are usually operated in pairs, with data transmitted by means of a half-duplex link. For successful wireless transmission, the transparent transmission mode, serial port baud rate, and wireless communication channel of the two paired modules must be set the same. The factory default module setting are: FU3, 9,600bps (8N1: 8 data bits, no parity, 1 stop bit), CH001 (433.4MHz), 20dBm power (100mW).
The number of bytes that can be continuously sent to the serial port of the module is unlimited in modes FU1 and FU3. However, considering ambient interference and other factors, if thousands of data bytes are sent continuously, some number of bytes may be lost. Therefore, the attached devices at each end of the link should have some sort of response and resending mechanism to avoid information loss.
(3) The four serial port transparent transmission modes
When the HC-12 module leaves the factory, its default serial port transparent transmission mode is FU3. In this mode the module remains in full-speed state, with an idle current of about 16mA. The module automatically adjusts the baud rate of wireless transmission in the air according to the serial port baud rate, with the corresponding relationship as shown in the table below:
|Serial port baud rate||1200 bps||2400 bps||4800 bps||9600 bps||19,200 bps||38,400 bps||57,600 bps||115,200 bps|
|Baud rate over the air||5000bps||15,000bps||58,000bps||236,000bps|
To get the maximum communication distance, the serial port baud rate should be set to be low (1200bps or 2400bps). For short-time transmission of mass data, the serial port baud rate may be set high, but be aware that the communication distance will be reduced accordingly.
The receiving sensitivity of the module at different baud rates in the air is as shown in the table below:
|Baud rate in the air||5000bps||15,000bps||58,000bps||236,000bps|
|Wireless receiving sensitivity||-117dBm||-112dBm||-107dBm||-100dBm|
Generally, every time the receiving sensitivity is reduced by 6dB, the communication distance will be reduced by half.
When the “SET” pin of the module is pulled low, the serial port transparent transmission mode and other parameters can be set through AT commands (see the introduction in the following chapter for details).
FU1 mode is a moderate power saving mode, with an idle working current of about 3.6mA. In this mode, the module can also be set to any of the eight serial port baud rates shown in the above table, but the baud rate in the air is a uniform 250,000bps.
FU2 mode is an extreme power saving mode, with an idle working current of about 80uA. In this mode, the module only supports baud rates of 1200bps, 2400bps, and 4800bps, with the baud rate in the air uniform at 250,000bps. If the module is subsequently set to any other serial port baud rate, the module will not be able to conduct wireless communication normally.
When the module is set to FU2 mode, if the currently set baud rate exceeds 4800bps it will be automatically reduced to 4800bps. In FU2 mode, the sending time interval of data packets can not be too short, otherwise data will be lost. It is suggested that the sending time interval between data packets should be no less than 1 second.
FU4 mode is useful for maximum range, up to 1.8km. Only a single baud rate of 1200bps is supported, with the in the air baud rate reduced to 500bps for improved communication distance. This mode can only be used for small amounts of data (each packet should be 60 bytes or less), and the time interval between sending packets must not be too short (preferably no less than 2 seconds) in order to prevent loss of data.
The following table gives typical reference values for the various modes:
|Idle current||3.6mA||80uA||16mA||16mA||Average value|
|Transmission time delay||15-25mS||500mS||4-80mS||1000mS||Sending one byte|
|Loopback test time delay 1||31mS||Serial port baud rate 9600, sending one byte|
|Loopback test time delay 2||31mS||Serial port baud rate 9600, sending 10 bytes|
|Operating range at full power (20dBm)||100m||100m||600m at 9600bps - 1000m at 2400bps||1800m at 1200bps||Clear line of sight between modules under ideal conditions|
Note: Loopback test time delay means the round trip time taken for data that is sent to the input (RxD pin) of one module, to begin to emerge from the output (TxD pin) of the same module, where a second (remote) module has been configured with the TxD and RxD pins connected together.
Module Parameter Setting AT Commands
AT commands are used to set module parameters and switch between module functions when the module is in command mode. After being set, these changes will become valid only after exiting from command mode. Parameters are stored in onboard non-volatile flash memory, so will not be lost when power is removed.
(1) Entering command mode
There are two ways to enter command mode:
- while energized, pull Pin 5 (“SET”) low, wait 40ms for command mode to engage
- disconnect the power supply, connect Pin 5 (“SET”) to GND, re-energize the module
Note: pin 5 has a 10k pullup resistor connected internally, allowing the pin to be driven by an open-collector output from an attached device.
Either of the above two methods will place the module in command mode ready to accept AT commands; releasing pin 5 (“SET”) in either case exits from command mode. If the module settings have changed after exiting from command mode, it will be switched to the new settings within 80ms.
When the second method (pin 5 “SET” tied to ground before power is applied), the module always enters command mode with the serial port configured for 9600bps, 8 data bits, no parity, 1 stop bit, irrespective of any previously configured settings.
(2) Command instructions
Test command. Send command “AT” to the module, and the module returns “OK”.
Change the serial port baud rate. The baud rate can be set to 1200bps, 2400bps, 4800bps, 9600bps, 19,200bps, 38,400bps, 57,600bps, or 115,200bps. The default value is 9600bps.
e.g: To set the serial port baud rate of the module to 19,200bps, send command “AT+B19200” to the module, and the module will return “OK+B19200”. After exiting from command mode, the module will begin to communicate at 19,200bps.
Change wireless communication channel, selectable from 001 to 127 (for wireless channels exceeding 100, the communication distance cannot be guaranteed). The default value for the wireless channel is 001, with a working frequency of 433.4MHz. The channel stepping is 400KHz, and the working frequency of channel 100 is 473.0MHz.
e.g: To set the module to work on channel 21, send command “AT+C021” to the module, and the module will return “OK+C021”. After exiting from command mode, the module will work on channel 21, with a working frequency of 441.4MHz. Note: As the wireless receiving sensitivity of the HC-12 module is relatively high, when the serial port baud rate is greater than 9600bps five adjacent channels should be staggered for use. Even when the serial port baud rate is not greater than 9600bps, over short distances (less than 10m) also five adjacent channels should be staggered for use.
Change the serial port transparent transmission mode of the module. Four modes are available, namely FU1, FU2, FU3, and FU4. Only when the serial port speed, channel, and transparent transmission mode of two modules is set to be the same, can normal wireless communications occur. For more details, please see the above section “Wireless Serial Port Transparent Transmission”.
e.g: Send command “AT+FU1” to the module, and the module returns “OK+FU1”.
Set the transmitting power of the module, with x selectable from 1 to 8. The corresponding transmitting power of the module is as shown below:
|Transmitting power of module||-1 dBm (0.8mW)||2 dBm (1.6mW)||5 dBm (3.2mW)||8 dBm (6.3mW)||11 dBm (12mW)||14 dBm (25mW)||17 dBm (50mW)||20 dBm (100mW)|
The default value is 8, and the higher the transmitting power, the farther the possible wireless communication distance. When the transmitting power level is set to 1, the transmitting power is at the minimum. Generally speaking, every time the transmitting power is reduced by 6dB, the communication distance will be reduced by half.
e.g: Send command “AT+P5” to the module, and the module returns “OK+P5”. After exiting from command mode, the transmitting power of the module will be set to 11dBm.
Obtain a single parameter from the module, where y is any letter among B, C, F, and P, respectively representing: baud rate, communication channel, serial port transparent transmission mode, and transmitting power.
Example 1: Send command “AT+RB” to the module, and if the module returns “OK+B9600” it is confirmed that the serial port baud rate of the module is 9600bps.
Example 2: Send command “AT+RC” to the module, and if the module returns “OK+RC001” it is confirmed that the communication channel of the module is 001.
Example 3: Send command “AT+RF” to the module, and if the module returns “OK+FU3” it is confirmed that the module is working in serial port transparent transmission mode FU3.
Example 4: Send command “AT+RP” to the module, and if the module returns “OK+RP:+20dBm” it is confirmed that the transmitting power of module is set to 20dBm (100mW).
Obtain all parameters from the module. Returns serial port transparent transmission mode, serial port baud rate, communication channel, and transmitting power in that order.
e.g: Send command “AT+RX” to the module, and the module returns “OK+FU3\r\n OK+B9600\r\n OK+C001\r\n OK+RP:+20dBm\r\n”. (“\r\n” means return\newline)
Set data bits (d), parity (p), and stop bits (s) for serial port communication. For parity, N means none, O means odd check, and E means even check. For stop bits, 1 means one stop bit, 2 means two stop bits, and 3 means 1.5 stop bits.
e.g: To set the serial port format to eight data bits, odd parity, and one stop bit, send command “AT+U8O1” to the module. The module will return “OK+U8O1”.
Request firmware version information from the module.
e.g: Send command “AT+V” to the module, and the module returns “HC-12_V2.3”.
After receiving this command, the module will enter sleep mode upon exiting from command mode, with a working current of about 22uA. This mode doesn’t allow serial port data transmission. Upon entering command mode again the module will exit from sleep mode automatically.
e.g: When wireless data transmission is not needed, to save power send command “AT+SLEEP” to the module, and the module will return “OK+SLEEP”. Upon exit from command mode the working current will drop to about 22uA.
Set serial port baud rate and configuration, communication channel, power, and serial port transparent transmission mode back to the factory default values.
e.g: Send command “AT+DEFAULT” to the module, and the module returns “OK+DEFAULT”, with the factory default values restored. The factory default serial port baud rate is 9600bps, 8 data bits, no parity, 1 stop bit, communication channel is 001, transmitting power is 20dBm, and serial port transparent transmission mode is FU3.
Puts the module in the state of waiting for a software update. After receiving this command the module will not respond to any further AT commands until power has been cycled.
- Do not connect a light-emitting diode and resistor directly to the module's TxD output as this may affect serial port communication.
- If using a PC or MCU to dynamically modify the module parameters, after pulling pin 5 (“SET”) low wait at least 40ms before sending any AT commands to the module. After releasing pin 5 (“SET”), wait at least 80ms for the module to return to serial port pass-through mode.
- The HC-12 may require up to 100mA of current when transmitting. Ensure sufficient current is available – a USB bridge device may not be able to supply sufficient current. It is recommended that a reservoir capacitor be provided across the power supply of at least 22uF, preferably 1000uF.
edited by Robert Rozee, 15 January 2016 further edited by Chris Morgan (Bluegoldfish Design), 1 December 2020