AM2302
Python module for the AM2302 temperature/humidity sensor on a Raspberry Pi.
Install / Use
/learn @apexskier/AM2302README
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.
Related Skills
node-connect
348.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
