Baud rates are the same but Serial throwing a tantrum!

So I am communicating with one of Atlas scientifics stamps for pH. I am trying to pass a string to it to read back a single pH value. It all works fine, however the serial terminal also displays a load of other nonsense:
You can see the values are coming back fine:

7.¾¿íÿ¿ÿûí·¯¿¿Í6.82

6.82

·¯¿¿í÷ÿÿûý7.<3

7.01

7.01

7.01

·¯¾½íÿ¯ÿÿÿ7.<1

7.01

7.01

7.01

7.01

ÿ�íÿÿÿÿý7.01

7.01

7.01

7.01

·¯<½íÿ¿ÿýÿ7/>9í7.01

7.01

7.01

·¯¿½ÿ¯¿½í÷ÿÿÿý7.81

In the past Ive only experienced this kind of thing when baud rates are out, however they aren’t in this case. Im using the serial library to pass the info to the terminal and a softserial to communicate with the stamp, both at 38400 - the terminal is also at that rate. Im using an interupt every second to pass the command to the stamp - that all works fine, sorry for the long code but Im only attaching it so you believe I set my two serial bauds to the same!

#include <SoftwareSerial.h>  //add the soft serial libray
#include <avr/io.h>          
#include <avr/interrupt.h>    //for the interrupt routine

#define ISR_TIMER1_COUNT 62499 // 16.0MHz clock / (prescaler = 256) 1Hz counter

#define rxph 2 //set the RX pin to pin 2
#define txph 3 //set the TX pin to pin 3

SoftwareSerial pH (rxph, txph); //enable the soft serial port

String inputstringPH = ""; //a string to hold incoming data from the PC
String sensorstringPH = ""; //a string to hold the data from the Atlas Scientific product
volatile boolean inputPH_stringcomplete = false; //have we received all the data from the PC
volatile boolean sensorPH_stringcomplete = false; //have we received all the data from the Atlas Scientific product
void setup()  //set up the hardware
{ 
    setupTimer1();     //calls the timer setup function for the interupt
 Serial.begin(38400); //set baud rate for the hardware serial port to 38400
 pH.begin(38400); //set baud rate for software serial port to 38400
 pinMode(12, OUTPUT); //toggle the led when the interupt 'ticks'
 inputstringPH.reserve(5); //set aside some bytes for receiving data from the PC
 sensorstringPH.reserve(30); //set aside some bytes for receiving data from the Atlas Scientific product
 inputstringPH = "R\r";
}  
void loop()  //here we go...
{
 if (inputPH_stringcomplete)  //if a string from the PC has been recived in its entiery
 {
  pH.print(inputstringPH); //send that string to the Atlas Scientific product
  inputPH_stringcomplete = false; //reset the flag used to tell if we have recived a complete string from the PC
 }
 while (pH.available()) //while a char is holding in the serial buffer
 { 
  char incharPH = (char)pH.read(); //get the new char
  sensorstringPH += incharPH; //add it to the sensorstring
  if (incharPH == '\r') 
  {
   sensorPH_stringcomplete = true;  //if the incoming character is a <CR>, set the flag
  } 
 }
 if (sensorPH_stringcomplete)  //if a string from the Atlas Scientific product has been received in its entirety
 { 
Serial.println(sensorstringPH); //use the hardware serial port to send that data to the PC
  sensorstringPH = ""; //clear the string:
  sensorPH_stringcomplete = false; //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
 }
}

Thanks guys

Inversion?

The code you posted produces the results you posted?

The PH sensor passes back a string (lower case s) of a maximum size. Go look up what that is, and ditch the String class.

Would you mind elaborating.. I've not heard of this

Sorry my reply was @ AWOL there and all your other post must of come in just befor I posted XD.

PaulS, I'm not quite sure what you mean here, my code is adapted from the one Atlas Scientific as placed on their website, it can be seen here: http://atlas-scientific.com/_files/code/Arduino-sample-code-EZ-COM.pdf

They have set it up so the command to take a reading is sent from the terminal and just requires 'R/r'. I dont see why my method should not work, as I dont change anything that the stamp does in terms of it replying, I simply send it a command in a different way!

@ Coding badly, yes the code I posted retrieves that result.

Still though, would anyone mind elaborating on 'inversion', never heard of that before.

Thanks

Grounds connected?

Thanking you, newbie error :blush:

I dont see why my method should not work, as I dont change anything that the stamp does in terms of it replying, I simply send it a command in a different way!

An unnecessarily complicated way, but that isn't the problem, is it? It is that between reading and printing the reply, you are getting a lot of garbage.

I suggested a static array, or the proper size, NULL terminated as data is added. You choose not to do that, even though it will result in a smaller footprint and probably eliminate the extra garbage being printed. Fine. I can accept that. Good luck.