In the comment of an existing answer that says a resistor is required, a person said that Pi's pins have in-built resistors ( https://raspberrypi.stackexchange.com/a/12162/121818 ), but it was just a comment and did not give the full source code.
I combined the comment code and the code from this article. Is this the correct code for using a DHT22 without a resistor? It does print values, but I am not sure those are correct values. The temperature seem quite high.
DHT22's pin1 is connected to Pi's pin1, pin2 to pin7, pin4 to pin6.
import Adafruit_DHT import RPi.GPIO as GPIO sensor = Adafruit_DHT.DHT22 gpioNumber = 4 pinNumber = 7 GPIO.setmode(GPIO.BOARD) GPIO.setup(pinNumber, GPIO.IN, pull_up_down = GPIO.PUD_UP) hum, tem = Adafruit_DHT.read_retry(sensor, gpioNumber) print("humidity = " + str(hum) + ", temperature = " + str(tem))