HC-12's communicate only one-way?

I am trying to get a HC-12 to send sensor data to another HC-12 using 2 Arduino Uno's. I found a simple sketch on the internet that claims I can enter something in one of the serial monitors and it will appear on the other serial monitor. This seems to only work one-way. If I enter something in the serial monitor of Arduino"A" it will appear on the serial monitor of Arduino"B". However, if I enter something in the serial monitor of Arduino"B" it does not show up on the serial monitor of Arduino"A". I took it a step further by hooking up a GPS to Arduino"A" and it indeed spits out NMEA sentences on the serial monitor of Arduino"B".

Do HC-12's only communicate(transmit) one-way?

I am using the below code found at www.HowToMechatronics.com:

#include <SoftwareSerial.h>

SoftwareSerial HC12(10, 11); // HC-12 TX Pin, HC-12 RX Pin

void setup() {

Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12

}

void loop() {

while (HC12.available()) { // If HC-12 has data
Serial.write(HC12.read()); // Send the data to Serial monitor
}
while (Serial.available()) { // If Serial monitor has data
HC12.write(Serial.read()); // Send that data to HC-12
}
}

the manual says they are half duplex. two way serial, but one way at a time

Hi,

I ran into same issue just now, and found your question. But, I also figured out a solution!

In my case, apparently not all pins of the arduino-boards are suitable for RX TX communication.

I use the same sample code you found, but changed pins 4 and 5, and used 10 and 11 instead. Now it works fine! (after connecting the HC12 boards to the new pins of course!).

Hope this is still of help to you, or someone else who runs into this problem.

tom_kieboom:
Hope this is still of help to you, or someone else who runs into this problem.

It would be an idea to point people to the reference page for Software serial;

https://www.arduino.cc/en/Reference/softwareSerial

There you will see that all pins can be used for Software serial on a UNO, which was what the OP was using, but not all pins can be used on a Mega for instance.