Install Temp and Humid Sensor DHT22 OctoPrint

Make sure you are updated:

sudo apt upgrade

Install the required packages:

sudo apt install build-essential python3-dev python3-openssl git libgpiod2 python3-rpi.gpio

Install the library

git clone https://github.com/adafruit/Adafruit_Python_DHT.git && cd Adafruit_Python_DHT

Now create a Python library with:

sudo python3 setup.py install

Change the directory to the examples directory:

cd ~/Adafruit_Python_DHT/examples/

run the example with code:

sudo ./AdafruitDHT.py 22 4

if it does not work, python might not be in the path. Try this:

sudo python3 AdafruitDHT.py 22 4

The first parameter indicates which sensor was used (22 for the DHT22) and the second indicates which GPIO it is connected to. In this example, we've connected the DHT22 to GPIO 4:

Should look like this:

Temp=25.0*  Humidity=45.7%

Install Adafruit Library

pip3 install adafruit-circuitpython-dht

Install adafruit-blinka

sudo pip3 install adafruit-blinka

install the https://github.com/vitormhenrique/OctoPrint-Enclosure Plugin

go to octoptint settings → plugins → enclosure

selerc:

First Input:

Label = Dryer

select Temperature Sensor

Sensor Type = DHT22

Sensor Pin = 4 (Pi4 12)

Second Input:

Label = Box

select Temperature Sensor

Sensor Type = DHT22

Sensor Pin = 21 (Pi4 25)

Select Advanced options and un-check Use SUDO

REF:
https://www.thingiverse.com/thing:2245493
https://github.com/vitormhenrique/OctoPrint-Enclosure
https://roboticsbackend.com/raspberry-pi-3-pins/#:~:text=The%20Raspberry%20Pi%204%20board,computer%20%E2%80%93%20the%20Raspberry%20Pi%20microprocessor.
https://raspberrypi.stackexchange.com/questions/40105/access-gpio-pins-without-root-no-access-to-dev-mem-try-running-as-root