Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Weather Station with DHT22, BMP180, and I2C LCD Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Weather Station with DHT22, BMP180, and I2C LCD Display

Circuit Documentation

Summary

This circuit is designed to interface an ESP32 microcontroller with various sensors and a display. The sensors include a DHT22 for temperature and humidity, a BMP180 for pressure, and an MQ-7 for gas detection. The data from these sensors is displayed on a 16x2 I2C LCD. The ESP32 reads data from the sensors and updates the display accordingly.

Component List

  1. ESP32 (30 pin)

    • Description: A powerful microcontroller with built-in Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
  2. DHT22

    • Description: A digital temperature and humidity sensor.
    • Pins: GND, VCC, DAT
  3. BMP180

    • Description: A digital barometric pressure sensor.
    • Pins: 3.3, SDA, SCL, GND, VCC
  4. MQ-7 Breakout

    • Description: A carbon monoxide gas sensor.
    • Pins: VCC, GND, DO, AO
  5. 16x2 I2C LCD

    • Description: A 16x2 character LCD with I2C interface.
    • Pins: GND, VCC, SDA, SCL

Wiring Details

ESP32 (30 pin)

DHT22

BMP180

MQ-7 Breakout

16x2 I2C LCD

Code Documentation

#include <DHT.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <LiquidCrystal_I2C.h>

#define DHTPIN D15    // Pin for DHT22 sensor
#define DHTTYPE DHT22   // Sensor type

DHT dht(DHTPIN, DHTTYPE);
Adafruit_BMP280 bmp; // I2C
LiquidCrystal_I2C lcd(0x27, 16, 2); // 16x2 LCD

void setup() {
  Serial.begin(9600);
  dht.begin();
  bmp.begin();
  lcd.begin();
  lcd.backlight();
}

void loop() {
  // Reading from DHT22
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();
  
  // Reading from BMP280
  float pressure = bmp.readPressure() / 100.0F; // Convert pressure to hPa

  // Display on LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C");

  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(humidity);
  lcd.print(" %");

  delay(2000);  // Wait for 2 seconds
}

This code initializes the DHT22, BMP180, and 16x2 I2C LCD in the setup() function. In the loop() function, it reads temperature and humidity from the DHT22, pressure from the BMP180, and displays the temperature and humidity on the LCD. The loop runs every 2 seconds.