This is a small library to get started with the AM2320 temperature and humidity sensor via i2C. It has a few functions available to get temperature in both celcius and farenheit along with the humidity in percent. See below for the pinout connections to get in hooked up to your device. I developed this on a Raspberry Pi using python3, so unsure if wit will work on other devices.
- smbus2
pip3 install smbus2
#!/usr/bin/env python3
from AM2320 import AM2320
if __name__ == '__main__':
am2320 = AM2320(1)
print("Temperature: {}°C".format(am2320.getTempC()))
print("Temperature: {}°F".format(am2320.getTempF()))
print("Humidity: {}%".format(am2320.getHumidity()))
Returns the temperature of from the device in celcius.
Returns the temperature from the device in farenheit. This isn't directly from the sensor but a calculation made on the getTempC function.
Returns the humidity in percentage.
Useful function if you want to wake up the sensor as it falls asleep sometimes.