The following example uses two UNOs to exchanges messages (Hello! and Fine1) between then using HC12 Radio Modules. It could be helpful for you.
Figure-1: Connection diagram between HC12 Module and UNO
(1) Let us build the setup as per above circuit diagram of Fig-1.
(2) Create, compile, and upload the following sketch into the flash of the Master UNO-1. Save the program as hc12-1.
#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 11); // SRX (10) of SUART goes to TXD-pin of HC12; STX (11) --> RXD of HC12
void setup()
{
Serial.begin(9600); // Harware Serial port to computer
HC12.begin(9600); // Software Serial port to HC12
}
void loop()
{
while (HC12.available()) // If HC-12 has data
{
Serial.write(HC12.read()); // Send the data to Serial Monitor
}
}
(3) Upload the program codes of Step-2 into the flash of UNO-2.
(4) Bring in SM1 for UNO-1.
(5) Bring in SM2 for UNO-2.
(6) In SM1, enter Hello! And click the Send button. Check that ‘Hello!’ has appeared on the SM2 of UNO-2.
(7) In the InputBox of SM2, enter Fine! And click the Send button. Check that ‘Fine!’ has appeared on SM1.