so i'm trying to use the hc 12 to built a remote control system for a tank.
In the example sketches i've seen they send information by reading in what you type in the serial command line 1 character at a time and sending it via the hc12. How would i send say a string "hello" from inside the code? or an analog read int like 1002? thank you for any help.
If i'm not understanding something correctly show me, don't have a go at me.
We hope that you are familiar with the procedures of data communication between Serial Monitor and UNO using hardware UART Port? Then you know most of the things. HC12 (the Radio Communication Module) is a UART driven device; it will accept all commands that are used to communicate with Serial Monitor except that the HC12 Module is recommended to be connected using a software UART Port.
What is a software UART Port?
In the Arduino UNO, we have only one hardware UART Port, and it is already engaged with the Serial Monitor and IDE.
To engage the HC12 Module, we need another UART Port which is created (simulated) using software instructions and hence the named software UART Port (SUART).
There are mainly two commands to exchange data over the UART Port, and these are Serial.print() and Serial.write(). You may practice these commands using Serial Monitor and UNO.
If i attempts to directly write a string to the hc12
if(Serial.available())
{
//stringToSend = Serial.readString();
stringToSend = "test";
HC12.write(stringToSend);
}
It throws an error.
exit status 1
no matching function for call to 'SoftwareSerial::write(String&)'
if it needs to be a char how would i split up the string to a char and send it?
GolamMostafa:
We hope that you are familiar with the procedures of data communication between Serial Monitor and UNO using hardware UART Port? Then you know most of the things. HC12 (the Radio Communication Module) is a UART driven device; it will accept all commands that are used to communicate with Serial Monitor except that the HC12 Module is recommended to be connected using a software UART Port.
What is a software UART Port?
In the Arduino UNO, we have only one hardware UART Port, and it is already engaged with the Serial Monitor and IDE.
To engage the HC12 Module, we need another UART Port which is created (simulated) using software instructions and hence the named software UART Port (SUART).
There are mainly two commands to exchange data over the UART Port, and these are Serial.print() and Serial.write(). You may practice these commands using Serial Monitor and UNO.
Thankyou! seems the problem was using hc12.write when i needed to use hc12.print!