Pages: [1]   Go Down
Author Topic: Software Serial and the BlueSmirf Silver - Weird Characters  (Read 1160 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
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?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 615
Posts: 49396
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  if (mySerial.available())
    Serial.write(mySerial.read());
You are reading ASCII data and sending binary data. Why?
Logged

Pages: [1]   Go Up
Jump to: