Hello everybody, I am having trouble to send data back from HC12 receiver to HC12 sender.
I want to have communication like so : HC12 sender sends data --> received by receiver --> add a char --> send it back to the sender to be read.
This is my sender code :
void loop() {
String str = Raspi.readStringUntil('
and receiver :
void loop() {
String input = HC12.readStringUntil('}'); //read data from sender
char ab = input.charAt(input.length() - 1);
if (input.length() > 15) {
if (ab == ']') {
input = input + "}" +"&";
//Serial.println(input);
HC12.print("%");
HC12.println(input);
}
HC12.flush();
}
i've checked data sent from sender to receiver via serial monitor, and it's sent. But I can't send the added string data back to sender from receiver.
What could be wrong? Oh, and anyway, I wish i could do back and forth communication with no using serial monitor.
Thanks before!); //read from raspi
if (str.length() > 15) {
HC12.println(str);
}
HC12.flush();
delay(500);
if (HC12.read()=='%'){ //read data from receiver
String str1 = HC12.readStringUntil('&'); //read from receiver until &
if (str1.length() > 1) {
Serial.println(str1);
}
}
and receiver :
§DISCOURSE_HOISTED_CODE_1§
i've checked data sent from sender to receiver via serial monitor, and it's sent. But I can't send the added string data back to sender from receiver.
What could be wrong? Oh, and anyway, I wish i could do back and forth communication with no using serial monitor.
Thanks before!