I am working with the Atlas Scientific PH,ORP, and EC Stamps. I am having a problem with the EC stamp. I am using Arduino 1.0.4 IDE. I am working with an Arduino Mega.
I wrote a class library to process data from each stamp. I used character arrays instead of the String class from their example code. I noticed my code was crashing/reseting the Arduino. After looking deeper I discovered the problem was only related to the EC stamp. After digging deeper into my code and I could not find the root cause of the problem. The PH and ORP stamps seem to work fine running for hours without any issues.
My next step was to load sample code provided by Atlas to see if I had the same problem. I loaded sample code provided and added a Serial.print command in setup. I noticed this program is crashing as well.
The problem seems to happen with reading from the Stamp either using the C and R commands, Sometimes I am seeing non-printable ASCII characters being returned as well.
VCC across both GND points on the stamp is 4.85V.
I have tried the following:
Factory Reset
IDE 1.0.2 same results
Use Serial1,Serial2,Serial3 for stamp same results.
Swap BNC connectors, same results.
Remove Probe, Readings 0,0,0 but Same results.
Different Mega, Same results.
Use Putty and IDE Serial Monitor, Same Results.
Here is the code I am using. It's right off their site (https://www.atlas-scientific.com/_files/code/Arduino-sample-code-EZ-COM-MEGA.pdf)
String inputstring = ""; //a string to hold incoming data from the PC
String sensorstring = ""; //a string to hold the data from the Atlas Scientific product
boolean input_stringcomplete = false; //have we received all the data from the PC
boolean sensor_stringcomplete = false; //have we received all the data from the Atlas Scientific product
void setup(){ //set up the hardware
Serial.begin(38400); //set baud rate for the hardware serial port_0 to 38400
Serial3.begin(38400); //set baud rate for software serial port_3 to 38400
inputstring.reserve(20); //set aside some bytes for receiving data from the PC
sensorstring.reserve(30); //set aside some bytes for receiving data from Atlas Scientific product
Serial.println("Start");
}
void serialEvent() { //if the hardware serial port_0 receives a char
char inchar = (char)Serial.read(); //get the char we just received
inputstring += inchar; //add it to the inputString
if(inchar == '\r') {input_stringcomplete = true;} //if the incoming character is a <CR>, set the flag
}
void serialEvent3(){ //if the hardware serial port_3 receives a char
char inchar = (char)Serial3.read(); //get the char we just received
sensorstring += inchar; //add it to the inputString
if(inchar == '\r') {sensor_stringcomplete = true;} //if the incoming character is a <CR>, set the flag
}
void loop(){ //here we go....
if (input_stringcomplete){ //if a string from the PC has been recived in its entierty
Serial3.print(inputstring); //send that string to the Atlas Scientific product
inputstring = ""; //clear the string:
input_stringcomplete = false; //reset the flage used to tell if we have recived a completed string from the PC
}
if (sensor_stringcomplete){ //if a string from the Atlas Scientific product has been recived in its entierty
Serial.println(sensorstring); //send that string to to the PC's serial monitor
sensorstring = ""; //clear the string:
sensor_stringcomplete = false; //reset the flage used to tell if we have recived a completed string from the Atlas Scientific product
}
}
Here is the output showing the problem:
Start <- Normal Start of Program
E,V3.0,4/12 <-- I command send from Serial Monitor
2178,1176,0 <-C command sent from Serial Monitor (returns readings every 1000ms)
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
2156,1164,0
2156,1164,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
Start <---- Crash
2178,1176,0
2111,1140,0
2200,1188,0
2178,1176,0
2178,1176,0
Start <--- Crash
2178,1176,0
2156,1164,0
Any help or suggestions would be greatly appreciated.
Thanks,
John