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