# AVR Error Handling: I2C, SPI etc

How would one go about handling errors in AVR interfaces that do not specifically provide any acknowledgement scheme?

For example, I have an I2C temperature sensor which I poll every 1 hour. So every hour my AVR sends a TWI start condition to the sensor and gets the temperature at the end of it.Now tet's say for some reason the sensor does not respond. Maybe it's been taken out, burned out etc. So how can I check for such in my code and inform the user?

Right now I am using the polling method. Infinite loop till TWINT is set in the TWCR register

while ((TWCR & (1<<TWINT)) == 0){};
return TWDR;

• well the I2C standard considers an acknowledge mechanism, check your AVR datasheet and see what the peripheral does about that. Aug 9 '14 at 14:09