HC-12 problem

mark713

New Member
Hi all,

I'm not usually one to post and ask for help, but I'm having some trouble with some HC-12 modules and can't find the issues I'm having online.

I am trying to connect to the HC-12 module by the HC-12 Config Utility but keep getting junk back, see image attached.

I have VCC connected to a 5V regulator through a 1N4001 diode and a 1000uF capacitor
GND connected to ground or 0V
TX on the HC-12 connected to RX on my serial converter
RX on the HC-12 connected to TX on my serial converter
SET connected to ground or 0V

I have tested my serial converter by shorting out the TX and RX pins as described in this link (click here) and it seems to be functioning properly, I have also checked the baud in device manager and its set to 9600 with 8 data bits, 1 stop bit and no parity.

Thinking the HC-12 modules may be faulty, I purchased more from a different vendor on Amazon but I'm getting the exact same issues.

On a side note, I have 2 Picaxe 18M2 successfully talking to each other by means of serout and serin, this was via a physical wire, I have also attached a 433Mhz transmitter to the output 18M2 and a receiver to the input 18M2 and again, this worked exactly as I expected, however I am having some trouble when trying to use the HC-12 module, I read that they will work straight out of the box on default settings, but the data received by the receiving 18M2 is not what was sent.

Have I bought faulty units from 2 different vendors or does someone with more knowledge know what I'm doing wrong?

Thank you for your time reading this.

Kindest regards,
Mark.

23298
 

techElder

Well-known member
Seems like I remember that you have to find out what channel/baud your HC-12 is on and start communication there to change it to something else.
 

inglewoodpete

Senior Member
I was fortunate: my pair worked "Out of the box". I also bought an HC-12 module with USB plug attached, so that I could monitor what was being sent to air using a terminal program like PuTTY.

One question: Is either the send or receive leg sending/expecting inverted data?

It may help members to see your minimum code for the sending and receiving PICAXEs (that, obviously, doesn't work).
 

neiltechspec

Senior Member
I encountered this problem in my earlier days. It's probably your serial converter - inverting the data sent / received.
What serial device are you using ?.
I use CP2102 based devices & don't have a problem.
After my AXE027 died early last year, I now use a CP2102 for programming PICAXE's with data in/out inverted through 74HC hex inverter.

Neil.
 

mark713

New Member
Thank you all for your advice and help,

Seems like I remember that you have to find out what channel/baud your HC-12 is on and start communication there to change it to something else.
Thank you for your reply, as standard out of the box it should be set at 9600 baud with 8 data bits, 1 stop bit and no paraity, however I read that if you ground the set pin before powering the device, then it sets it to the default mode with the settings above, I guess this is in case you have trouble connecting, like a safe mode of sorts, just doesn't seem to work for me.



I was fortunate: my pair worked "Out of the box". I also bought an HC-12 module with USB plug attached, so that I could monitor what was being sent to air using a terminal program like PuTTY.

One question: Is either the send or receive leg sending/expecting inverted data?

It may help members to see your minimum code for the sending and receiving PICAXEs (that, obviously, doesn't work).
Thank you for your reply, I tried mine out of the box, just didn't work as expected, maybe mine are clones or faulty, I think that's a very good idea with the USB HC-12, if I can resolve this issue with the config utility I will purchase one of those.

I'm sending out, and expecting true data (non inverted), but I've tried a few different settings at different baud rates and the results are the same.

At this point I would like to confess, I was looking at the wrong baud rates in the manual, your reply made me look again and then I kicked myself quite hard, I was using B9600 instead of T9600, I was playing with hserin/out to try and rectify the issue, I didn't get a syntax error so completely missed it, sorry, I'll blame the new born keeping me awake at night :)
This is the test code I am using, it works a treat with a wires connection and with a low range cheap 433Mhz separate TX/RX units and now with the HC-12, its weird that the cheap low range unit didn't care about the error.

Transmitting 18M2:
Code:
main:
inc b1                    'increment b1
serout b.5,T9600_8,(b1)    'send out via serial
toggle b.3                'toggle LED (just for visual verification)
debug                    'to view on laptop
pause 500                'short break
goto main                'start again
Receiving 18M2:
Code:
main:
serin B.5,T9600_8,b1    'read serial in and put value in b1
debug                    'view results on laptop
pause 100                'short break
goto main                'start again
The original problem remains though, I'm still having trouble with the config utility.



I encountered this problem in my earlier days. It's probably your serial converter - inverting the data sent / received.
What serial device are you using ?.
I use CP2102 based devices & don't have a problem.
After my AXE027 died early last year, I now use a CP2102 for programming PICAXE's with data in/out inverted through 74HC hex inverter.

Neil.
Thank you for your reply, I actually thought it could be my serial converter as I bought it a few years ago, so I bought another and the results are the same. I'm really sorry but I do not know if my converter is inverting the data its sending, I'm going to read up on this.
In device manager, my old converter is called Prolific USB to Serial converter, the new one I have bought is ATEN UC232A, I hope that answers your question, I'm not sure what its based on, looking at your CP2102 based device on google, I think I'm going to buy one on Amazon now.
Both are set up the same in device manager and as far as I'm aware are compatible with the HC-12 settings.
HC-12 error 2.jpg


Once again, thank you all for your help.
 
Last edited:

neiltechspec

Senior Member
I have a prolific USB2Serial in my junk box - not used for years.
That is usb to serial at RS232 voltage levels, not suitable for connecting to HC12's without level shifting & inverting.

An ATEN UC23A appears to be the same - RS232 voltages.

Both of these could well have damaged the HC12's.

Use a CP2102 based converter - USB to Serial at TTL levels & non inverting - cheap as chips on the likes of ebay.
This can also power the HC12 as well for programing purposes.

Neil.
 

mark713

New Member
I have a prolific USB2Serial in my junk box - not used for years.
That is usb to serial at RS232 voltage levels, not suitable for connecting to HC12's without level shifting & inverting.

An ATEN UC23A appears to be the same - RS232 voltages.

Both of these could well have damaged the HC12's.

Use a CP2102 based converter - USB to Serial at TTL levels & non inverting - cheap as chips on the likes of ebay.
This can also power the HC12 as well for programing purposes.

Neil.
Thank you for your reply, and especially your previous reply as you suggested the use of the CP2102 based device, I bought one off Amazon after replying to your post, and with the wonders of Amazon Prime it arrived today.
As soon as I installed drivers, it worked straight away and now the HC-12 config responds as expected.

I think where I failed here was incorrectly assuming that the same USB to serial converter I use to programme Picaxe chips could be used to read the HC-12 modules. As both the Picaxe and HC-12 can send and receive data to a com port on the laptop I thought the same cable would be ok.
I made my cable a few years ago before I bought an Axe027, I used a USB to serial converter attached to the cable I made with the resistors soldered in place, then off to dupont pin headers, I actually prefer it over the Axe027.

Luckily the HC-12 modules seems to be functioning correctly, as my cable has the 22k and 10k resistors on it for picaxe programming, maybe they reduced the risk of damage, if they didn't it may have been a different story.

I feel a bit of a fool not knowing much about the different applications that different devices need to communicate, but you live and learn and this has prompted me to explore this area further and learn more, also if my mistakes help others in the future then all the better.
This along with my other mistake of using B instead of N in my serial program has fixed my issues.


The ATEN UC232A and the Prolific PL-2303 actually use the same chip but with different VID and PID numbers.
Thank you for your reply, that is very useful information, thank you.
I am going to learn more on this subject and the differences between different chips.




Thank you all, I half expected blunt comments like "Read the manual" or "Google it" but I felt that you genuinely want to help others in their tasks and learn from it with useful information, no matter how much of a novice mistake they make :)

HC-12 error sorted.jpg
 

hippy

Technical Support
Staff member
Luckily the HC-12 modules seems to be functioning correctly, as my cable has the 22k and 10k resistors on it for picaxe programming, maybe they reduced the risk of damage, if they didn't it may have been a different story.
The AXE027 is 0V/5V, and the 22K will have helped if the HC-12 is a 3V3 device.

It is connecting the +/-10V of RS232 which is what is likely to cause damage.

I feel a bit of a fool not knowing much about the different applications that different devices need to communicate, but you live and learn and this has prompted me to explore this area further and learn more
Generally, for FTDI, Prolific, any other chips, if the USB-to-Serial interface is on a PCB with header pins it will be 0V/5V or 0V/3V3 signalling, sometimes link selectable, with normally high, active low, "UART" polarity.

If it's a 9-way D it likely is +/-10V RS232, normally low, active high.

Other connectors are best treated as RS232 until confirmed it isn't.

The AXE027 is a bit of an oddity, UART signalling levels, but RS232 polarity.
 
Top