Go to the documentation of this file.
4 from __future__
import absolute_import, division, print_function, unicode_literals
12 The DHT11 class is a stripped version of the DHT22 sensor code by joan2937.
13 You can find the initial implementation here:
14 - https://github.com/srounet/pigpio/tree/master/EXAMPLES/Python/DHT22_AM2302_SENSOR
18 >>> sensor = DHT11(pi, 4) # 4 is the data GPIO pin connected to your sensor
19 >>> for response in sensor:
20 .... print("Temperature: {}".format(response['temperature']))
21 .... print("Humidity: {}".format(response['humidity']))
26 pi (pigpio): an instance of pigpio
27 gpio (int): gpio pin number
40 Clears the internal gpio pull-up/down resistor.
49 Monitors RISING_EDGE changes using callback.
59 Either Edge callbacks, called each time the gpio edge changes.
60 Accumulate the 40 data bits from the dht11 sensor.
67 handler = level_handlers[level]
90 if not (total & 255) == self.
checksum:
92 elif 16 <= self.
bit < 24:
94 elif 0 <= self.
bit < 8:
114 Handle Either signal.
120 Start reading over DHT11 sensor.
122 self.
pi.write(self.
gpio, pigpio.LOW)
130 Stop reading sensor, remove callbacks.
139 Support the iterator protocol.
145 Call the read method and return temperature and humidity informations.
155 if __name__ ==
'__main__':
159 print(
"temperature: {}".format(d[
'temperature']))
160 print(
"humidity: {}".format(d[
'humidity']))
def __init__(self, pi, gpio)
def either_edge_callback(self, gpio, level, tick)
def _edge_FALL(self, tick, diff)
int set_mode(unsigned gpio, unsigned mode)
def _edge_RISE(self, tick, diff)
void callback(uint32_t hash)
def _edge_EITHER(self, tick, diff)
int set_watchdog(unsigned user_gpio, unsigned timeout)
def register_callbacks(self)
int set_pull_up_down(unsigned gpio, unsigned pud)
cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Fri Aug 2 2024 09:40:56