Value send by trasmitting RF433Mhz module is received but unable to assign

unsigned char data[8];
unsigned int  sum,checksum;

void setup() 
{
 Serial.begin(1200);                            //Baud rate
}

void loop() 
{


  if(Serial.available())
  {
    
    data[0] = Serial.read();                  // Reading the data and printing it continuously (I've added this for checking if I'm receiving data or not)
    Serial.print(data[0]);
    Serial.print(" ");
  
    if(data[0] == 170)                            //Checking for start bit that is 0xAA 
    {
    
      for(int i = 1;i<6;i++)                      //After start bit Assigning the required data to Unsigned array and printing it
        {
          Serial.println("IN1234");
          data[i]=Serial.read();
          Serial.println(data[i]);
        }
     
      sum = data[1]+data[2]+data[3]+data[4];     //Adding data for checksum byte
      
      if(sum == data[5])                         //data[5] is checksum so checking if data is correct or not
      {  
        Serial.println(data[1]);                //My data part 1
        Serial.print(".");
        Serial.println(data[2]);
      
        Serial.print(data[3]);                  //My data part 2
        Serial.print(".");
        Serial.println(data[4]);
      }
      
      
      }
    
    }
    
   
  }

Wireless communication using RF433Mhz

Hey guys the following code runs perfectly just one trouble is that i am not able to assign the received data which is in the for loop.

Instead of the received data it assignes value 255 (As usigned char) if i change the data type to unsigned int then it assignes value 65535

I’m using 8051 at the transmiting end and arduino at receiving

Here is the output

0 0 0 0 0 170
IN1234
255
IN1234
255
IN1234
255
IN1234
255
IN1234
255
90 0 27 0 117 0 0 0 0 0 0 181 124 118 170
IN1234
255
IN1234
255
IN1234
255
IN1234
255
IN1234
255
90 0 27 0 117

At starting it is not receiving anything for that 0 then as soon as it receives start bit that is 170 it enters the loop and instead of assigning the next values to my data array it assigns 255 to that array.

After that it agains receives data which is my data which was to be assigned to that array

90 0 27 0 117

here 90,0,27,117

is my data first 4 are data and last is checksum byte

The main thing i am not able to understand is that it can assign data to data[0] but not to data[1],data[2],data[3],data[4],data[5]

Your description of behavior is unclear. Can you post the output you get?

DrAzzy: Your description of behavior is unclear. Can you post the output you get?

Sorry for that

Here is the output

0 0 0 0 0 170 IN1234 255 IN1234 255 IN1234 255 IN1234 255 IN1234 255 90 0 27 0 117 0 0 0 0 0 0 181 124 118 170 IN1234 255 IN1234 255 IN1234 255 IN1234 255 IN1234 255 90 0 27 0 117

At starting it is not receiving anything for that 0 then as soon as it receives start bit that is 170 it enters the loop and instead of assigning the next values to my data[] array it assigns 255 to that array.

After that it agains receives data which is my data which was to be assigned to that array

90 0 27 0 117

here 90,0,27,117

is my data first 4 are data and last is checksum byte

The main thing i am not able to understand is that it can assign data to data[0] but not to data[1],data[2],data[3],data[4],data[5]

Your posts still do not make sense. What has the radio got to do with it?

You check for serial.available() once, then attempt to read in a bunch of data.

That won’t work because the data aren’t necessarily available when you perform the read().

Guys the problem is solved i just needed to add delay between 2 assign operation

Thank You