Equipment:
pH Probe
Atlas-Scientific pH Stamp
Working? Yes.
Issue:
When I stream my pH and temperature data to Pachube. The temperature works fine, but the pH ends up repeating itself.
I think the issue is because it is a string when it sends the data.
pH/Sensor Code:
-Code just for pH sensor
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
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
}
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
}
-Code to send data to Pachube
lastConnected = client.connected();
String dataString = "External_Temperature,";
dataString += TemperatureF;
// you can append multiple readings to this String if your
// pachube feed is set up to handle multiple values:
dataString += "\nInternal_Temperature,";
dataString += thermocouple;
dataString += "\npH,";
dataString += sensorstring;
I feel that if I had a way to turn the string into a integer it would work fine.
I tried:
String sensorstring;
int pHsensor = sensorstring.toInt();
Just got a 0 for pH, and temperatures still worked (switched the variable in the code for pachube to pHsensor).
pHsensor = atoi(sensorstring);
Compiling error: CompleteWebServer:106: error: cannot convert 'String' to 'const char*' for argument '1' to 'int atoi(const char*)'
All help I appreciate.
-Miles