AM2302-rpi

Drive an AM2302 temperature sensor with a raspberry pi.


Keywords
am2302, humidity-sensor, iot, raspberry-pi, sensor, temperature-sensor
License
Other
Install
pip install AM2302-rpi==1.1.2

Documentation

Python DHT-Raspberry Pi module

This module enables access to the AM2302 wired digital temperature and humidity sensor from a Raspberry Pi. It's been adapted from Adafruit's C code.

It may work with both the DHT11 and DHT22 sensors as well, though this is untested.

Get it with pip install am2302_rpi. The BCM2835 C Library is required and the root user must be used to access the GPIO pins.

am2302_ths

Both methods return floats, or None if the sensor can't be read. The sensor can only be read once every few seconds.

get_temperature(pin)

Reads the current temperature from a sensor attached to the specified pin.

get_humidity(pin)

Reads the current humidity from a sensor attached to the specified pin.

am2302_rpi

This module provides a class Sensor which periodically polls the sensor to keep track of the current temperature without waiting for it.

It has the following methods available.

init(pin)

Create a new sensor object instance with s = am2302_rpi.Sensor(4).

get()

Get the last read temperature.

get_last_time()

Get the time of the last successful read.

off()

Turn the timer off by cancelling it's internal ticker. Make sure you call this before exiting.

TODO

Clean up the sensor object properly.