This is very strange, I have never seen somehting like this
please help if you could
I get a response back from the ph stamp, i do get the ph but one of the characters is weird. looks like this
7.x4 (where is the x comming from?!?!?)
also when i unplug the ph probe, one would expect a reply from the stamp saying no probe
this is what i get
chÅck pòobÅ and sometimes cheÃk ðroÂe
here is my code
#include <NewSoftSerial.h> //this will let the software take advantage of the "newsoftserial" library.
NewSoftSerial mySerial = NewSoftSerial(7, 8);
char stamp_data[15];
//this is where the data from the stamp is stored. The array is 15 char long because
//if no pH probe is connected, the message "check probe" is transmitted.
//Having an array that is too small will cause data corruption and could cause the Arduino to crash.
byte holding;
//used to tell us the number of bytes that have been received by the Arduino and are
//holding in the buffer holding
byte i;
void setup()
{
mySerial.begin(38400);
Serial.begin(57600);
delay(1000);
mySerial.print("l0"); //the command "c" will tell the stamp to take continues readings
mySerial.print(13,BYTE); //ALWAYS end a command with <CR> (which is simply the number 13) or//(print("/r")
delay(1000);
mySerial.print("r"); //the command "c" will tell the stamp to take continues readings
mySerial.print(13,BYTE); //ALWAYS end a command with <CR> (which is simply the number 13) or//(print("/r")
}
void loop() { //main loop
if(mySerial.available() > 0) { //if we see the more than three bytes have been received by the Arduino
holding=mySerial.available(); //lets read how many bytes have been received
for(i=1; i <= holding;i++){ //we make a loop that will read each byte we received
stamp_data[i]= mySerial.read(); //and load that byte into the stamp_data array
}
for(i=1; i <= holding;i++){ //we now loop through the array
Serial.print(stamp_data[i]); //printing each byte we received through the hardware UART
}
Serial.println(""); //once we finished, we print a null char with the <CR><LF> command.
mySerial.flush();
}
}
also using different code as well i get weird looking characters
#include <NewSoftSerial.h> //this will let the software take advantage of the "newsoftserial" library.
NewSoftSerial mySerial = NewSoftSerial(7, 8);
void setup()
{
mySerial.begin(38400);
Serial.begin(57600);
}
void loop()
{
char inData_pH[24];
int index =0;
float pH_val = 0.0;
mySerial.print("c"); //the command "c" will tell the stamp to take continues readings
mySerial.print(13,BYTE); //ALWAYS end a command with <CR> (which is simply the number 13) or//(print("/r")
delay(1000);
while (mySerial.available() > 0 && index < 5)
{
inData_pH[index] = mySerial.read();
index++;
inData_pH[index] = '\0';
}
Serial.print("Sensor output: [");
Serial.print(inData_pH); Serial.println("]");
// pH_val = atof(inData_pH);
// Serial.println(pH_val);
}