I'm using two ESp32 in a server and client configuration and i'm sending data between them in form of strings but i want to convert the recieved data which is fom of strings but it contains numbers into int on which i can workon to calculate the required things for my project. Can anyobne help me on how to convert string to integer?
The question was answered many times before, but you can convert an String to Integer either by converting it to an
char array and using the
char strVal; str.toCharArray(strVal, 10); int val = atoi(strVal);
or simply using the
int val = str.toInt();
Source: Arduino Forum
Try to use the second solution as the
atoi() function returns
0 on error, which can be misleading.