Does the HC-12 RF Transciever remember it's settings?

Thread Starter

pyroartist

Joined Oct 9, 2015
131
The paper on this device never says if the settings (channel, mode, etc.) require reprogramming after every power cycle or not.
Or does it just come up in the default mode?
Someone named Mark Hughes wrote a very informative article about this device on this website in 2016 but he never mentioned it either.
Thanks for more details.
 

ericgibbs

Joined Jan 29, 2010
18,849
hi,
Do you a copy of the HC12 datasheet, it explains how to SET the module and how to quickly read the current settings.?
E
 

Thread Starter

pyroartist

Joined Oct 9, 2015
131
Yes, I have that, thanks. I also have the updated user manual that someone put out for increased clarity. I uploaded that file below.
Also if anyone wants to know more about this inexpensive transciever (on eBay) they should read the tutorial on it that is found
as an article on the allaboutcircuits.com website, by Mark Hughes.
 

Attachments

Thread Starter

pyroartist

Joined Oct 9, 2015
131
@MarkHughes
I am starting to connect and test my HC12 with an Arduino Nano. In looking at your examples in your writeup it appears you do not have the right pins listed. You wrote;


/* HC12 Send/Receive Example Program 1

By Mark J. Hughes


Connect HC12 "RXD" pin to Arduino Digital Pin 4 >>>>> Shouldn't this be going to the Arduinio TXD pin?

Connect HC12 "TXD" pin to Arduino Digital Pin 5 >>>>>> Shouldn't this be wired to the Arduino RXD pin?

Connect HC12 "Set" pin to Arduino Digital Pin 6 >>>>>>>> This is the D6 port. Looks OK to me.

Please explain how the communication can occur while using the D4 and D5 digital pins.
 

LesJones

Joined Jan 8, 2017
4,190
The way Mark is doing it is using a software UART to communicate between the Arduino and the HC-12 The the hardware UART on the Arduino is being used to communicate with the PC via the USB to serial converter on the Arduino board. I use a different method that may only work with the Arduino uno. I just use the USB to serial converter on the Arduino board. When I first used this method I removed the ATmega328 so it's Uart did not short out the signals from the USB to serial converter. Later I found that by default the pins that were used by the UART were configured as inputs. They are only enabled by the instruction serial.begin. So if you have a sketch running that does not contain serial.begin or anything that sets the RX or TX pin to be an ouput then my method works. (For example the simple blink sketch.) My method works by connecting the TX on the HC-12 to the TX on the Arduino and the RX on the HC-12 to the RX on the Arduino. The reason for this is that the TX on the USB to serial converter is connected to the the RX on the Arduino. So by connecting it this way the TX on the USB to serial converter will be connected to the RX on the HC12. So when you use the serial monitor you are communicating directly with the HC-12. The ATmega328 is not involved in this communication.)

Les.
 

Mark Hughes

Joined Jun 14, 2016
409
Hi @pyroartist,
Glad you're back to your project. You are absolutely correct that a crossover must occur for the UART protocol (HC12Rx->ArduinoTx, ArduinoTx->HC12Rx). My sketch doesn't make this clear in that I only mention the HC12pins in the variable names. The crossover happens somewhat quietly when the variables are called in the line
Code:
SoftwareSerial HC12(HC12TxdPin, HC12RxdPin);
.

Now when I first experimented with these, I had the HC12 on pins 7&8, but then that interfered with the GPS when I added it for the next article, so I re-worked the sketches to pins 4, 5, 6 and copied that header info back into the preceding files (which is why pin 6 shows up even though it isn't used in the sketch).

Hope that helps explain things!
Mark
 

Thread Starter

pyroartist

Joined Oct 9, 2015
131
@MarkHughes
I think I see what you did. You needed the Tx Rx pins for the GPS so you somehow re-directed the definition of the pins using some software wizardry that I have no familaraity with. I really don't know C at all. I'm just bumbling my way through this task by leaning on other people's example code.
I will stick with the direct connection as I don't have any other serial devices that need the Tx Rx pins.

@LesJones
This method is also out of my software reach. Anyway, eventually this code will run on battery power so I will not have the USB port connected then.
Interesting that you can do all this trick manipulation. What physical pins did you connect t he HC12 to?
 

LesJones

Joined Jan 8, 2017
4,190
The RX pin on the HC-12 is connected to the pin marked RX on the Arduino board. This what is RX on the ATMega 328P (Which is not being used by the by the UART under the conditions I described.) but it is connected to the TX pin on the USB to serial converter which happens to be an ATMEGA16u on the Arduino Uno board. The same reasoning applies to the TX pin on the HC-12.

Les.
 
Top