Go Down

Topic: Software Serial and the BlueSmirf Silver - Weird Characters (Read 1 time) previous topic - next topic

geek_tk

I'm having trouble reading serial sent from an Android Bluetooth terminal app. I'm using the SoftwareSerial library so that I can use pins 2 and 3 instead of 0 and 1.

On my breadboard:
BlueSmirf TX--->Arduino 2
BlueSmirf RX---> Arduino 3
BlueSmirf Vcc--> Arduino 5V
BlueSmirf Gnd---> Arduino GND


To keep things simple I'm using the example code from the Software Serial:

Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);

void setup() 
{
  Serial.begin(115200);
  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(115200);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{



  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}



Now here's the weird part - I get only the first letter of anything I send, then gibberish for the remaining characters. For example, if i sent "test" I get "t-­.÷"

If I send "word" I get "w·¹Ù"

Now, if I use this code:

Code: [Select]
void setup() 
{
  Serial.begin(115200);
  Serial.println("Goodnight moon!");

 
}

void loop() // run over and over
{
  if (Serial.available())
    Serial.write(Serial.read());
  }


And I re-connect the BlueSmirf RX/TX pins into the Arduino pins 0/1, any text I send from the phone comes over perfectly. Any ideas?


geek_tk

Does anyone have any ideas? Still experiencing the same problems. Thanks.

PaulS

Code: [Select]
  if (mySerial.available())
    Serial.write(mySerial.read());

You are reading ASCII data and sending binary data. Why?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy