Welcome to MicroPython AM2320 Library’s documentation!

Contents:

am2320 module

AM2320

class am2320.AM2320(i2c[, address])

The basic class for handling the communication with the sensor.

The i2c parameter is an initialized I²C bus, and the optional address specifies which sensor to connect to, if you have more than one and have changed their addresses with the Addr pin.

temperature()

Get the temperature in Celcius

humidity()

Get the relative humidity as a percentage

Usage Examples

Connect your sensor in following way:

  • vin3V
  • sdagpio4
  • gndgnd
  • sclgpio5

Now, to make basic measurement:

import am2320
from machine import I2C, Pin
i2c = I2C(scl=Pin(5), sda=Pin(4))
sensor = am2320.AM2320(i2c)
sensor.measure()
print(sensor.temperature())
print(sensor.humidity())

To perform continuous measurement:

import time
while True:
    sensor.measure()
    print(sensor.temperature())
    print(sensor.humidity())
    time.sleep_ms(4000)

Indices and tables