Tuesday, July 26, 2016

AM2320 library for AVR's without hardware TWI support

Hi! Some time ago I've bought several AM2320 sensors. They have I2C interface, so it is very easy to use them with AVR's that have h\w TWI support. But what about low-end MCU's without full TWI implementation (Tiny2313, Tiny24, etc.)?
First I tried to use USI module for TWI implementation. As for me resulting code was too "fat" for 2Kb FLASH and there was no need for full TWI feature support (the only TWI device in my project was AM2320).

After some time spent on datasheet reading and hardware testing I've wrote a C library for these sensors. Please note that AM2320_ReadData function writes raw data to variables. This notice is actual for negative temperature values, where 0x8000 bit is set.

AM2320 Datasheet