Go Down

Topic: Atlas Scientific pH Sensor Help (Read 875 times) previous topic - next topic

ablarry91

I am sporting an Arduino Mega 2560 with an ethernet shield and Arduino 1.0 software.  I am trying to hook up an Atlas Scientific pH probe (https://www.atlas-scientific.com/product_pages/kits/ph-kit.html) which hooks to my Arduino through a BNC plug to a breakout board to the Serial3 ports. 

I'm new to serial communication and was hoping someone could help clarify what is going on and how I can manipulate this into useful information.  Right now, I am getting nothing on my computer's serial monitor, regardless of what I type in.  Any thoughts?

My wiring can be found through this link: https://www.atlas-scientific.com/_files/code/Arduino-sample-code-EZ-COM-MEGA.pdf

My coding is also found through that link, or you can refer to it below:

String inputstring = "";
String sensorstring = "";
boolean input_stringcomplete = false;
boolean sensor_stringcomplete = false;
//a string to hold incoming data from the PC
//a string to hold the data from the Atlas Scientific product
//have we received all the data from the PC
//have we received all the data from the Atlas Scientific
//product
void setup(){
Serial.begin(38400);
Serial3.begin(38400);
inputstring.reserve(5);
sensorstring.reserve(30);
}
//set up the hardware
//set baud rate for the hardware serial port_0 to 38400
//set baud rate for software serial port_3 to 38400
//set aside some bytes for receiving data from the PC
//set aside some bytes for receiving data from Atlas Scientific
//product
void serialEvent() {
char inchar = (char)Serial.read();
inputstring += inchar;
if(inchar == '\r') {input_stringcomplete = true;}
}
//if the hardware serial port_0 receives
//a char
//get the char we just received
//add it to the inputString
//if the incoming character is a <CR>,
//set the flag
void serialEvent3(){
char inchar = (char)Serial3.read();
sensorstring += inchar;
if(inchar == '\r') {sensor_stringcomplete = true;}
}
//if the hardware serial port_3 receives
//a char
//get the char we just received
//add it to the inputString
//if the incoming character is a <CR>,
//set the flag
void loop(){
if (input_stringcomplete){
Serial3.print(inputstring);
inputstring = "";
input_stringcomplete = false;
}
//here we go...
//if a string from the PC has been received in its entierty
//send that string to the Atlas Scientific product
//clear the string:
//reset the flag used to tell if we have received a completed
//string from the PC
if (sensor_stringcomplete){
Serial.println(sensorstring);
sensorstring = "";
sensor_stringcomplete = false;
}
}
//if a string from the Atlas Scientific product has been
//received in its entierty
//send that string to to the PC's serial monitor
//clear the string:
//reset the flag used to tell if we have received a
//completed string from the Atlas Scientific product


Carsten53T

#1
Jul 12, 2012, 09:16 am Last Edit: Jul 12, 2012, 09:19 am by Carsten53T Reason: 1
Your code lies very close to the example-code.
If I was to put that on my board/pc, the setup would fail on
Serial.begin(38400);
For whatever reason, my pc communicates on
Serial.begin(9400);
... if I recall right, the symptoms of a silent/no-error response matches my experience too.

ablarry91

You mean 9600 baud?  I'm still getting blank stares from my serial monitor.

Are you able to explain how the serial input works?  As I understand it with this particular code, I should be able to type out '\r' into my serial monitor and get a reading.  Would anyone agree to this being correct?

Carsten53T

#3
Jul 13, 2012, 09:46 am Last Edit: Jul 13, 2012, 09:56 am by Carsten53T Reason: 1

You mean 9600 baud?  I'm still getting blank stares from my serial monitor.


That was what I meant.

Quote

Are you able to explain how the serial input works?  

Not really, except that it uses two lines, tx for transmission and rx for recieving.
Quote

As I understand it with this particular code, I should be able to type out '\r' into my serial monitor and get a reading.  Would anyone agree to this being correct?

Yes, you can write in the upper inputField of the serial monitor and hit return to send.
I was about to send this code
Code: [Select]

void setup()
{
 Serial.begin(9600);
}

boolean test=true ;

void loop()
{
 if( Serial.available()>0)
 {
   int gg = Serial.read();

   if(test){
     Serial.println("writes ") ;
     test=false;
   }
   else{
     Serial.print("reads ") ;
     Serial.println(char(gg)) ;
     test=true;
   }
 }
}// end loop

as a quick test. Every second time you send a letter, it should return "reads "+ letter. Using the serial montor is no big deal, though the way people chooses to parse the recieved bytes differs.

If you go into your preferences you should be able to choose 'verbose' error-output ... maybe that can give you a hint of what's missing

Go Up