Go Down

Topic: pH sensor code (Read 1 time) previous topic - next topic

racefan917

I'm looking for a program code that will work with the arduino uno to control an Atlas Scientific pH sensor. I don't need it to do anything but output a pH reading. I'm having problems getting the sample code the Atlas Scientific website has to work. I was wondering if anyone has suggestions to get their sample code to work or has a program of their own? Thanks!

PaulS

Quote
I'm having problems getting the sample code the Atlas Scientific website has to work.

Who is better than the manufacturer of the probe to develop the code? If you are having problems with their code, you might consider contacting them, or post the code here and explain what problems you are having.

NobleNoob

Please post example code:

The Atlas pH stamp will take a minimum 262 millis from receipt of command untill it will respond with the pH reading.  If the debug led's are enabled the lag will double. By default the pH Stamp module uses the following serial settings: 38400, 8, N, 1.

Serial3.begin(38400);

// Send Single Read Command To Stamp
Serial3.print('R');
Serial3.print(13);

// Give stamp time to do it's thing
delay(300);

// Read the stamp data

float myPH = Serial3.parseFloat();

Hope this helps, if you need more info, just post question




seanz2003

#3
Dec 10, 2012, 04:29 am Last Edit: Dec 10, 2012, 04:32 am by seanz2003 Reason: 1
Their example code works fine for me on the mega, uno, and pro mini. what issues are you having?

racefan917

At this point it might be wiring. I've got the wire going from TX on the pH microchip to the TX pin on the Arduino and the same with the RX pin. I've also tried to upload it with the two switched. I can upload the program fine, but nothing will print on the serial monitor. The baud rate and carriage return settings are correct as well. This is going to be used in a biodiesel process so the only thing attached to the arduino is this sensor

NobleNoob

Arduino TX Pin to pH Stamp RX pin
Arduino RX Pint to pH Stamp TX pin

holmes4

Serial3 is for the mega not the UNO try using Serial.

Mark

racefan917

//here's the sample code im using thee only modifications i did was add the delay's at the end just in case it needed it.

#include <SoftwareSerial.h>
#define rxpin 0
#define txpin 1
SoftwareSerial myserial(rxpin, txpin);
String inputstring = "";
String sensorstring = "";
boolean input_stringcomplete = false;
boolean sensor_stringcomplete = false;
void setup(){
Serial.begin(38400);
myserial.begin(38400);
inputstring.reserve(5);
sensorstring.reserve(30);
}
void serialEvent() {
char inchar = (char)Serial.read();
inputstring += inchar;
if(inchar == '\r') {input_stringcomplete = true;}
}
void loop(){
if (input_stringcomplete){
myserial.print(inputstring);
inputstring = "";
input_stringcomplete = false;
}
while (myserial.available()) {
char inchar = (char)myserial.read();
sensorstring += inchar;
if (inchar == '\r') {sensor_stringcomplete = true;}
}
if (sensor_stringcomplete){
Serial.print(sensorstring);
sensorstring = "";
sensor_stringcomplete = false;
delay(1000);
}
delay(1000);
}

PaulS

Code: [Select]
#include <SoftwareSerial.h>
#define rxpin 0
#define txpin 1
SoftwareSerial myserial(rxpin, txpin);

Why are you doing software serial on the hardware serial pins? You can't do both.

hidayah

paulS..... what u mean cannot do that? that is effect the value?

i done exactly with this project... but the value is display 8 output at one time... like i attach...

PaulS

Quote
what u mean cannot do that?

There is nothing ambiguous about the statement "You can not do that". If you don't understand that pins 0 and 1 can be used by the HardwareSerial instance (Serial) OR by the SoftwareSerial instance (mySerial), but not by both, I can't help you.

Go Up