RF links receiving wrong numbers!

Im trying to send the temperature from one Arduino to an other. Im using LM35DT sensor and got it working when viewing the calculations in the transmitter Serial Monitor. The results are about 240-250. This means the temperature is about 24,0-25,0 celcius. The problem happens when trying to transmit these numbers to the receiving Arduino. Instead of receiving numbers between 240 and 250 I'm receiving numbers like these:

2
2
66
2
98
98
2
2
97
2
2
99
2
2
66

Im using RF links and the VirtualWire library.

Transmitter code:

#include <VirtualWire.h>

int potPin = 0;
int temperature = 0;

int ledPin = 10;

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

  analogReference(INTERNAL);

  pinMode(ledPin, OUTPUT);

  //VitualWire Setup
  vw_setup(2000);
  vw_set_tx_pin(2);
}

void loop() {
  int span = 20;
  int aRead = 0;
  //Getting a more reliable temperature reading
  for (int i = 0; i < span; i++) {
    aRead = aRead+analogRead(potPin);
  }
  aRead = aRead / 20;
   // convert voltage to temperature
  temperature = ((100*1.1*aRead)/1024)*10; 
  //Printing to Serial buffer
  Serial.println(temperature);
  //Transmitting the temperature
   int msg = temperature;

   vw_send((uint8_t *) msg, 3);
   digitalWrite(ledPin, HIGH);
   vw_wait_tx();
   digitalWrite(ledPin, LOW);

   delay(500);
}

Receiver code:

 #include <VirtualWire.h>

 void setup(){
   vw_set_rx_pin(8);
   vw_setup(2000);
   vw_rx_start();

   Serial.begin(9600);
 }

 void loop() {

   uint8_t buflen = VW_MAX_MESSAGE_LEN;
   uint8_t buf[buflen];

   if (vw_get_message(buf, &buflen))
   {
     for(int i = 0; i < buflen;i++)
     {
       Serial.println(buf[i]);
     }
   }
 }
   int msg = temperature;

How is this useful? temperature is an int.

   vw_send((uint8_t *) msg, 3);

WTF? How many bytes in an int?

   if (vw_get_message(buf, &buflen))
   {
     for(int i = 0; i < buflen;i++)
     {
       Serial.println(buf[i]);
     }
   }

You broke the int into a series of bytes, and sent them. Then, you print the bytes and expect to see something you recognize? Well, good luck with that.

You need to either rejoin the 3 bytes you sent as an int (good luck with that) or send the value as a string and convert the string back to an int.

A quick look by another newbie and I would suggest that your are sending numerical values via the link and these are being displayed as ASCII .

EG, a temperature of 20 would need to be converted to two ASCII values, "2" and "0" then sent via the link. Or this conversion can be done with the received value to convert 20 value to ASCII "20".

Pseudo code only

TemperatureValue = 25

First digit = temperatureValue/10.                //value is 2
Second digit = temperature%10.                    //value is 5

//Display first and second digit.

First ASCII  = first digit + 48.                            //ASCII value displayed  50 or "2"
Second ASCII  = second digit + 48.                  //ASCII value displayed 53 or "5"

Weedpharma