Problem reading Atlas Scientific PH circuit
hello
i have following product:
https://www.atlas-scientific.com/product_pages/circuits/ezo_ph.html?
datasheet: https://www.atlas-scientific.com/_files/_datasheets/_circuit/ph_ezo_datasheet.pdf?
sample code: https://www.atlas-scientific.com/_files/code/arduino_ph_sample_code.pdf?
i using arduino uno
my problem simple one, after long playing around haven't found solution hope here forum can point me in right direction.
when use sample code atlas scientific don't readings in serial monitor.
but sure arduino, ph circuit , wiring working correctly because when use super_ez_com method readings on serial monitor.
thank help!
i have following product:
https://www.atlas-scientific.com/product_pages/circuits/ezo_ph.html?
datasheet: https://www.atlas-scientific.com/_files/_datasheets/_circuit/ph_ezo_datasheet.pdf?
sample code: https://www.atlas-scientific.com/_files/code/arduino_ph_sample_code.pdf?
i using arduino uno
my problem simple one, after long playing around haven't found solution hope here forum can point me in right direction.
when use sample code atlas scientific don't readings in serial monitor.
but sure arduino, ph circuit , wiring working correctly because when use super_ez_com method readings on serial monitor.
code: [select]
//this code has intentionally has been written overly lengthy , includes unnecessary steps.
//many parts of code can truncated. code written easy understand.
//code efficiency not considered. modify code see fit.
//this code output data arduino serial monitor. type commands arduino serial monitor control ph circuit.
//set var arduino_only equal 1 watch arduino take on control of ph circuit.
//as of 11/6/14 default baud rate has changed 9600.
//the old defaul baud rate 38400.
#include <softwareserial.h> //we have include softwareserial library, or else can't use it.
#define rx 2 //define pin rx going be.
#define tx 3 //define pin tx going be.
softwareserial myserial(rx, tx); //define how soft serial port going work.
char ph_data[20]; //we make 20 byte character array hold incoming data ph.
char computerdata[20]; //we make 20 byte character array hold incoming data pc/mac/other.
byte received_from_computer=0; //we need know how many characters have been received.
byte received_from_sensor=0; //we need know how many characters have been received.
byte arduino_only=0; //if operate ph circuit arduino , not use serial monitor send commands set 1. data still come out on serial monitor, can see working.
byte startup=0; //used make sure arduino takes on control of ph circuit properly.
float ph=0; //used hold floating point number ph.
byte string_received=0; //used identify when have received string ph circuit.
void setup(){
serial.begin(9600); //enable hardware serial port
myserial.begin(9600); //enable software serial port
}
void serialevent(){ //this interrupt trigger when data coming serial monitor(pc/mac/other) received.
if(arduino_only!=1){ //if arduino_only not equal 1 function bypassed.
received_from_computer=serial.readbytesuntil(13,computerdata,20); //we read data sent serial monitor(pc/mac/other) until see <cr>. count how many characters have been received.
computerdata[received_from_computer]=0; //we add 0 spot in array after last character received.. stop transmitting incorrect data may have been left in buffer.
myserial.print(computerdata); //we transmit data received serial monitor(pc/mac/other) through soft serial port ph circuit.
myserial.print('\r'); //all data sent ph circuit must end <cr>.
}
}
void loop(){
if(myserial.available() > 0){ //if see ph circuit has sent character.
received_from_sensor=myserial.readbytesuntil(13,ph_data,20); //we read data sent ph circuit until see <cr>. count how many character have been received.
ph_data[received_from_sensor]=0; //we add 0 spot in array after last character received. stop transmitting incorrect data may have been left in buffer.
string_received=1; //a flag used when arduino controlling ph circuit let know complete string has been received.
serial.println(ph_data); //lets transmit data received ph circuit serial monitor.
}
if(arduino_only==1){arduino_control();} //if var arduino_only set 1 call function. letting arduino take on control of ph circuit
}
void arduino_control(){
if(startup==0){ //if arduino booted up, need set things first.
myserial.print("c,0\r"); //take ph circuit out of continues mode.
delay(50); //on start first command missed.
myserial.print("c,0\r"); //so, let's send twice.
delay(50); //a short delay after ph circuit taken out of continues mode used make sure don't on load commands.
startup=1; //startup completed, let's not again during normal operation.
}
delay(800); //we take reading ever 800ms. can make longer or shorter if like.
myserial.print("r\r"); //send command take single reading.
if(string_received==1){ //did data ph circuit?
ph=atof(ph_data); //many people ask "how convert string float?" how...
if(ph>=7.5){serial.println("high\r");} //this proof has been converted float.
if(ph<7.5){serial.println("low\r");} //this proof has been converted float.
string_received=0;} //reset string received flag.
}
//here functions might find useful
//these functions not enabled
void cal_s(){ //calibrate ph of 7
myserial.print("cal,mid,7\r");} //send "cal,mid,7" command calibrate ph of 7.00
void cal_f(){ //calibrate ph of 4
myserial.print("cal,low,4\r");} //send "cal,low,4" command calibrate ph of 4.00
void cal_t(){ //calibrate ph of 10.00
myserial.print("cal,high,10\r");} //send "cal,high,10" command calibrate ph of 10.00
void phfactorydefault(){ //factory defaults ph circuit
myserial.print("x\r");} //send "x" command factory reset device
void read_info(){ //get device info
myserial.print("i\r");} //send "i" command query information
void phsetleds(byte enabled) //turn leds on or off
{
if(enabled) //if enabled > 0
myserial.print("l,1\r"); //the led's turn on
else //if enabled 0
myserial.print("l,0\r"); //the led's turn off
}
thank help!
that code doesn't make me happy, not programming. think wrong. did accidently copy line wrong place ? original ?
could write sketch passes data in both ways ? can type commands in serial monitor , arduino in between.
how did connect module ? gnd connected ?
i think arduino pin 2 (soft rx) ph module pin rx.
and arduino pin 3 (soft tx) ph module tx.
could write sketch passes data in both ways ? can type commands in serial monitor , arduino in between.
code: [select]
// not tested
...
void setup()
{
serial.begin(9600); //enable hardware serial port
myserial.begin(9600); //enable software serial port
serial.println("sketch has started !");
serial.println("select carriage return serial monitor");
}
void loop()
{
if (serial.available() > 0)
myserial.write (serial.read());
if (myserial.available() > 0)
serial.write (myserial.read());
}
how did connect module ? gnd connected ?
i think arduino pin 2 (soft rx) ph module pin rx.
and arduino pin 3 (soft tx) ph module tx.
Arduino Forum > Using Arduino > Sensors > Problem reading Atlas Scientific PH circuit
arduino
Comments
Post a Comment