Skip to content

apexskier/AM2302

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Python module for the AM2302 temperature/humidity sensor on a Raspberry Pi.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published