Sending and receiving a string

Hi Guys and Gals;

I’m building a robot that will be controlled by an Android Tablet. I need to grab my x/y coordinates from the tablet, do some math to them then prefix each with a letter (Z in the code below) before sending them over a BlueTooth serial link. Everything works except for the sending and receiving of them over the serial link. The toast in my example tells me that WRP is being correctly calculated, Z10.0 for example. But on my receive side serial monitor I get 50 (linefeed) 46. The 50 is stable, the 46 changes, but not consistently, and not equal to A.

If I try “sendData(“S”);” I correctly receive an S on my serial monitor.

All the tutorials and references I have found only send a single character.

This is probably a stupid question but ,how do I send and receive a short string?

For simplicity’s sake I have boiled down the problem to the following;

On the transmit side (Android Tablet):

btnOff.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

A=A+1;

String WRP = (Double.toString(A));

WRP = “Z”+ WRP;

sendData(WRP);

Toast msg = Toast.makeText(getBaseContext(),

WRP, Toast.LENGTH_SHORT);

msg.show();

}

});

btnStop.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

sendData(“S”);

}

});

AND

private void sendData(String message) {

byte msgBuffer = message.getBytes();

Log.d(TAG, "…Sending data: " + message + “…”);

try {

outStream.write(msgBuffer);

} catch (IOException e) {

String msg = "In onResume() and an exception occurred during write: " + e.getMessage();

if (address.equals(“00:00:00:00:00:00”))

msg = msg + “.\n\nUpdate your server address from 00:00:00:00:00:00 to the correct address on line 37 in the java code”;

msg = msg + “.\n\nCheck that the SPP UUID: " + MY_UUID.toString() + " exists on server.\n\n”;

errorExit(“Fatal Error”, msg);

}

}

On the Receive side:(Arduion Uno)

void loop() {

if (mySerial.available())

dataFromBT = mySerial.read();

Serial.println(mySerial.read());

}

Thanks in Advance!

Don