Troubleshooting OSError with DHT22 Sensor in ESP32 MicroPython Real-Time Control System

Hi guys @Middleware & OS , am developing a real-time control system using an ESP32, MicroPython, and an ML model to predict temperature based on sensor(DHT22) readings, and integrate it with a relay to control a heating element. I have setup flash MicroPython firmware on the ESP32, connected the DHT22 sensor to the ESP32 (data pin to GPIO 4), connected the relay module to control the heating element (relay input to GPIO 5).

But am getting the error
Failed to read sensor: OSError

This is my code
file0.jpg
Solution
Since esp32 comes in different pin layout you can try debugging by adding a led to the pin 5 and try to blink it
Was this page helpful?