Interfacing DHT22 Temperature & Humidity Sensor with Custom PCB
This week focuses on understanding and interfacing input devices with a custom-designed microcontroller board. The objective was to probe both analog and digital signals and measure a real-world physical property using a sensor connected to my previously fabricated PCB.
For the individual assignment, I measured environmental temperature and humidity using a DHT22 sensor connected to my custom board based on the Seeed Studio XIAO RP2040 microcontroller.
As part of the group assignment, we analyzed and probed input device signals using measurement instruments such as oscilloscopes and multimeters. We observed analog voltage levels and digital transitions to understand signal timing and logic behavior.
Detailed documentation of the group work is available here:
Instead of designing a new PCB this week, I reused my previously fabricated custom embedded board. This board includes:
Reusing the board demonstrates modular design and expandability in embedded systems.
The DHT22 is a digital temperature and humidity sensor. It internally measures:
Although these are analog physical properties, the sensor converts them internally into digital data and transmits the result via a single-wire protocol.
The sensor connections were:
#include "DHT.h"
#define DHTPIN D1
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Sensor read failed");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print("% Temperature: ");
Serial.print(t);
Serial.println("°C");
}
The code initializes the DHT sensor and reads humidity and temperature values every two seconds. Error checking ensures invalid readings are detected.
The readings show stable humidity and temperature values, confirming successful interfacing and reliable digital communication.
After correcting these issues, stable sensor readings were achieved.
This assignment strengthened my understanding of digital sensor communication, signal abstraction, and embedded debugging techniques. It reinforced the importance of modular PCB design and careful wiring practices.
The following video demonstrates the complete working setup of the DHT22 sensor interfaced with my custom PCB. The Serial Monitor output shows real-time temperature and humidity readings.
| Assignment Task | Status |
|---|---|
| Linked to group assignment page | Completed |
| Probed input device signals (Group Assignment) | Completed |
| Interfaced DHT22 sensor with custom PCB | Completed |
| Measured environmental temperature and humidity | Completed |
| Explained code functionality | Completed |
| Documented design & fabrication process | Completed |
| Documented problems encountered & solutions | Completed |
| Included hero shot of final board | Completed |