This is a pretty sneaky problem, I'm sure there is a libc way to do it but I usually just
uint32_t get_number(char size) {
uint32_t output_number = 0;
for (char i=0; i<size; i++) {
// get some characters, convert ascii into the actual number, add it in
// note that '0' is 48, the ascii code for the zero character
output_number += Serial.read() - '0';
output_number *= 10; // shift everything up by one digit
}
}
This assumes that you send digits in the most significant to least significant order ie if you want to send 1234 you would send '1', '2', '3', '4'. So to get an 8 digit number you would just go
uint32_t num = get_number(8);
But using a 32 bit integer on an 8 bit micro is really inefficient, you should just store it in an array and process it from there.
#define NUM_SIZE 8
char buffer[NUM_SIZE];
for (i=0; i<NUM_SIZE; i++) buffer[i] = Serial.read() - '0';
Good luck!