Loading
Read temperature and humidity with a DHT22 and show them on a 0.96" OLED, all on an ESP32.
Guide
8 parts · about ₹1,652
What you need
Step 1 of 5
https://espressif.github.io/arduino-esp32/package_esp32_index.json.Milestone
IDE ready
An empty sketch compiles for ESP32 Dev Module.
Step 2 of 5
Milestone
Wired
Step 3 of 5
| 1 | #include <Wire.h> |
| 2 | #include <Adafruit_GFX.h> |
| 3 | #include <Adafruit_SSD1306.h> |
| 4 | #include <DHT.h> |
| 5 | |
| 6 | #define DHT_PIN 4 |
| 7 | DHT dht(DHT_PIN, DHT22); |
| 8 | Adafruit_SSD1306 oled(128, 64, &Wire, -1); |
| 9 | |
| 10 | void setup() { |
| 11 | Serial.begin(115200); |
| 12 | dht.begin(); |
| 13 | if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { |
| 14 | Serial.println("OLED not found at 0x3C: check SDA/SCL"); |
| 15 | while (true) delay(1000); |
| 16 | } |
| 17 | oled.setTextColor(SSD1306_WHITE); |
| 18 | } |
Milestone
Readings on the screen
Breathe on the sensor: humidity should jump within a few seconds.
Step 4 of 5
Step 5 of 5
0x3D; try that, and check SDA/SCL are not swapped.Labs
All labs