I’m using the ESP8266_ReadPin example and it works well. The serial monitor shows my data formatted ["75"]. However I’d like to get the data without the brackets and quotes, so just 75 (end goal being to use this data as an integer (or other) variable).
I know this is not a Blynk thing, but probably C (?) or just basic HTTP stuff. Can anyone share an example if they’ve successfully done this or point me in the right direction?
Maybe use isdigit() in the while (client.available()) loop, if true an integer will be the value -‘0’ and you will probably need to count through the loop to see how many digits are in the integer and multiply the left most digit by 10 for 2 digits, 100 for 3 digits.
Serial.print("Read value: ");
body.remove(0,2); // Starting at index 0, remove 2 characters.
body.remove(body.length() - 2); // Starting at 2 characters from the end of the string, remove everything after.
int tempF = body.toInt(); // Convert string to int.
Serial.println(body);
Serial.println(tempF + 1); // Confirm toInt() really worked!
I have a feeling this is a tad less graceful than Costa’s idea… but I’m going to try that next!