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

ESP32-Based Smart Weather Station with BME280, BH1750, and OLED Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Smart Weather Station with BME280, BH1750, and OLED Display

Smart Weather Station Circuit Documentation

Summary

This document provides a detailed overview of a smart weather station circuit. The circuit interfaces with various sensors and an OLED display to measure and display environmental parameters such as temperature, humidity, pressure, and light intensity. The core of the circuit is an ESP32 microcontroller, which communicates with the sensors and the display.

Component List

  1. BME/BMP280

    • Description: Environmental sensor for measuring temperature, humidity, and pressure.
    • Pins: GND, SCL, SDA, VIN
  2. Wind Vane

    • Description: Sensor for measuring wind direction.
    • Pins: A0, VCC, GND
  3. 0.96" OLED

    • Description: Display module for showing sensor readings.
    • Pins: GND, VDD, SCK, SDA
  4. BH1750

    • Description: Light intensity sensor.
    • Pins: VCC, GND, SCL, SDA, ADDR
  5. TP4056

    • Description: Lithium-ion battery charger module.
    • Pins: OUT-, B-, B+, OUT+, IN-, IN+
  6. 18650 Li-ion Battery

    • Description: Rechargeable lithium-ion battery.
    • Pins: -, +
  7. RS485

    • Description: Communication module for RS485 protocol.
    • Pins: VCC, RO, RE, GND, B, A, DE, DI
  8. ESP32 (30 pin)

    • Description: Microcontroller for processing and communication.
    • 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
  9. Soil Moisture Module

    • Description: Module for measuring soil moisture.
    • Pins: positive, negative, Analog, Digital, Ground, VCC
  10. Soil Moisture Sensor

    • Description: Sensor for detecting soil moisture.
    • Pins: positive, negative
  11. 5v 2-Relay JD-VCC

    • Description: Relay module for controlling high-power devices.
    • Pins: JD-VCC, VCC, GND, IN1, IN2, NO, COM, NC
  12. Pump

    • Description: Water pump for irrigation.
    • Pins: +, -
  13. Plastic Solenoid Valve

    • Description: Valve for controlling water flow.
    • Pins: pin1, pin2

Wiring Details

BME/BMP280

Wind Vane

0.96" OLED

BH1750

TP4056

18650 Li-ion Battery

Soil Moisture Module

Soil Moisture Sensor

Code Documentation

/*
 * Smart Weather Station
 * This Arduino sketch interfaces with a BME280 sensor, BH1750 sensor, and an
 * OLED display to create a smart weather station. The BME280 sensor measures
 * temperature, humidity, and pressure. The BH1750 sensor measures light
 * intensity. The OLED display shows the sensor readings.
 */

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <BH1750.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_BME280 bme;
BH1750 lightMeter;

void setup() {
  Serial.begin(115200);
  Wire.begin();

  if (!bme.begin(0x76)) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }

  if (!lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
    Serial.println("Could not find a valid BH1750 sensor, check wiring!");
    while (1);
  }

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("SSD1306 allocation failed");
    while (1);
  }
  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop() {
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);

  display.print("Temp: ");
  display.print(bme.readTemperature());
  display.println(" *C");

  display.print("Humidity: ");
  display.print(bme.readHumidity());
  display.println(" %");

  display.print("Pressure: ");
  display.print(bme.readPressure() / 100.0F);
  display.println(" hPa");

  display.print("Light: ");
  display.print(lightMeter.readLightLevel());
  display.println(" lx");

  display.display();
  delay(2000);
}

This code initializes the BME280 sensor, BH1750 sensor, and the OLED display. It reads the temperature, humidity, pressure, and light intensity from the sensors and displays the readings on the OLED display. The loop function continuously updates the display with new sensor readings every 2 seconds.