Right Ok, so I have got rid of the pH problem I was having here is how I solved it:
if (sensorPH_stringcomplete) //if a string from the Atlas Scientific product has been received in its entirety
{
char buf[sensorstringPH.length()];
sensorstringPH.toCharArray(buf, sensorstringPH.length());
float pH_reading = atof(buf);
float check = pH_reading*10;
Serial.println(check);
As for EC problem I have found out that I can split the string using:
#include <string.h>
char EC_reading;
String Filename = "50000,3720,42.5";
void setup()
{
Serial.begin(9600);
char buf[Filename.length()];
Filename.toCharArray(buf,Filename.length());
char *p = buf;
char *str;
while ((str = strtok_r(p, ",", &p)) != NULL) // delimiter is the comma
Serial.println(str);
}
void loop(){}
however two problems:
- Why does this miss out the last number from Filename (ie the 5)? Not a big issue as I only want to use the first value but still dont understand why it does this. If I put a delimiter at the end of my string it will pick up everything
- What does str become? Is it a character array? Im having difficulty extracting just the '5000' before I then will convert it to a float for use elsewhere in my code