I connect ESP8266 with ATmega8 using UART. I send some value from ESP8266 to ATmega8 on that basis of the value ATmega8 send back some value to the ESP8266 and this is working fine but after few hours ATmega8 does to send data after resetting ATmega8 its working fine but then again a few hours later its stop send data.
//ESP8266 CODE
Serial.write(post_data);
delay(2000);
String port_status = "";
if (Serial.available()) {
incomingByte = Serial.read();
delay(2000);
if(incomingByte == 70) {
pin_status = '0';
}
if(incomingByte == 79) {
pin_status = '1';
}
}
//ATMEGA8 CODE
int main() {
unsigned char reccive;
unsigned char ch;
while(1) {
while(! (UCSRA & (1<<RXC)));
{
reccive = UDR;
ch = ' ';
if(reccive == 'A') {
reccive = ' ';
_delay_ms(500);
ch = 'O';
while(! (UCSRA & (1<<TXC)));
{
UDR = 'O';
_delay_ms(500);
}
}
else {
ch = 'F';
while(! (UCSRA & (1<<TXC)));
{
UDR = 'F';
_delay_ms(500);
}
}
}
}
}