I'm trying to communicate between 2 arduinos using HC-12 modules.

ofir

Joined Feb 20, 2018
1
hello,
im trying to communicate between 2 arduinos using HC-12 modules.
i connected them well like the picture above with the diode and the capacitor, where my arduino is my power supply.

i have a simple code for message transmit and recieve. same code for both arduinos.
messages wont send.
this is the code:

C:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); //RX, TX

void setup() {
Serial.begin(9600);
mySerial.begin(9600);
}

void loop() {
if(Serial.available() > 0){//Read from serial monitor and send over HC-12
mySerial.println(input);
}

if(mySerial.available() > 1){//Read from HC-12 and send to serial monitor
Serial.println(input);
}
delay(20);
}
any suggestions what im doing wrong?

Mod's note:
This thread was split from HC-12 Nothing showing up in Serial monitor.

Last edited by a moderator:

FlyingCow

Joined Dec 30, 2017
72
hello,
im trying to communicate between 2 arduinos using HC-12 modules.
i connected them well like the picture above with the diode and the capacitor, where my arduino is my power supply.
View attachment 148595

i have a simple code for message transmit and recieve. same code for both arduinos.
messages wont send.
this is the code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); //RX, TX

void setup() {
Serial.begin(9600);
mySerial.begin(9600);
}

void loop() {
if(Serial.available() > 0){//Read from serial monitor and send over HC-12
mySerial.println(input);
}

if(mySerial.available() > 1){//Read from HC-12 and send to serial monitor
Serial.println(input);
}
delay(20);
}

any suggestions what im doing wrong?
@ofir,
What is your input method for the data you want to send? If you have the arduino board connected to your computer via USB and using the IDE to tell the HC-12 what you want it to send, there will be problems as they will share the serial bus. I am using a simplified explanation for this but never-the-less, it won't work if you have it connected that way. I used a pair of unos with the chip removed and that worked very well while connected to my computer and typing into the serial monitor in the IDE.
CLARIFICATION: Actually, they won't share the serial bus, which is the problem, they will compete for it and nothing will get through. Someone else may come on here and explain it better, but you get the idea. Another method is to use an FTDI connector.

Last edited:

FlyingCow

Joined Dec 30, 2017
72
@ofir,
Did I answer your question? I sometimes miss the point so I like to ask so you can redirect me if need be. Let me know if the above information helps.

Mitch

shteii01

Joined Feb 19, 2010
4,644
Ok.
From the top.
Your picture shows that you use pins 4 and 5.
Your code shows that you use pins 2 and 3.
I am done.