hc-12 transferring data between two arduino got no output

Hi, I'm doing a project that collects temperature and pulse from human and sends the data wirelessly using HC-12. The project uses two Arduino, the first Arduino act as transmitter called beetle Arduino, the second Arduino act as receiver called Arduino UNO.

I tried to do this but failed to get the data from the receiver part. The problem occurs is when both Arduino is running, hc12 at receiver Arduino show no output, but when I disconnected the transmitter Arduino, I get a bunch of output suddenly display on the serial monitor.

here the code I used for transmitter part

#include <SoftwareSerial.h>
#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>

SoftwareSerial hc12(10, 9);  //tx, rx
int pulsesensorsignal = A0;
int tempsensorsignal = A1;
int pulsedata;
float tempdata;
int threshold = 516;
PulseSensorPlayground pulseSensor;

void setup() {
  Serial.begin(9600);
  hc12.begin(9600);

  pulseSensor.analogInput(pulsesensorsignal);
  pulseSensor.setThreshold(threshold);
  pulseSensor.begin();

  pinMode(pulsesensorsignal, INPUT);
  pinMode(tempsensorsignal, INPUT); 
  }

void loop() {

  pulsedata = pulseSensor.getBeatsPerMinute();
  tempdata = analogRead(tempsensorsignal);
  tempdata = tempdata * 5*100/1024;

  pulseSensor.sawStartOfBeat();
  Serial.print(" temp ");
  Serial.print(tempdata, 2);
  Serial.print(" pulse ");
  Serial.print(pulsedata);
  Serial.println(" ");

  sendTemp(tempdata, pulsedata);
  delay(1000);
  }

void sendTemp(float tempdata, int pulsedata) {
  hc12.print(" temp ");
  hc12.print(tempdata, 2);
  hc12.print(" pulse ");
  hc12.print(pulsedata);
  hc12.println(" ");
  }

here the code I used for receiver part

#include <SoftwareSerial.h>
SoftwareSerial hc12(3, 2); //tx, rx
String RFInput;

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

void loop() {
  
  if(hc12.available() > 1)  {
    hc12.begin(9600);
    RFInput = hc12.readString();//read string
    Serial.println(RFInput);
    }
  delay(1000);
  }

please help me with this problem, thank you

ameer786:
when I disconnected the transmitter Arduino, I get a bunch of output suddenly display on the serial monitor.

Which Arduino is the Serial Monitor connected to? What is the output? Is it the data you expected, or just some random garbage?

ameer786:

  if(hc12.available() > 1)  {

hc12.begin(9600);

Remove the "hc12.begin(9600);" here in your code. You should only call that once in setup().

@OP

Receiver Side: SoftwareSerial hc12(3, 2); //tx, rx
Transmitter Side: SoftwareSerial hc12(10, 9); //tx, rx

With reference to your above declarations, please consult the following diagram and then answer to the questions:
hc12-2y.png

Q1. Which DPin (digital pin) of UNO (Receiver) have you connected with TXD-pin of HC12 Modeule?
Q2. Which DPin (digital pin) of UNO (Receiver) have you connected with RXD-pin of HC12 Modeule?

Q3. Which DPin (digital pin) of Transmitter have you connected with TXD-pin of HC12 Modeule?
Q4. Which DPin (digital pin) of Transmitter have you connected with RXD-pin of HC12 Modeule?

hc12-2y.png

Is the data you are receiving when you disconnect a bunch of junk or is it the data you expected? If its the latter, then you might need to flush the serial buffers.