Atlas scientific ph/orp stamp RS232

    for(i=0; i <= holding;i++){       //we make a loop that will read each byte we received

If you got 4 characters, holding will contain 4. You loop while i=0, i=1, i=2, i=3 and i=4, to read 5 of the available 4 characters.

The data sheet for the sensor says:

The output is (up to five) ASCII digits representing the PH and ending
with a carriage return (ASCII 13).
Example:
4.60

So, you should be reading data until the arrives, not just whatever happens to have arrived at any given moment.

I have just tested my code on Arduino UNO (supply of 5v) as opposed to Arduino fio 328 (supply of 3.3v)
and it works like a charm, no garbage characters

I figured the serial out from the ph stamp is at a different level somehow to the arduino fio..

any help to get it to work with the fio

I have already tried the HEF4050 with both 3.3 and 5v as supply but still same garbage coming out...

First time on here and new to Arduino programming, hoping to get some help or advice.

It looks like Atlas Scientific has been changing the pH stamp commands with each new version. I am using version 3.0, the latest version, in which the data sheet says the output can return up to 12 ASCII characters. According the the sellers instructional video, the null command is used to make an LED blink on the pH stamp (- YouTube), and from reading forums like this I have learned it is also needed to make an array (no idea why). I finally have my Arduino Uno displaying readable text on the serial monitor using a slight variation from the sample code provided by Atlas (as it looks like you guys have been discussing on here). The problem is that the data I am receiving does not appear to be pH readings, I get continous lines (in the serial monitor) of:

...
base: 0acid: 2012.91
base: 0acid: 2012.91
base: 0acid: 2012.91
base: 0acid: 2012.91
...

Here is the code I am using (not sure how to shrink it down like you guys are doing):

#include <NewSoftSerial.h> //this will let the software take advantage of the "newsoftserial" library.

NewSoftSerial mySerial = NewSoftSerial(2, 3); //setup and rename soft uart.
// RX|TX

void setup(){
mySerial.begin(38400);
Serial.begin(38400);
}

void loop() {

mySerial.print('r'); //take a reading from the sensor, end with carriage return
mySerial.print(13,BYTE);
delay(5000); //delay to read serial monitor

int holding;
int i;
char stamp_data[25];

if(mySerial.available() > 3) { //if we see the more then 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*= 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*); //printing each byte we recived through the hardware UART*
    * }*
    * Serial.println(""); //once we finished, we print a nul char with the command.*

* }*
}
Any help?

Notice how half of your post is in italics? Modify your post, select your code, and press the # icon on the second row, and save.

Some questions. Why are you waiting specifically for 3 bytes to arrive, when clearly there are a lot more than 3 arriving? Where did you get the 12 character value from? What you show as your output has more than 12 characters.

ossama:
I have just tested my code on Arduino UNO (supply of 5v) as opposed to Arduino fio 328 (supply of 3.3v)
and it works like a charm, no garbage characters

I figured the serial out from the ph stamp is at a different level somehow to the arduino fio..

any help to get it to work with the fio

I have already tried the HEF4050 with both 3.3 and 5v as supply but still same garbage coming out...

ossama,

I am experiencing exactly the same problem as you (the garbage characters), same Arduino Fio 328p. Haven't tried on a 5v model yet(unfortunately I made a Fio specific PCB).
Have you eventually found a workaround?

Thanks,