Environmental Sensing (DHT11/DHT22)

Custom hardware integration, data logging, and performance comparison of environmental sensors.

Soldered Perf Board and Case

Hardware & Enclosure Design

To transition this project from a messy breadboard prototype to a robust, permanent device, I undertook a complete hardware integration process. This involved carefully soldering the microcontroller and sensor components onto a perf board to ensure solid, reliable electrical connections. To protect the electronics and give it a professional finish, I used SolidWorks to design a custom snap-fit case and lid, which were then 3D printed. The enclosure was engineered to allow proper airflow to the sensor while providing flexibility in how the device is run, supporting both an external battery or a standard 5V cable for continuous power.

DHT11 vs DHT22: Sensor Comparison

During the development of this project, I experimented with both the DHT11 and the DHT22 temperature and humidity sensors. While they share the same pinout and are often used interchangeably in tutorials, their performance characteristics are significantly different:

  • Accuracy & Range: The DHT22 is the clear winner here. It measures temperatures from -40°C to +80°C with an accuracy of ±0.5°C, whereas the DHT11 only measures from 0°C to 50°C with a much larger margin of error (±2°C). The humidity readings on the DHT22 are also far more precise (0-100% RH vs 20-80% RH on the DHT11).
  • Sampling Rate: Interestingly, the DHT11 has a slight edge in speed, allowing you to request data every 1 second (1Hz). The DHT22 requires 2 seconds (0.5Hz) between readings. However, for environmental sensing, temperature rarely changes fast enough for 1 second to matter.
  • Form Factor: The DHT11 is smaller and cheaper, making it great for basic educational projects. But for serious data logging where accuracy matters, the DHT22 justifies its slightly higher cost and larger white casing.

The plot below visualizes the logged data over time, demonstrating the signal filtering techniques applied to clean the sensor's raw output and handle occasional missed readings.

Filtered Sensor Data Plot