i have been trying to come up whit working I2C code for my atmega328 to read a temperature register on a MCP9804 temp sensor. I tried I2C library from Peter Fleury(tried TWITEST and I2CMASTER), but i could not make sense of it or get it to work. So i decided to go whit official at328p datasheet in which there is good explnanation of protocol and code and il ltry to bang together a working code, but i failed miserably couple of times. I read all the literature about TWCR. TWINT, TWDR, slave adresiing, read/write bits,.... but for the love of god, i cannot seem to be able to put it all togehter so it would work. So if some1 has a sample of code that knows it works on AVR for reading register on a I2C slave, please if you can share. Or any guide or tutorial site that i missed, please share.