Xbee sending/recieving incorrect data

I am performing a simple program of sending a pot value from one arduino to another arduino using xbee. I am reading the values from the Sender arduino and the Reciever arduino but the values are different. Can you help me find my mistake. Here’s my code-

int potPin = 2;

void setup()
{
  pinMode(potPin, INPUT);
  //Create Serial Object (9600 Baud)
  Serial.begin(9600);
}

void loop()
{
  int val = analogRead(potPin);
  Serial.println(val);
  delay(500);
  
}

Receiver-

void setup() {
  Serial.begin(9600);

}

void loop() {
  while( Serial.available() == 0);
  int data = Serial.read() -'0';
  Serial.println(data);
  delay(500);
}

You are sending something like “450”.
You are reading ‘4’, and converting that to 4.
You are reading ‘5’, and converting that to 5.
You are reading ‘0’, and converting that to 0.
You are reading and converting that to who know what.
You are reading and converting that to sho knows what.

That is NOT how to read “450” and make 450 out of it.

You need to read and store all the data, with no “wait for data” loop, as it arrives. When the incoming value is \n or \r, and the number of stored characters is not 0, convert the NULL terminated array of characters, that you saved data in, to an int using atoi().

Srry for that. Thats how someone on youtube told me to do.. Anyways I am gonna send the data in a different manner now.. Thanks Paul!