HC-12 module stops working midway through

I am using 2 HC-12 modules to communicate between an Arduino uno and an ESP-32 board. Everything works fine for a while, with the HC-12 responding appropriately to AT commands and transmitting data. However, after some time, the HC-12 communication just ... stops.

I tried checking the HC-12 on the arduino uno with the AT commands, and I do not get any response. The HC-12 on the ESP32 still responds to the AT commands. I decided to swap the HC-12s, to see if this is a problem of one of the HC-12 modules, but even then, the HC-12 on the arduino uno now (which was originally connected to esp32) did not respond to AT commands, and the HC-12 on the ESP-32 (which was originally connected to the arduino uno) responds to AT commands. This must mean this is a problem on the Arduino Uno.

I then changed the pins I used for my RX and TX on the Arduino, and then my HC-12 module on the Arduino starts working again. However, after a few hours, they stop working again, and I have to change pins once again.

Would anyone have any idea why Arduino Uno behaves this way? Resetting the board does not fix this, and the only thing that seems to fix this is time. Is there something in the Software Serial library that causes this problem? This is something that has made me waste a lot of time :frowning:

Does your Uno only have the HC-12 connected? Or is there something more?
Does power cycling the Uno and HC-12 solve the issue (this is not the same as a simple reset of the Uno as you did try).
Bad contacts might be a cause of your problems.

Hi, currently there is also a micro-SD card reader attached to the Uno, but this problem has been persisting for quite some time, before I used the microSD card reader. Maybe the reader might be making this happen more frequently? But I am not too sure, I haven't been recording how often I face this issue

What does power cycling mean? Does it just mean to disconnect the Uno from the power supply and reconnect it (in my case, my laptop)? If so, yeah, I also try that, but get the same result.

Regarding bad contacts, that might be possible too, but I just wanted to see if there were any other possibilities before I conclude that

Hello a_x

Post a connection and wiring diagram of your project.

Could insufficient memory on the Uno be a possible cause of the problems? Uno has only 2K and SD card library can easily use half of that.

Memory usage reported by the compiler may not be a reliable guide to how much memory is being used, as much of it is allocated at run time.

Both Arduino and HC-12; if the HC-12 is powered from the Uno, disconnecting the Uno from the laptop should be sufficient.

My comment was based on your comment that just resetting the Uno is not sufficient to get communication going again so possibly the HC-12 might get into an unknown state.

I doubt it is the SoftwareSerial that causes the problem; problems like you experience would have been picked up / known long ago if they were in the library.

If you don't trust the library, there are alternatives like AltSoftSerial and NeoSWSerial.

From the HC-12 pdf datasheet/manual, page 3:

They suggest it in order to take advantage of the diode's forward voltage drop effect.

I fried a HC-12 module once on the Uno due to not paying attention to this. It occurred during a data burst transmission. After that experience, I always put a 1N4007 there between the module's VCC and the Uno(or any other 5v power source/supply) when operating above 4.5v no matter, even if the module is sitting there just as a receiver. I found no drop in output power, data rate nor range when the diode was added.

Just to be on the safe side, I also always put an electrolytic decoupling capacitor(I think I'm using a 100uf 16v one) in series with the module(between VCC and GND).

Reference: https://www.elecrow.com/download/HC-12.pdf

My connections are:

Arduino -> HC12
3.3V -> VCC
GND -> GND
Pin 4 -> RXD
Pin 3 -> TXD

Arduino -> microSD card Reader
3.3v -> 3V3
Pin 10 -> CS
Pin 11 -> MOSI
Pin 12 -> MISO
Pin 13 -> CLK
GND -> GND

But this problem has been persisting before I started using the microSD card reader, so I doubt this is the error.

Actually, I have picked up this problem for a long time, but I always just ignored it until today when I decided to see how I could fix this problem.

Oh okay, thanks for that, if I can't find a solution and the problem keeps recurring I will try those libraries.

I see, but I have been using a voltage of 3.3 V, so I don't foresee facing that issue.

How does the decoupling capacitor help? Does it just make data transmission smoother?

1 Like

Could you at least try powering it from the output of the Uno's 5v regulator through a 1N4007 diode and see how it goes?

Well, I don't think so. In the use case I had to work with the HC-12, there's two different Arduino types. One which most of the time just transmits data continuously is a Uno, and it's making use of the Software Serial library:

#define HC12_TX 5
#define HC12_RX 6
#define BAUD_RATE 19200

SoftwareSerial HC12(HC12_TX, HC12_RX);

void setup() {
  HC12.begin(BAUD_RATE); 
}

The rest of it(from A0 to A5) is a bunch of analog sensors. Works just fine.

The other Arduino is a ATmega32U4-based Arduino Micro, which has a dedicated hardware serial available to the developer.

#define BAUD_RATE 19200

void setup() {
  Serial1.begin(BAUD_RATE); 
}

The rest of it are servos and relays.

Both work just fine with a distance of a little more than 600m between them. Both are equipped with a Nagoya Na-771 external antenna. Communication is very smooth.

I hope it helps!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.