AM2321 Temperature and Humidity Sensor Library

The AM2321 is a miniature Temperature and Humidity sensor manufactured by Aosong (GuangZhou) Electronics Co. Ltd.

Even though the manufacturer claims this sensor uses I2C to communicate with it’s host, however, if you read the manual carefully, this sensor has it own I2C communication requirements particularly in the timings, that the standard I2C functionality available on the Spark firmware will not be sufficient.

This library has implemented the required I2C timings and handling of device wake up based on the manufacturer supplied data and the example that comes with this library reads the device ID, temperature and humidity data from the AM2321 and dump them to the Serial line.

I couldn’t find any English version of the data sheet. Anyway, here is the Japanese version
and the Chinese (Simplified) version from Manufacturer or from Datasheet-pdf.com

You can found this library on the Web IDE, just search for AM2321. Or you can go to my git repo here.

Good luck and have fun!

2 Likes

Interesting - are there any advantages over the AM2302 sensor ?

@peekay123 and @mtnscott worked on a new library recently for that sensor.

@edwintam Do you know if this device works correctly when sharing the I2C bus with other ‘standard protocol’ I2C devices? Do they interfere with each other?

@Rockvole The advantage would be to share a common I2C bus with other sensors (assuming they can). From a quick review of the library, it appears to poll and wait for the device to respond.

@mtnscott The device itself could sit with other I2C devices on the bus nicely and won’t interfere with each other. I know that because it was sitting together on the same I2C bus with a OLED display. It’s just that it won’t work under the standard I2C protocol offered due to the peculiar timings and ack sequences.

@Rockvole The only advantage I saw was the I2C in AM2321 instead of a custom 1-wire as in the AM2302. However, this advantage is completely gone when they employed a few twists on the I2C protocol that the Spark Core could not offer - almost everything I2C they put in the manual has a but attached.

I’m trying to use the AM2320 and don’t see any differences on the datasheets for both (except a lower voltage of operation)

I only receive ID:65535, Temp: 6553.50, Humi: 6553.50… Stumped trying to find a library for use with the AM2320

How have you got the sensor connected?
Have you got the I2C pull-upsin place?