5 years, 5 months ago.

Arduino serial print working mbed not.

I am trying to configure a bluetooth module using the mbed. I have the code operational on an arduino. But when I transferred the code to the mbed I am not able to get the device configure.

int main() {

device.baud(115200); device.printf("SET\n\r"); device.printf("SET BT NAME TEST\n\r"); device.printf("RESET\n\r"); reset device to set everything in flash

while(1) { wait(1);

} }

I am able to see the messages printed via tera term. However the device is not seeing them. What is the difference between my arduino and the mbed when it comes to serial printing messages?

Here is the arduino code that is able to properly configure the device.

Serial.begin(115200); Serial.println("SET"); Serial.println("SET BT NAME TEST"); Serial.println("RESET"); reset device to set everything in flash

any insight would be appreciated.

Just a guess, but is it some type of flow control issue? Not sure how to adjust this parameter though

1 Answer

5 years, 5 months ago.

Hi TJ,

In your mbed code, try switching all "\n\r" occurrences to "\r\n". I'm not 100% sure if that will fix your problem. but generally serial devices look for "\r\n" to signal the end of a command. Having "\n\r" will sometimes confuse the device.

Let me know if that helps!


Hi Brian, Thanks for the suggestion. I originally tried this one to replicate arduino. Unfortunately the device still does not configure properly when reserving the new line and carriage return.


posted by TJ Houck 16 Jun 2015

Hmm, you can post all of your code, including the declaration of your Serial instance ("device" in this case). Also, what platform are you using?

posted by Brian Daniels 16 Jun 2015