We are using 2 analog pins of X-bee for reading the sensor. This data is being transmitted from end device xbee to coordinator xbee.
A 24 byte packet data is being transmitted. We require 4 data bytes numbered 20,21,22,23. This is the code we have used in order to accomplish this.
The problem we are facing is that we receive the first two bytes correctly i.e 20,21 but the next two bytes are not read correctly.
Please suggest changes in the code for it to work correctly.
float temp1; float temp2;
if(Serial.available() >= 21)
int msb1 = Serial.read();
int lsb1 = Serial.read();
int msb2 = Serial.read();
int lsb2 = Serial.read();
int analog1= lsb1+(msb1256);
temp1 = analog1/ 1023.0 * 1.23;
int analog2= lsb2+(msb2256);
temp2 = analog2/ 1023.0 * 1.23;