Converting a message received in char buffer to integer
atoi() is the simplest way:

int val = atoi(buf);


If that doesn't work then your buffer doesn't start with the number you are after. If that is the case you will have to work out where in the buffer the number is and convert just that portion. How you do that depends on what the format of the data is in your buffer.