guys please can you help the noob
i have connected 6 x DHT22 Temperature and Humidity Sensors on my Raspberry PI 4
I am getting a reading from the first DHT22 Sensor on GPIO 22 [ The Other DHT22 Sensors are Connected to GPIO 2, 3, 4, 17, 27 ]
I want to test the Other 5 x DHT22 Sensors
I am Using the Following code to test One DHT22 Sensor
I need to change the Same Code to Test All 6 x DHT22 Sensors
What do i need to do in the code to Test All 6 x DHT22 Sensors with One Python File?
CODE I am Using:
i have connected 6 x DHT22 Temperature and Humidity Sensors on my Raspberry PI 4
I am getting a reading from the first DHT22 Sensor on GPIO 22 [ The Other DHT22 Sensors are Connected to GPIO 2, 3, 4, 17, 27 ]
I want to test the Other 5 x DHT22 Sensors
I am Using the Following code to test One DHT22 Sensor
I need to change the Same Code to Test All 6 x DHT22 Sensors
What do i need to do in the code to Test All 6 x DHT22 Sensors with One Python File?
CODE I am Using:
import adafruit_dht import time class DHT22Module: def __init__(self, pin): self.dht_device = adafruit_dht.DHT22(pin) def get_sensor_readings(self): while True: try: # Print the values to the serial port temperature_c = self.dht_device.temperature temperature_f = temperature_c * (9 / 5) + 32 humidity = self.dht_device.humidity print( "Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format( temperature_f, temperature_c, humidity ) ) return temperature_c, humidity except RuntimeError as error: # Errors happen fairly often, DHT's are hard to read print(error.args[0]) time.sleep(2.0) continue except Exception as error: self.dht_device.exit() raise error
buran write May-11-2023, 10:45 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.