RF Serial Link

If you want to communicate between devices in your home you have a variety of options but basically they fall into two categories: wired and wireless.  In past Episodes we have explored Bluetooth and Wi-Fi but one we haven’t looked at yet is plain old RF.  I got interested in this when I found some posts on the web about trying to read wireless temperature sensors.  While investigating this I determined that there are two completely different RF communications methods that both use the same frequency ranges (315-MHz and 433-MHz).  Originally I was interested in seeing if I could decode signals from some cheap wireless security sensors I have lying around and that experience is documented in a different post.  That communication method uses various signal encoding techniques.  The method discussed in this project, however, uses the simple UART communications protocol.  Both methods have their strengths and weaknesses and each is best suited for different applications.

RF Module

The module I use for UART communications is called the HC-12.  If you remember from the Bluetooth projects we used HC-05 and HC-06 modules.  In essence these all act in a similar manner and interfacing to them is basically the same.  These modules are transceivers so data can go in either direction but they need to take turns transmitting because communications are only half duplex.  They can be used as they come set up from the factory or they can be reconfigured in a wide variety of ways.  Module configuration uses the AT command protocol (detailed in the manual) but an enterprising user created a really cool Windows utility to make it so much easier.  Both the Manual and the utility are included here.

HC-12 v2.4 Manual

HC-12 config

Configuration options include the expected serial port settings but also include things like power level, transmission speed, and transmission frequency.  The frequency range is from 433.4-MHz to 473-MHz with a total of 100 possible channels.  That gives you the flexibility to be able to use several pairs of these in the same area while being able to keep them from stepping on each other.  Just remember that the transmitting and receiving ends need to be set to the same channel.

In order to put the HC-12 into the configuration mode, the SET pin needs to be grounded.  When I added header pins to the modules I added an extra pin to the ground so that I could jumper it to the SET pin.  Another way would be to just set up a small test board that is wired to allow SET to be jumpered to ground during configuration.  I also used a common USB to serial TTL cable to hook it up to the PC.

The module comes with a spring type antenna that can be soldered to the board.  There is also a connector on the board if you want to use an external antenna instead.


PIC RF Interface

You could set up two PICs, wired to separate HC-12 modules, for testing but you don’t really need to.  That would be an option if you wanted to test the range of the modules.  As shown in the schematic, a single PIC can be used with the PIC TX pin connected to the RX pin of one HC-12 module and the PIC RX pin connected to the TX pin of the other module.  The diode shown in the diagram can be any silicon diode rated at 1 amp or higher.  It is there because the manual recommends using a diode to reduce the power supply voltage if extended communications periods are expected.

Another way to test the modules is to simply insert them between two items that are normally wired together using serial TTL connections.  You may need to change the baud rate to get a proper match.  As an example I used two HC-12 modules, without changing the configurations, to replace the wired connections between the GPS unit and the PIC detailed in an earlier post.   The GPS TX output connected directly to the HC-12 RX.  The other HC-12 was connected to the PIC RX input.  No software changes were needed in the PIC.  That allowed me to put the GPS in a totally separate location from the display.



The software is really pretty simple because we just have the PIC send the letter “A” to start the communication.  The second HC-12 will receive the transmission and send it back to the PIC via the serial port.  When the PIC receives the character it sends it to the LCD, increments the ASCII value, and then transmits it.  The software alternates between the two lines of the LCD every other letter.  When the letter “Z” is received the display is cleared and it starts over.  There are delays between each transmission so you can monitor the progress.

There are some folks who say that reception may not work if the modules are too close to each other.  Personally, I had no problem with them sitting about 12 inches apart on my bench.  I didn’t test the full range of the boards (it’s cold outside!) but I did connect the GPS (as mentioned above) and had no issue with one HC-12 in a corner of my basement and the other at the farthest corner away on the main level.  If you need long range communications the manual specifies FU4 mode (FU3 is default) for maximum range.  That, however, reduces the maximum baud rate to 1200.  That’s it for this post.  Check out my other electronics projects.

HC-12 RF Test