Now I am trying to read 4bytes of data coming from the ATMega32.
1-sync,2-t,3-h,4-f
I inserted that while loop after every Serial1.read()
if(Serial1.available()>0)
{
sync=Serial1.read();
//delay(500);
if(sync==0xAA)
{
Serial.print("Sensor reading \n");
while(!Serial1.available())
digitalWrite(13,HIGH);
//if(Serial1.read()==B00011010) //Address 1=B00011010
//{
while(!Serial1.available());
temp=Serial1.read();
while(!Serial1.available());
hu=Serial1.read();
while(!Serial1.available());
fcs=Serial1.read();
digitalWrite(13,LOW);
if((temp+hu)==fcs)
{
Serial.print("Temperature 1 \t");
Serial.print(temp);
Serial.print("Humidity 1 \t\n");
Serial.print(hu);
}
else
Serial.print("Sensor1 Error\n");
//}
}
}
It is very slow(not main problem as the sensor updates the data once every second, but still the data received is lot slower and jitter is also high ) and the error rate is too high. Is there any programming improvement to reduce the errors and jitter(speed is secondary)