Hello,
I've got an application using Serial to read/write data to a Bluetooth modem. Currently, the bluetooth modem is connected to the pre-marked Rx/Tx pins on the Due. I am using the SerialUSB (Native USB Port) for debugging in the Serial monitor. This has been working great. Now, I want to issue some commands to the connected modem to change it's name. I cannot seem to figure out how to take commands in through the Serial Monitor using SerialUSB.read() and write them to the Serial, and be able to read it's response back to the Serial Monitor through SerialUSB.
This is currently what I am trying, and the device is reacting, but I just see a bunch of numbers printed to the screen. Is there a way for Serial to translate this to ASCII by default?
void setup()
{
// Serial monitor
SerialUSB.begin(9600);
// Bluetooth modem
Serial.begin(115200);
}
void loop()
{
if (SerialUSB.available())
{
unsigned char out_msg = SerialUSB.read();
Serial.write(out_msg);
}
if (Serial.available())
{
unsigned char in_msg = Serial.read();
SerialUSB.print(in_msg);
}
}
This is the device and guide I am using for communication: Device Setup Guide
They are using SoftwareSerial library, which I assumed that I could directly translate to Serial and SerialUSB and have it work the same, but apparently I am doing something wrong?
If I change Serial.write(out_msg)
to Serial.print(out_msg)
I get no response back to the Serial Monitor?
Thanks in advance for any help!