DHT22 and MCP2221 with C-python
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DHT22 and MCP2221 with C-python

by scotch1 on Sun Jan 10, 2021 10:00 pm

Following this tutorial: https://github.com/adafruit/Adafruit_CircuitPython_DHT

from here: https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/python-setup

installed via pip: [img]

Thought it was G0 vs G1 issues, then also tried to plug into the RX, same issue (even when removing the G0 import)

Error Message:
Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "A_DHT22_temp_1.py", line 3, in <module>
    import adafruit_dht
  File "C:\ProgramData\Anaconda3\lib\site-packages\adafruit_dht.py", line 33, in <module>
    from os import uname
ImportError: cannot import name 'uname' from 'os' (C:\ProgramData\Anaconda3\lib\os.py)

tried to import os, and same error? Any Idea why it won't run?

Code: Select all | TOGGLE FULL SIZE
import os

import time
import board
import adafruit_dht
from board import G1

DHT_TYPE = adafruit_dht.DHT22

# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT22(board.G1)

# you can pass DHT22 use_pulseio=False if you wouldn't like to use pulseio.
# This may be necessary on a Linux single board computer like the Raspberry Pi,
# but it will not work in CircuitPython.
# dhtDevice = adafruit_dht.DHT22(board.D18, use_pulseio=False)

while True:
        # Print the values to the serial port
        temperature_c = dhtDevice.temperature
        temperature_f = temperature_c * (9 / 5) + 32
        humidity = dhtDevice.humidity
            "Temp: {:.1f} F / {:.1f} C    Humidity: {}% ".format(
                temperature_f, temperature_c, humidity

    except RuntimeError as error:
        # Errors happen fairly often, DHT's are hard to read, just keep going
    except Exception as error:
        raise error

Adafruit_list_sht22.JPG (91.02 KiB) Viewed 35 times

Posts: 144
Joined: Mon Nov 26, 2012 12:13 am

Please be positive and constructive with your questions and comments.