Comprehensive Local Weather Station With ESP32 for Environmental Tracking

by weather_station in Circuits > Microcontrollers

94 Views, 1 Favorites, 0 Comments

Comprehensive Local Weather Station With ESP32 for Environmental Tracking

Screenshot 2025-01-12 225335.png

The Weather Monitoring and Voice-Integrated Home Automation System is an advanced project designed to measure and track various environmental parameters including temperature, humidity, air pressure, wind speed and direction, and rainfall. These measurements are captured by a weather station powered by an ESP32 microcontroller, which is a compact yet powerful device capable of connecting to the internet to relay real-time data.

The data collected by the ESP32 is integrated into a Home Assistant platform, a popular open-source home automation system. Through this integration, users can conveniently view the weather information on a customizable dashboard that updates in real-time. This dashboard serves as a centralized control panel, offering a comprehensive overview of the current weather conditions.

In addition to the dashboard, the system includes weather alerts that notify users on their mobile devices whenever certain weather conditions meet predefined thresholds (e.g., heavy rainfall, extreme temperature changes, or wind speed alerts). This helps users stay informed and prepared for adverse weather conditions.

A key feature of this project is the inclusion of voice interaction, which adds a hands-free and user-friendly aspect to the system. Using voice commands, users can request information such as:

  1. Current weather status – simply ask the system about the weather and it will respond with the latest data.
  2. Open the Home Assistant dashboard – initiate the dashboard display directly through a voice command.

By leveraging ESP32, Home Assistant, and voice integration, this project creates a seamless and interactive weather monitoring system that enhances both functionality and convenience. Whether you’re looking for a quick weather update or need to access your home automation dashboard, this system brings everything to your fingertips or voice, providing a smart and efficient way to manage your home environment.

Supplies

1 * ESP32 Board

1 * Micro USB Cable

1 * DHT22 Sensor (Temperature and Humidity)

1 * BMP180 Sensor (Pressure)

Various Wires and Cables

10 * JST Connectors

6 * Hall A3144 Sensor

1 * Raspberry Pi 4

2 * Perfboard

1 * Hot glue gun kit

1 * Battery (Rechargable for ESP32)

3 * Resistor (4.7 k ohm)

1 * Capacitor (10µF 25 V)

Neodymium Magnet 1 Box


Tools:

3D printer

Soldering Iron

Wire crimper

Shrink tube (2mm and 5 mm) diameter 30 (2 mm) & 10 (5 mm)

RGBW wire(4 wires)(22awg) 10 meters

Saw

20 * M4 nut

20 * M4 washers

Super glue

M4 threaded rod 1 full rod

20 * M4 screws

Header pins(both male and female pins) 3 full strip

30 * Kabel binder

Temperature and Humidity Measurement With DHT22 Sensor

WhatsApp Image 2025-01-17 at 15.22.51 (1).jpeg
WhatsApp Image 2025-01-17 at 15.22.48.jpeg
WhatsApp Image 2025-01-17 at 15.22.49.jpeg

In this setup, we're using a DHT22 sensor to measure both temperature and humidity. The DHT22 is a widely used sensor for environmental monitoring, providing accurate readings for a variety of applications.

System Overview:

  1. DHT22 Sensor: This sensor is attached to a perfboard, with a pull-up resistor added to the data line for stable communication. The DHT22 provides digital temperature and humidity readings.
  2. Perfboard: The sensor is mounted on a perfboard, which allows easy connections and soldering. The pull-up resistor helps ensure reliable data transmission between the sensor and the microcontroller.
  3. Stevenson Screen: The entire setup, including the sensor and perfboard, is placed inside a Stevenson Screen. This is an essential component for accurate readings, as it shields the sensor from direct sunlight, rain, and other weather conditions that could affect its performance.
  4. 3D Printed Enclosure: All parts are housed inside a custom 3D-printed enclosure. This enclosure is designed to securely hold the sensor and perfboard in place while ensuring proper airflow, which is crucial for accurate temperature and humidity measurements.

This design ensures that the DHT22 sensor is protected from external environmental factors, allowing for more accurate and consistent readings over time. The 3D-printed parts make assembly easy and customizable, while the Stevenson Screen provides the necessary protection against the elements.


Wind Direction Sensor Design

WhatsApp Image 2025-01-17 at 15.22.52 (3).jpeg
WhatsApp Image 2025-01-17 at 15.22.52 (4).jpeg
WhatsApp Image 2025-01-17 at 15.22.52 (5).jpeg
WhatsApp Image 2025-01-17 at 15.22.52 (1).jpeg

a wind direction sensor that can accurately detect the direction from which the wind is blowing. The sensor setup features a rotating arrow-shaped flag, a weighted system for stability, and a magnetic sensor-based detection method using Hall effect sensors.

System Overview:

  1. Arrow-Shaped Flag: The wind direction sensor uses an arrow-shaped flag that rotates based on the direction of the wind. This shape helps clearly indicate the wind's direction, pointing toward the source of the wind. To ensure proper rotation and balance, a bolt is placed inside the arrow, acting as a weight to stabilize the flag.
  2. Free Rotation with Ball Bearing: The flag is mounted on a base with a ball bearing, allowing it to rotate freely in response to wind direction. The ball bearing provides minimal friction, ensuring smooth and responsive movement of the arrow in the wind.
  3. Hall Effect Sensors: Four Hall effect sensors are used to detect the wind's cardinal direction (North, East, South, and West). These sensors are magnetic sensors that can detect changes in the magnetic field, which happens when a magnet is brought close to the sensor.
  4. Cardinal Points Detection: The flag has a magnet attached to its upper part, which moves with the flag as it rotates. As the flag points toward each cardinal direction (North, East, South, West), the magnet will come close to the corresponding Hall effect sensor, triggering a signal.
  5. Intermediate Directions: For intermediate points, like North-East or South-West, two sensors will be activated simultaneously. For example, when the flag points towards North-East, both the North and East sensors will detect the magnet.
  6. Magnet Placement: The magnet is placed on the upper part of the rotating flag, allowing it to move freely and interact with the Hall sensors as the flag turns. This magnet is crucial for detecting the wind's direction by triggering the sensors as the flag moves through each cardinal point.
  7. Protective Enclosure: To protect the Hall effect sensors from rain or other environmental factors, the magnetic sensors are mounted on the base of the sensor system, while the magnet is mounted on the upper rotating flag. A protective cover is added to shield the sensors, ensuring that they remain functional even in wet or harsh weather conditions.
  8. Perfboard Setup: The Hall effect sensors are mounted onto a perfboard. This board acts as the main support structure for the sensors, wiring, and any additional components that might be needed, such as a microcontroller for processing the sensor signals.

Wind Speed Sensor

WhatsApp Image 2025-01-17 at 15.22.53 (1).jpeg
WhatsApp Image 2025-01-17 at 15.22.53 (2).jpeg
WhatsApp Image 2025-01-17 at 15.22.53 (3).jpeg
WhatsApp Image 2025-01-17 at 15.22.53.jpeg

This is an anemometer, a device designed to measure wind speed. The visible components include the base and the rotating cups. Here's a detailed description of how it works:

  1. Rotating Part:
  2. The three cups are mounted on a rotating assembly, which spins when the wind blows. The speed of rotation is proportional to the wind speed.
  3. Magnetic Sensor Mechanism:
  4. Inside the base, a magnetic Hall effect sensor detects changes in the magnetic field caused by a magnet attached to the rotating part.
  5. As the magnet passes by the sensor with each revolution, it generates an electrical impulse.
  6. Signal Output:
  7. The sensor sends out a pulse for each complete rotation of the cups. These impulses can be counted over a set time to determine the wind speed.

Precipitation Sensor

WhatsApp Image 2025-01-17 at 15.22.53 (6).jpeg
WhatsApp Image 2025-01-17 at 15.22.54.jpeg
WhatsApp Image 2025-01-17 at 15.22.53 (7).jpeg

precipitation sensor to measure the amount of rainfall. The sensor uses a mechanical system to collect rain and detect the amount through a tipping bucket mechanism, which activates a magnetic sensor for each tilt.


How It Works:

The sensor consists of a funnel that collects rainwater, directing it into a tipping bucket. Once the bucket reaches a certain weight due to the accumulated water, it tips over, triggering a magnetic sensor. The sensor detects the movement and sends an impulse each time the bucket tilts, counting the amount of precipitation based on the number of movements.


The precipitation sensor is constructed by 3D printing the essential components, including the funnel, base, and tipping bucket. The mechanical assembly involves cutting a threaded rod and attaching it with self-locking nuts and washers to secure the tipping bucket. As rainwater fills the funnel, the tipping bucket tilts, triggering a hall-effect sensor positioned near the pivot point.


This sensor which counts each impulse generated by the tipping action. A magnet is attached to the tipping bucket to activate the hall sensor when the bucket tilts. The system is programmed to process these impulses and calculate the amount of precipitation in millimeters, based on the number of bucket tilts.

3D Model Frame

WhatsApp Image 2025-01-17 at 15.22.54 (2).jpeg
WhatsApp Image 2025-01-17 at 15.22.53 (4).jpeg


This is a 3D-printed frame designed to hold all the components of the weather station, ensuring stability and proper alignment of the sensors. The structure features a central vertical pole with a sturdy base supported by four symmetrical legs for maximum balance. The arms extending from the central pole are strategically positioned to mount sensors like the anemometer, wind vane, and rain gauge. The compact and modular design allows easy assembly and ensures that each sensor has an optimal orientation for accurate data collection. This frame not only provides physical support but also helps maintain precision in measurements.

Circuit

Circuit.png

This circuit diagram designed using a NodeMCU microcontroller, which collects and transmits environmental data through its built-in Wi-Fi capability. The system incorporates a DHT sensor for measuring temperature and humidity, a BMP sensor for atmospheric pressure, an anemometer for wind speed, a wind vane for wind direction, and a rain gauge for precipitation levels. Signals from the anemometer, wind vane, and rain gauge are processed using ACS714 current sensors to ensure accurate readings. The NodeMCU acts as the central hub, managing sensor inputs and powering the entire circuit, making it ideal for real-time weather monitoring and IoT applications.

Home Assistant

feelslike.png


The weather station is integrated with Home Assistant, a local server that facilitates the control of various home automation devices. Home Assistant can be installed on a Raspberry Pi or within a Virtual Machine on a computer; in this setup, it is running on a virtual machine. To establish the connection between the weather station and Home Assistant, ESPhome is used, enabling the ESP32 to interface seamlessly with the Home Assistant platform. Once the configuration is complete, real-time weather data is accessible through either the Home Assistant web interface or mobile app. Additionally, the data is logged, allowing for long-term trend analysis through graphical representations.

Basic Steps to Set Up Home Assistant in a Virtual Machine:

  1. Create a Virtual Machine: Start by creating a virtual machine using software like VirtualBox or VMware. Allocate appropriate resources (CPU, RAM, and storage) based on your system's capabilities.
  2. Download Home Assistant OS: Download the Home Assistant OS image from the official website, selecting the appropriate version for virtual machine installation.
  3. Install Home Assistant on the VM: Attach the downloaded image to the virtual machine as the bootable disk and follow the installation instructions to set up Home Assistant on the VM.
  4. Configure Network Settings: Ensure the virtual machine has proper network connectivity, either using bridged or NAT network mode, so it can communicate with other devices in the home network.
  5. Access Home Assistant Interface: Once the installation is complete, access the Home Assistant web interface via the assigned IP address in a browser. The default login will guide the initial setup, including adding users and configuring basic settings.



You can install ESPHome on your computer to configure ESP32 devices.

For installation, you can use Home Assistant Supervisor or manually on your computer:

  1. Home Assistant Supervisor (via the ESPHome add-on):
  2. In Home Assistant, go to Supervisor > Add-on Store.
  3. Search for ESPHome and click on Install.
  4. After installation, click on Start to start the add-on.
  5. Open the ESPHome web interface by clicking Open Web UI.


To configure ESP32 devices, ESPHome can be installed on your computer. There are two methods for installation: via the Home Assistant Supervisor or manually on your computer.

Installation via Home Assistant Supervisor (ESPHome Add-on):

  1. Access the Supervisor Panel: In Home Assistant, navigate to the Supervisor section and then go to the Add-on Store.
  2. Search and Install ESPHome: In the Add-on Store, search for ESPHome and click on Install to begin the installation process.
  3. Start the Add-on: Once the installation is complete, click Start to initiate the ESPHome add-on within Home Assistant.
  4. Open the Web Interface: After starting the add-on, click on Open Web UI to open the ESPHome web interface, where you can begin configuring your ESP32 devices for integration with Home Assistant.

Mobile Dash Board

IMG-20241216-WA0004.jpg
IMG-20241216-WA0005.jpg

The Home Assistant Companion App enables users to access the Home Assistant dashboard on their Android mobile phones, providing a seamless interface to view all environmental data collected by your weather station. This app serves as a bridge, allowing you to monitor sensor data such as temperature, humidity, wind speed, wind direction, atmospheric pressure, and rainfall directly from your phone. However, for it to function properly, both the mobile phone and the Home Assistant setup (which includes the ESP32-based weather station and the VM running Home Assistant) must be connected to the same local network.

The app communicates with the Home Assistant instance hosted on the local network, ensuring a fast and secure connection without relying on external servers. To get started, you simply need to install the app, log in using the local IP address of your Home Assistant instance, and configure the dashboard to display your weather station data.

YAML File for ESP32

WhatsApp Image 2025-01-17 at 15.27.47.jpeg

This YAML configuration is intended for setting up a weather station using an ESP32 device. The configuration file is provided below

Downloads

Printed Circuit Board

Screenshot 2025-01-17 200107.png
Screenshot 2025-01-17 200131.png
Screenshot 2025-01-17 200158.png

PCB design using Gerber files involves creating detailed instructions for manufacturing a printed circuit board. Gerber files are the industry standard for defining the copper traces, solder masks, silkscreen, drill holes, and board outlines. Designers use specialized software like KiCad, Altium Designer, or Eagle to create the PCB layout, then export it as Gerber files. These files are verified using Gerber viewers to ensure accuracy before being sent to manufacturers for production. Each file corresponds to a specific layer or feature of the PCB, ensuring precise and reliable fabrication.

Below you can download the Gerber file of weather station.

https://drive.google.com/file/d/1PWZXJisGOk8A2zUfEtL4bqA50ukBGbza/view?usp=sharing



Voice Assistant Features

Screenshot 2025-01-06 011918.png

The Voice Assistant for the weather station offers key features designed to enhance user interaction and accessibility. The "Weather Station Status Update" feature allows users to receive real-time information about the station's current readings, such as temperature, humidity, and other weather conditions. Additionally, the "Open Weather Station Dashboard" feature enables users to quickly access the full weather station dashboard through voice commands, providing a convenient way to monitor data and manage settings. These functionalities are integrated into a Python application, streamlining the process of obtaining weather information hands-free.

A demo video and the python code are given below.

Mobil Alert

Screenshot 2025-01-17 200539.png
Screenshot 2025-01-17 200415.png
Screenshot 2025-01-17 200513.png
WhatsApp Image 2025-01-17 at 15.36.28 (2).jpeg
WhatsApp Image 2025-01-17 at 15.36.28.jpeg
8b27d886-fab9-4098-9708-e4815fc45dbf.jpg

To receive wind, rain, and temperature alerts on your mobile, integrate your ESP32 weather station with Home Assistant and set up automations. Use the Home Assistant Companion App to enable push notifications on your phone. Then, create automations to monitor sensor thresholds (e.g., high wind speed, heavy rain, or extreme temperatures) and send alerts using the notify.mobile_app service. This setup ensures you get real-time weather updates directly on your mobile.



In conclusion, the Weather Monitoring and Voice-Integrated Home Automation System combines cutting-edge technology with user-friendly features to offer an intuitive and efficient way to monitor and manage environmental conditions. By integrating the ESP32 microcontroller with Home Assistant and adding voice interaction, this system not only provides real-time weather updates but also empowers users to stay informed through smart alerts and hands-free commands. Whether for everyday weather tracking or preparing for unexpected changes, this system ensures that users have easy access to vital information, improving both convenience and safety in their home environment.