HC-12 433MHz wireless serial communication module configuration

Description

HC-12 are cheap 433MHz wireless serial port communication modules with a range up to 1800m in open space. Each costs about $5 when bought from China, and 2 of them can create wireless UART link that can be used, for example, to transfer telemetry data from UAV. Or drive IoT device. Or connect sensors. Or whatever else one can think of.

HC-12 433MHz wireless serial communication module

It is based on SI4463 RF chip, has build in microcontroller, can be configured using AT commands and allows to use external antenna. Working frequency is divided into 100 channels starting from 433,4MHz up to 473,0MHz with 400kHz channel separation. Maximum output power is 100mW (20dBm) and receiver sensitivity differs from -117dBm to -100dBm, depending on transmission speed. It accepts 3,2V-5,5V power supply and can be used with 3.3V and 5V UART voltage devices (5V safe).

HC-12 serial port supports following baud rates:

  1. 1200bps
  2. 2400bps
  3. 4800bps
  4. 9600bps (default)
  5. 19200bps
  6. 38400bps
  7. 57600bps
  8. 115200bps

Each HC-12 can work in one of following modes:

  1. FU1 – moderate power saving mode with 250000bps “over the air” baud rate. Serial port baud rate can be set to any supported value
  2. FU2 – extreme power saving mode with 250000bps “over the air” speed. Serial port rate is limited to 1200bps, 2400bps, 4800bps
  3. FU3 – default, general purpose mode. “Over the air” speed differs depending on serial port speed. The same goes for maximum range:
    • 1200bps ~ 1000m
    • 2400bps ~ 1000m
    • 4800bps ~ 500m
    • 9600bps ~ 500m
    • 19200bps ~ 250m
    • 38400bps ~ 250m
    • 57600bps ~ 100m
    • 115200bps ~ 100m
  4. FU4 (available in version 2.3 or newer) – long range mode. “Over the air” speed is limited to 500bps and serial port speed to 1200bps. Because air speed is lower than port speed, only small packets can be send: max 60 bytes with interval of 2 seconds. In this mode range is increased to 1800m.

Pair of HC-12 that creates a wireless link has to work in the same mode (FU1, FU2, FU3, FU4) and with the same speed.

Configuration

HC-12 can be configured using AT command. The best way to do it, is to use USB-to-serial converter like CP2102. To put HC-12 into AT mode, pull SET pin to GND like this:

USB-To-Serial HC-12
Vcc Vcc
GND GND
TX RX
RX TX
GND SET

Then, telnet to device:

  • Linux and Mac usually has preinstalled screen command that does that. In my case (Macbook Pro) syntax was: screen /dev/tty.usbserial-A50285Bl 9600
  • In case of Windows machines you can use excellent Putty and open serial port (COM1-COM4 depending on your setup) with speed 9600bps

Now we can start sending commands. The only problem here is that you can not just type them. Wireless module will expect that each command will entered very fast. So the best option here is to open text editor, type commands there and then copy them one by one into serial software.

Most important commands:

  1. AT – test command. It will return OK if AT interface is enabled
  2. AT+Bxxxx – set serial port baud rate. For example, AT+B57600 set baud rate to 57600bps
  3. AT+Cxxx – set radio channel. Channels start from 001 at 433,4MHz. Each next channel adds 400kHz. Channel 100 is 473,0MHz. AT+C002 will set frequency to 433,8MHz. Two HC-12 devices that creates a wireless link have to operate on the same frequency
  4. AT+FUx – set device mode: FU1, FU2, FU3 or FU4. Two HC-12 devices that creates a wireless link have to use the same mode
  5. AT+Px – set device transmitting power. For example AT+P2 sets power to 2dBm (1.6mW)
    1. -1dBm (0.8mW)
    2. 2dBm (1.6mW)
    3. 5dBm (3.2mw)
    4. 8dBm (6.3mW)
    5. 11dBm (12mW)
    6. 14dBm (25mW)
    7. 17dBm (50mW)
    8. 20dBm (100mW)
  6. AT+RX – retrieve all parameters: mode, channel, baud rate, power
  7. AT+V – retrieve module version
  8. AT+DEFAULT – reset module parameters to default settings

20 thoughts on “HC-12 433MHz wireless serial communication module configuration

  1. Hello,

    thanks for writing this.

    Do you know what happens if one tries to use several of these HC-12 modules (like sensor nodes) which try to communicate with one module (master receiver) at the same time. Is there any kind of built-in protocol that handles this?

    If not, do you have an idea how to solve this, so the packets don’t get lost?

    Thanks

    1. Hi,

      Did not tested that yet. But they are rather one-to-one devices and more than two on one channel would probably break the transmission.

    2. The Si4463 has Listen-before-talk to avoid collisions. This will be useful in mesh network like what you described. but I am not sure if the standard firmware running in the STM8 CPU configures the RF chip that way. If not you will have to implement some kind of stop-and-wait datalink protocol in the application. Here again this will work assuming you dont have long packet transmission times and reasonable number of nodes. You can refer to some ALOHA theory to get an idea on this CSMA scheme.

  2. Hello!
    Is there any way to change some parameters of the HC-12? For example decrease frequency step from 400kHz and specify GFSK modulation of the Si5563? Could you please provide any information (link) on how to reprogram MCU firmware?

    Thanks!

  3. Hey. I can not understand why data packets are lost at a distance of more than 10 m. It is adjusted to the speed of 9600, an external antenna is connected.
    In the application, at a distance of 10-20m there are messages “not received data” 🙁

      1. I have already replaced 4 modules. Constantly the same thing. It is adjusted to the speed of 9600 FU3. Antenna standard spring on quadrocopter and large dipole on the receiver. 🙁

  4. Hi, I see this question asked before but it is yet to be answered.

    Can we create mesh networks with this HC-12 module?

    Secondly, what is the maximum number of nodes we can connect to a central controller over this (presumed) mesh network?

    Thanks.

Leave a Reply

Your email address will not be published.