Introduction: Long Range, 1.8km, Arduino to Arduino Wireless Communication With the HC-12.

In this instructable you will learn how to communicate between Arduinos over a long distance up to 1.8km in open air.

The HC-12 is a wireless serial port communication module that is very useful, extremely powerful and easy to use.

First you will learn how to make a wireless instant messenger with the least effort possible.

Then we will move on to light up an LED with a push button and then you will learn a few useful string functions and operations for serial communication.

The last part of the instructable is not necessary but you will learn how to use the HC-12 module like a pro.

In this part you will learn how to enter the modules setup mode to change the baud rate, transmission distance and so on.

And finally you will learn how to connect an external SMA antenna.

Follow the rest of this instructable to find out how easy it is to become a pro in wireless serial communication.

Step 1: Parts List

Picture of Parts List
  • 2 x Arduino (got my Arduino clones for 3 dollar here)
  • 2 x HC-12 modules (got mine here )
  • Wires
  • Breadboard.
  • 10 k resistor
  • push button
  • Exercise files here

Step 2: Wiring and Setup

Picture of Wiring and Setup

First we have to solder the spring antennas to both of the HC-12 chips.

I also soldered some pins on the HC-12 module to make it easy to use on a breadboard.

We will use 2 Arduinos with a HC-12 module connected to each of them as you can see in the image.

For both Arduinos we connect pin 2 to TX and pin 3 to RX. Ground to ground and VCC to 5v.

At one Arduino we will add a push button as you can see in the image.

To work with 2 Arduinos on 1 computer, we have to open 2 instances of the Arduino IDE. This means that we have to open the Arduino software 2 times. This is not the same as “file → New”

Save the one with the push button connected as “HC-12 sender” and the other as “HC-12 receiver”.

Make sure that the right ports are selected for each of the Arduinos.

Step 3: Instant Wireless Messenger, Toggle Button, Momentary Button and a Few Useful Functions

Picture of Instant Wireless Messenger, Toggle Button, Momentary Button and a Few Useful Functions

Wireless Messenger

We will start by making an instant wireless messenger.

Copy the content from the file “HC-12 messenger send/receive.txt” in the ZIP archive and paste it to each of the Arduino instances. The code is the same for both Arduinos.

After uploading the code, open the serial monitor for both instances.

Now start typing in both serial monitors to start a chat.

Even your Arduinos are connected to the same computer, the communication is wireless.

Toggle Button

A toggle button is used often in electronics. The principle is very simple. You press a button once to turn on the LED and press the same button again to turn of the LED.

Copy and paste the content of the “HC-12 Toggle Button Send.txt” to the “HC-12 sender” instance and the the “HC-12 Toggle Button Receive.txt” to the “HC-12 receiver” instance and upload.

When you push the button, you should see the LED light up. When you push the button again, the LED turns off.

A few validators like timing and button code are used in order to make sure this example works perfect.

Momentary Button

A momentary button is pretty straightforward. While pushing the button, the LED lights up. When releasing the button, the LED turns off.

Copy and paste the content of the “HC-12 Momentary Button Send.txt” to the “HC-12 sender” instance and the the “HC-12 Momentary Button Receive.txt” to the “HC-12 receiver” instance and upload.

Some useful functions and operators

There are a few useful functions and operators that come in handy when you want to convert or spit a string and convert it to a decimal and so on.

Look at the file “HC-12 Useful Functions and Operators Send.txt” and “ HC-12 Useful Functions and Operators Receive.txt”.

The send sketch sends the string “test123” on button press.

The receive sketch reads the string, split it and convert it to an integer.

Step 4: Advanced Setup. Changing the HC-12 Settings With AT Commands

Picture of Advanced Setup. Changing the HC-12 Settings With AT Commands

You can easily skip this section as it will cover some advanced chip settings. However I will cover the basics so you will be able to change the module's baud rate, transmission power, channels and working modes.

A full manual can be found in the ZIP archive under the name HC-12 User Manual.pdf

Connect the HC-12 as shown in the image and connect the Arduino to your computer.

Copy and paste the contents of the file named “HC-12 AT Commander.txt” from the ZIP archive and upload to your Arduino.

Open the serial monitor and type “AT”. If the module returns “OK”, the command mode is working.

Changing the baud rate

Type “AT+Bxxxx”.

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.

Example: type “AT+B4800”. The module returns “OK+B4800”.

Changing the communication channel

Type “AT+Cxxx”.

The value can be a number from 001 to 127.

Every number is a 400KHz step. The working frequency of channel 100 is 473.0MHz.

Example: type “AT+C021”. The module returns “OK+C021”.

The module is now set to a working frequency of 441.4MHx

Note that both sending and receiving modules need to have the same frequency to communicate.

Changing the working mode of the module.

This can be FU1, FU2, FU4 or FU4 (FU4 at a baud rate of 1200 sets the chip to transmit up to 1800 meter in open air). See documentation for a full explanation.

Example: Type “AT+FU4”. The module returns “OK+FU4”.

Obtain all parameters from the module.

Type “AT+RX”.

The module should return something like this:





More settings can be found in the “HC-12 User Manual.pdf” in the ZIP archive.

Step 5: Spring Antenna or SMA Antenna

Picture of Spring Antenna or SMA Antenna

The HC-12 modules come standard with a spring antenna. However you can connect an SMA antenna to the board.

There are whole books written about antennas and how they work. I don't want to go to deep into this subject.

The only thing to remember for now is that electronic circuitry can interfere with an antenna and therefore the HC-12 has a IPEX RF socket so you can separate the antenna from the board. This can help for better reception and transmission.

What you need is a IPEX to SMA extension cord and an SMA antenna.

I got my extension here and the antenna here.(check for male and female).

Make sure when you order that the male and female connections match.

You can push the cord on the IPEX connector and solder it on. On the other site of the cord you can screw on the SMA antenna.

Step 6: Final Note:

In this instructable you have learned how to use the HC-12 for long distance communications between Arduinos. You have learned how to make an instant messenger, a toggle button, a momentary button, how to use some string operators and functions, how to change the HC-12 settings and how to use a different antenna.

The making of this instructable took about 100 hours of research, editing, testing, writing and so on.

If this instructable was helpful for you, please click the favorite button and subscribe.

See you in the next instructable.

Other instructables you might like:

$2 Arduino. The ATMEGA328 as a stand-alone. Easy, cheap and very small. A complete guide.

How to fix bad Chinese Arduino clones


Donate to help me keep doing this work:


08stevieg (author)2017-12-06

Thanks Tom, really great project, I have got the momentary button working fine, I would really like to be able to control multiple LEDS/relays, I am new to Arduino what would be the code for the send to have up to 5 inputs and the receive to have 5 outputs. Thanks again for a great demonstration and for shareing this work

dick541 (author)2017-11-26

I did what you said but when I open the serial port I get only one covering the whole screen, whats wrong?

Smascar (author)2017-11-17

Any idea on the latency? and other important parameters?

Also HC-12 has a specified range of 1Km, is it because of your choice of antenna that you achieved this?

I'm trying to make a quad, any tips with this chip?

WernerM2 (author)2017-11-15

Hi Tom,

I have a question. On some sites they advertise the HC-12 with a Max distance of 1000 meters. How is it that you get 1.8km ?

selvamanikannan (author)2017-07-28

Frequency of hc-12 is 433-477MHz

is this allowable in india?

pls reply asap

Dear Mr. Selvamanikannan & Vaishranana,

Who says that this frq. is banned in India? Absolutely no! Because you are making your own network communication bridge. & not going to hamper or make use or change government / semi- government or any private signals that are indented for telecommunication & entertainment. What are banned are satellite frequency whose bands are sold by government to telecom companies.

So you can built & use your private network based on RF / GSM / laser etc.

Hi Selvamani ,I have the same question.Could you please let us know if the band can be used in India?

sf5 (author)2017-08-11

I have three brand new HC12 modules that appear to be dead .. I can not get an AT response from them. Is there any hack/jolt/fix to revive them. I have tried your Arduino sketch as well as other HC12 configuration utilities with no success.

fahid bin tariq (author)2017-07-24

Hi, actually it may be quite simple but please tell me that how to control multiple LEDS.

nelun (author)2017-05-08

Hello !

I have tested the
schematics with HC-12 and arduino nano, it is intermittently
functioning. It is blocking and it remains active or does not activate
the command on the output 13, after resetting the receiver it works but
not always. Initially we tested with improvised arduino uno and it looks
like it works well.Any idea ?
Thank you !

MarcoL82 (author)nelun2017-06-18

i'm having the same issue, did you manage to make it work in the end?

krahnemoon (author)2017-06-01

Hey there!

How fast is this HC-12?

Would it be suitable for video streaming?

If yes:

Is there a way to stream a video while transmitting some other data at the same time?

If no:

What long range module (1-2km) would you suggest for streaming videos?

vinodchinthoti (author)2017-01-17

hi sir, my hc-12 module not respond to AT cmd mode, i have 3 modules no one will work?

0xffff (author)vinodchinthoti2017-05-08

Make sure the HC-12 pin labelled "Set" is grounded at the time you send AT commands. See Tom's Step 4 above, in this very detailed tutorial ;)

ssandeeppatil (author)2017-05-06


I am very thankful for all this info. I have constructed same wireless bridge using HC-12. For this, I have used 'Toggle Button' program to on & off LED.

Now I just want to modify program to operate 5V 2CH relay & led both at Receiver side & to get status of relay at sender side by activating LED.

Kindly help me.


Sandeep Patil.

tss231197 (author)2017-02-19

I am making quadcopter. So for the remote control which one should I use between 'nrf24l01 with SMA antena' or 'HC-12' Bluetooth module for better range and controls??

achtung241 (author)tss2311972017-05-01

Research openLRSng using the Si4432 module.

Maker Saga (author)2017-04-25

Nice! I was looking to make a remote indicator light somehow in order to know if my chicken coop door was shut (from inside the house far away), before the nocturnal predators come out. Now I know how!

My first nameM (author)2017-04-12

What is the range with the standard spring antenna with FU4 mode and a baud rate of 1200?

JamesA9 (author)2017-04-07

Hi, Thanks soo much for this tutorial, I ordered 4 HC 12's and thaught no-one would have done anything on them, This tutorial really helped, Thanks!!

isaac_okoboji (author)2017-03-31

My friend and I set this up exactly as it was shown in your tutorial. Copy and pasted the code. Everything works, except there is about a 1.2 second delay from when we enter into the serial monitor, and when it displays on the other serial monitor. Also, if we type two entries too quickly, it combines them on the same line instead of separating them on different lines. I assume it is on some timer and recognizes that the incoming message has ended because a certain amount of time has transpired. Any suggestions on this? Thanks.


For anyone who needs to know:

Turns out that the default serial monitor has a 1000ms delay. To fix the problem I used:



For both the sender and receiver. That way, there is only a very small delay when sending and receiving information, as well as displaying it on the serial monitor. It works now!



CedomirG (author)2017-03-24

Can I use one HC-14 transmiter and two HC-12 as receivers. Same frequency same baude rate?

xxxxbbbbb0 (author)2017-02-13

Hi sir . In toggle button case both the Arduino is connected to computer .
Will this work if I use battery instead of pc after uploading the sketch? For final project? Plz reply

IsaacPierce (author)xxxxbbbbb02017-03-01

Yes, the arduino will save the sketch in its memory.

It will keep the sketch forever until you upload a new one.

tss231197 (author)2017-02-19

Thanks for your guide. Can I use HC-12 module on my quadcopter and control it via android phone?? How much the range will be??

alijalil (author)2017-02-15

Good work Mr. tomheylen
From your kind How can make robotic control through. using HC12. And arduino.
With my best regards

kanunnikovmaksim1 (author)2017-02-06

Thank you very much for your guide. I have a problem with my hc-12 modules. I've tried to test a maximum transmission distance and i have only 60-70 meters. transmission mode is FU4, i used antennas that was in the hc-12 pack(metal spiral(welding). What is the problem? How can i increase distance? Sorry for my English.

magic_beans (author)2017-01-26

just to note that the cheaper boards are not good at low temperature - typically fail at 5 or 6 deg C or lower. Use Arduino board if intending to use in low temp application.

RõyÃ40 (author)2017-01-26

hello sir,,, how to use in drone. and how make a flight controller of arduino board . can i its, sir plz reply me
my email id-

PGCsean (author)2017-01-08

Can I use the toggle switch send module to trigger a LED on multiple receive modules?

magic_beans (author)2017-01-06

hi - your 'Exercise files here' link not working anymore ?

tomheylen (author)magic_beans2017-01-06

My domain has expired. Should be working again today. If you send me a message on facebook, i will send you the files.The link to facebook is at the end of the article. Cheers

magic_beans (author)tomheylen2017-01-07

got them - many thanks. Great work by the way.

luxusl (author)2016-12-29

Hi, great tutorial! Thank you!

Is it possible to send from one to the other and so on?

EngrTamzid (author)2016-12-29

Hi, I want to use RF transceiver 1km module pair to drive a robotic car of 4 wheelers through Arduino Uno.But it doesn't work.I don't understand whether the fault is on the RF module or on the program or on the arduino pin.

Can anyone give me the program codes of RF transceiver sender and receiver for driving a 4 wheelers robotic car through Arduino Uno.

Please please.......

RudiA4 (author)2016-10-13


Is is possible to go further than 1.8Km?

Foxtrot70 (author)RudiA42016-12-27

You can if you use a modified 2' diameter satellite dish. Remove the LNB and replace it with a bowtie antenna. The gain of the dish + the bowtie is about 38bdm which give a substantial boost. If you are doing one way data transmission use the coiled antenna on the transmitter and the dish antenna on the receive location. Overall cost is under $50 in parts.

rockermr (author)2016-12-19

You are a legend. BTW i got some questions. This module does not have pipe, or authentication procedures like nrf, esp modules. This is great. SO what if i have one module act as transmitter and two or more as receivers. Will it work. Will they receive simultaneously. ReplyASAP. It will be very helpful.

parapedro (author)2016-12-11

Hi Tom, Thanks for your hard work and putting this out to dummies like me.

I tried it and it all worked perfectly first time. Very clear instructions and easy to follow. Thanks again, now I can get on with my Mailbox Notifier.

ahbrown41 (author)2016-12-08

Very nice, thanks for the great instructable, worked like a champ!

gunge (author)2016-11-28

Hi Tom, congratulations on a really useful tutorial that gives an extremely clear introduction to using the HC-12!!

Just two minor observations...

(i) I had trouble getting the toggle sketch to work properly (the led would either switch only occasionally or else get stuck on. After doing some debugging, I eventually found it was the fault of the Arduino clone I was using for the receiver. Adding a 330 Ohm resistor between the pin 13 led and ground fixed the problem.

(ii) during my debugging, I found that mySerial.flush does not actually clear out the serial buffer - the term 'flush' is misleading. Instead, substitute while(>-1); . This reads the buffer until it is empty.

Thanks again for all the effort you put into this tutorial. It is very much appreciated.

AhsanR17 (author)2016-11-21

Where are the zip files to test arduino codes??

OkiE1 (author)AhsanR172016-11-25

I can't find them too

AhsanR17 (author)OkiE12016-11-25

In the exercise files here option you will find the files.First click on show all steps then in the list of components you will see the last option as exercise files here

AhsanR17 (author)2016-11-25

I found them OkiE1 :)

AhsanR17 (author)2016-11-21

Where are the zip files for arduino code??

skyrafal. (author)2016-11-15

Very good, simple and stabillity remote control. No problems with work.
Much better than nRF24L01.

eburman (author)2016-07-17

Great tutorial! I finally started working through the steps today and so far I've had great success. I managed to get the driver for the Chinese Arduino boards working on my Mac (OS X 10.11 El Capitan). I got the LED toggle button sketches for the two boards up and working and then I wondered what the maximum range of the HC-12 might be. My home happens to sit atop a hill which has a broad view over my town so I figured I would get good range of transmission. I modified the send sketch for the transmitter unit so that it would automatically send a signal to flash the LED on the receiver. I was able to travel around with the receiver unit and as long as the LED kept flashing I would know that I was still receiving a signal. I used external antennas for each module as you suggested. I set the transmitter unit running outside on my deck which overlooks town. I put the other unit in my car and started driving around. I found that I easily got a consistent signal around my entire neighborhood even in areas where trees and homes obstructed the line of sight. I then took to the highway. The farthest line of sight distance was FIVE MILES AWAY (8 KM) as the crow flies! I measured the direct line of sight distance on google from my home to where my car was parked. Amazing! It would probably go further but I decided to end the experiment at that point. The test was using my HC-12 with default settings unaltered. If I changed the HC-12 settings and connect the transmitter up to my rooftop scanner antenna I wouldn't be surprised to get even better range.

tarupanchal (author)eburman2016-10-24

Which type of antenna are use for line of sight?

About This Instructable




Bio: I like to make stuff in my free time. Especially programming, cooking, electronics etc. Lately I'm making tutorials about stuff I made the last ... More »
More by tomheylen:Long range, 1.8km,  Arduino to Arduino wireless communication with the HC-12.How to connect a FT232RL programmer to the Arduino ATMEGA328 for uploading sketches$2 Arduino. The ATMEGA328 as a stand-alone. Easy, cheap and very small. A complete guide.
Add instructable to: