Public Member Functions | Public Attributes | Private Member Functions | List of all members
DHT22.sensor Class Reference

Public Member Functions

def __init__ (self, pi, gpio, LED=None, power=None)
 
def bad_checksum (self)
 
def cancel (self)
 
def humidity (self)
 
def missing_message (self)
 
def sensor_resets (self)
 
def short_message (self)
 
def staleness (self)
 
def temperature (self)
 
def trigger (self)
 

Public Attributes

 bad_CS
 
 bad_MM
 
 bad_SM
 
 bad_SR
 
 bit
 
 cb
 
 CS
 
 gpio
 
 hH
 
 high_tick
 
 hL
 
 LED
 
 MAX_NO_RESPONSE
 
 no_response
 
 pi
 
 power
 
 powered
 
 rhum
 
 temp
 
 tH
 
 tL
 
 tov
 

Private Member Functions

def _cb (self, gpio, level, tick)
 

Detailed Description

A class to read relative humidity and temperature from the
DHT22 sensor.  The sensor is also known as the AM2302.

The sensor can be powered from the Pi 3V3 or the Pi 5V rail.

Powering from the 3V3 rail is simpler and safer.  You may need
to power from 5V if the sensor is connected via a long cable.

For 3V3 operation connect pin 1 to 3V3 and pin 4 to ground.

Connect pin 2 to a gpio.

For 5V operation connect pin 1 to 5V and pin 4 to ground.

The following pin 2 connection works for me.  Use at YOUR OWN RISK.

5V--5K_resistor--+--10K_resistor--Ground
                 |
DHT22 pin 2 -----+
                 |
gpio ------------+

Definition at line 10 of file DHT22.py.

Constructor & Destructor Documentation

def DHT22.sensor.__init__ (   self,
  pi,
  gpio,
  LED = None,
  power = None 
)
Instantiate with the Pi and gpio to which the DHT22 output
pin is connected.

Optionally a LED may be specified.  This will be blinked for
each successful reading.

Optionally a gpio used to power the sensor may be specified.
This gpio will be set high to power the sensor.  If the sensor
locks it will be power cycled to restart the readings.

Taking readings more often than about once every two seconds will
eventually cause the DHT22 to hang.  A 3 second interval seems OK.

Definition at line 35 of file DHT22.py.

Member Function Documentation

def DHT22.sensor._cb (   self,
  gpio,
  level,
  tick 
)
private
Accumulate the 40 data bits.  Format into 5 bytes, humidity high,
humidity low, temperature high, temperature low, checksum.

Definition at line 89 of file DHT22.py.

def DHT22.sensor.bad_checksum (   self)
Return count of messages received with bad checksums.

Definition at line 208 of file DHT22.py.

def DHT22.sensor.cancel (   self)
Cancel the DHT22 sensor.

Definition at line 235 of file DHT22.py.

def DHT22.sensor.humidity (   self)
Return current relative humidity.

Definition at line 197 of file DHT22.py.

def DHT22.sensor.missing_message (   self)
Return count of missing messages.

Definition at line 216 of file DHT22.py.

def DHT22.sensor.sensor_resets (   self)
Return count of power cycles because of sensor hangs.

Definition at line 220 of file DHT22.py.

def DHT22.sensor.short_message (   self)
Return count of short messages.

Definition at line 212 of file DHT22.py.

def DHT22.sensor.staleness (   self)
Return time since measurement made.

Definition at line 201 of file DHT22.py.

def DHT22.sensor.temperature (   self)
Return current temperature.

Definition at line 193 of file DHT22.py.

def DHT22.sensor.trigger (   self)
Trigger a new relative humidity and temperature reading.

Definition at line 224 of file DHT22.py.

Member Data Documentation

DHT22.sensor.bad_CS

Definition at line 66 of file DHT22.py.

DHT22.sensor.bad_MM

Definition at line 68 of file DHT22.py.

DHT22.sensor.bad_SM

Definition at line 67 of file DHT22.py.

DHT22.sensor.bad_SR

Definition at line 69 of file DHT22.py.

DHT22.sensor.bit

Definition at line 81 of file DHT22.py.

DHT22.sensor.cb

Definition at line 62 of file DHT22.py.

DHT22.sensor.CS

Definition at line 103 of file DHT22.py.

DHT22.sensor.gpio

Definition at line 52 of file DHT22.py.

DHT22.sensor.hH

Definition at line 154 of file DHT22.py.

DHT22.sensor.high_tick

Definition at line 80 of file DHT22.py.

DHT22.sensor.hL

Definition at line 151 of file DHT22.py.

DHT22.sensor.LED

Definition at line 53 of file DHT22.py.

DHT22.sensor.MAX_NO_RESPONSE

Definition at line 73 of file DHT22.py.

DHT22.sensor.no_response

Definition at line 72 of file DHT22.py.

DHT22.sensor.pi

Definition at line 51 of file DHT22.py.

DHT22.sensor.power

Definition at line 54 of file DHT22.py.

DHT22.sensor.powered

Definition at line 60 of file DHT22.py.

DHT22.sensor.rhum

Definition at line 75 of file DHT22.py.

DHT22.sensor.temp

Definition at line 76 of file DHT22.py.

DHT22.sensor.tH

Definition at line 129 of file DHT22.py.

DHT22.sensor.tL

Definition at line 145 of file DHT22.py.

DHT22.sensor.tov

Definition at line 78 of file DHT22.py.


The documentation for this class was generated from the following file:


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:58