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 (pH Kit | Atlas Scientific) 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 ,
//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 ,
//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[/table]