A better way to verify a value is an integer than string.toInt() …
/* * this function check that you can convert a value to an integer * * It is necessary, because the arduino string.toInt() * returns a 0 if the first character is not numeric, * and also a 0 if the first character is 0. therefore, * if you pass a string like 0B, arduino returns a 0. * * This function converts the string to a char buffer, * and checks the ascii value of each character in the string. * It will fail if any value is outside the * ascii range for the numbers 0-9. * */ boolean validInteger(String intString) { int len = intString.length() + 1; char buff[len]; intString.toCharArray(buff, len); for (int i = 0; i<len-1; i++) { if ((buff[i]<48) || (buff[i]>57)) { int buffInt = buff[i]; responseString = "FAIL Invport#"; return false; } } // end for i=0... return true; }