Want to keep a log of the climate in your greenhouse, build a humidor control system, or track temperature and humidity data for a weather station project? The AM2320 Temperature & Humidity Sensor may be the right choice for you!

AM2320 sensor is factory-calibrated and requires few external components to work. So with just a few connections and some Arduino code, you can start measuring relative humidity and temperature right away.

Hardware Overview

The AM2320 is a low-cost, easy to use, fairly accurate, digital temperature & humidity sensor, from AOSONG. It looks like the popular DHT11/DHT22 temperature and humidity sensors, but unlike classic DHT sensors, it has an I2C interface!

am2320 sensor

The AM2320 sensor is capable of reading humidity over the full range of 0 to 100% RH with a typical accuracy of ±3% over the range of 20% to 80% RH (0.024% RH resolution).

It has a maximum temperature range of -40 to 80°C and a typical accuracy of ±0.5°C at 25°C (0.01°C resolution).

The AM2320 can output data at a maximum sampling rate of 0.5Hz i.e. one reading every two seconds.

Power Requirement

The sensor itself uses 3.3V to 5.5V which makes it 3V or 5V compliant. So, you can use it with your favorite 3.3V or 5V microcontroller without worry.

The AM2320 consumes less than 0.95mA during measurements and less than 10µA during sleep mode. This low power consumption allow the implementation in battery driven devices such as handsets, wearables or smart watches.

I2C Interface

The AM2320 is a I2C sensor, meaning it uses the two I2C data/clock wires available on most microcontrollers, and can share those pins with other I2C sensors as long as they don’t have an address collision.

The sensor has a fixed I2C address and is set to 0x5CHEX. A multiplexer/Mux is required to communicate to multiple AM2320 sensors on a single bus.

Technical Specifications

Here are the complete specifications:

Supply Voltage3.3V to 5.5V
Current draw~0.95mA (during measurements)
~10µA (during sleep mode)
Humidity Range0 to 100 %RH
Humidity Accuracy±3% over the range of 20% to 80% RH
Temperature Range-40°C to +80°C
Temperature Accuracy±0.5°C at 25°C
Sampling Rate0.5Hz (one reading every two seconds)

For more details, please refer below datasheet.

AM2320 Sensor Pinout

Now let’s have a look at the pinout.

am2320 sensor pinout

VDD is the power pin. Since the sensor uses 3.3 to 5.5VDC, give it the same power as the logic level of your microcontroller – e.g. for a 5V micro like Arduino, use 5V.

SDA is the I2C data pin, requires a pullup of 2.2K – 10K to VDD.

GND is the common ground for power and logic.

SCL is the I2C clock pin, requires a pullup of 2.2K – 10K to VDD.

Wiring up a AM2320 to an Arduino

As it makes use of the I2C bus, connecting the AM2320 to an Arduino is pretty simple!

There are only four pins that need to be hooked up in order to start using the sensor. One for VCC, one for GND, and two data lines for I2C communication.

Connect the SCL pin to the I2C clock pin and the SDA pin to the I2C data pin on your Arduino. Note that each Arduino Board has different I2C pins which should be connected accordingly. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. They are also known as A5 (SCL) and A4 (SDA).

The AM2320 does not have internal pullup resistors for the I2C bus. So, you need to add them externally. Any value from 2.2K to 10K should work fine. The resistors go from VDD to SCL and SDA each.

The following illustration shows the wiring.

wiring am2320 sensor with arduino

Library Installation

To get your sensor up and running, you will need to install the Adafruit AM2320 library. It is available from the Arduino library manager.

To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries.

manage libraries

Filter your search by typing ‘am2320‘ and install the library.

adafruit am2320 sensor library installation

The Adafruit_AM2320 library uses the Adafruit Sensor support backend. So, search the library manager for Adafruit Unified Sensor and install that too (you may have to scroll a bit)

adafruit unified sensor library installation

You also need to install the Adafruit Bus IO helper library. It abstracts away I2C & SPI transactions and registers.

adafruit busio library installation

Arduino Code – Reading Temperature and Humidity

Below is a basic Arduino sketch. Go ahead and upload it to your Arduino. You will see the current temperature and humidity in your room!

#include "Adafruit_Sensor.h"
#include "Adafruit_AM2320.h"

Adafruit_AM2320 am2320 = Adafruit_AM2320();

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    delay(10); // hang out until serial port opens
  }

  am2320.begin();
}

void loop() {
  Serial.print("Temp: ");
  Serial.print(am2320.readTemperature());
  Serial.print(" C");
  Serial.print("\t\t");
  Serial.print("Humidity: ");
  Serial.print(am2320.readHumidity());
  Serial.println(" \%");

  delay(2000);
}

Once your code is uploaded, open the serial terminal at 9600bps. You should see something like the output below. Try breathing on the sensor to see both humidity and temperature values change!

am2320 sensor arduino output

Code Explanation:

This is probably about as simple as a sketch can get. At the beginning, Adafruit_Sensor.h and Adafruit_AM2320.h libraries are included and an Adafruit_AM2320 object is created in the global space.

#include "Adafruit_Sensor.h"
#include "Adafruit_AM2320.h"

Adafruit_AM2320 am2320 = Adafruit_AM2320();

In the setup, we initialize the serial communication with PC and call the begin() function to initialize the object.

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    delay(10); // hang out until serial port opens
  }

  am2320.begin();
}

Once the object is initialized, you can access object’s (am2320) methods using the dot operator.

am2320.readTemperature() returns floating point (decimal + fractional) temperature reading in °C. You can convert to Fahrenheit by multiplying by 1.8 and adding 32.

am2320.readHumidity() returns humidity reading, also as a floating point value between 0 and 100 (this reads % humidity).

void loop() {
  Serial.print("Temp: ");
  Serial.print(am2320.readTemperature());
  Serial.print(" C");
  Serial.print("\t\t");
  Serial.print("Humidity: ");
  Serial.print(am2320.readHumidity());
  Serial.println(" \%");

  delay(2000);
}

Login
ADS CODE