Weather Station for Home Assistant in ESPHome

The weather station measures speed and direction of wind, as well as temperature and humidity.
The ESP32 is programmed with ESPHome to connect directly to Home Assistant.
(sill not included atmospheric pressure, UV Ray Index).

(*) The electronic part of this weather station is based on the model Conrad WH2080 – 2011/13

 

The list of components:

Sensors:

Anemometer (Wind speed)

The Anemometer measures wind speed by closing a reed switch on each rotation. It’s plugged into the wind vane.
Two pulses are given per full rotation of the wind cups.1 switch closure/second indicates 2.4 km/h (1.492 MPH).
The Anemometer be pulled high to 3.3V via a 10 kΩ Pull-Up resistor. (Sales on AliExpress)

Wind Direction Sensor  (Wind vane)

The wind vane indicates the direction that the wind is blowing. This uses 4 magnetic reed switches, for North, East, South & West.
Each direction has a different resistance per direction with their own unique resistor.
As the wind vane rotates, a magnet closes the reed switches, and may close two at a time due to their proximity to each other also 16 different positions. Directions between, e.g. North East, are the resistance value of two resistors in parallel.
Value ranges of the ADC determine the direction the wind.

This table contains values that are measured on an actual wind vane that is in use with a 10 kΩ on-board Pull-Up.

Direction by °ResistanceVoltage
(V=3.3v, R =10 kΩ)
0N33K2.53V
22.56.57K1.31V
45NE8.2K1.49V
67.58910.27V
90E1K0.30V
112.56880.21V
135SE2.2K0.59V
157.51.41K0.41V
180S3.9K0.92V
202.53.14K0.79V
225SW16K2.03V
247.514.12K1.93V
270W120K3.05V
292.542.12K2.67V
315NW64.9K2.86V
337.521.88K2.26V

The four leads from the RJ2 jack are as follows:

  • Pin 1 ——–> output of Wind vane
  • Pin 2 ——–> output of Anemometer
  • Pin 3 ——–> ground of Anemometer
  • Pin 4 ——–> ground of Wind vane

Rain gauge

This is a tipping bucket rain gauge. Rain water falls into a funnel and feels a small bucket.
When the bucket fills with water it tips over under gravity and activates a magnetic reed switch.
The count of bucket tips is the measured rain.

This rain gauge is 0.2794mm ( 0.011 inch) per bucket tip.
The gauge’s switch is connected to the two center conductors of the attached RJ 1-terminated cable.
The Rain Bucket be pulled high to 3.3V via a 10 kΩ pull-up resistor.

The four leads from the RJI jack are as follows:

  • Pin 1
  • Pin 2 ——–> output of Rain Gauge
  • Pin 3 ——–> ground of Rain Gauge
  • Pin 4

DHT11: Measuring temperature and humidity

For recording temperature and humidity I’m using DHT11 Temperature and Humidity Sensor.
Note: The DHT 11 I’ve been using include the internal 4.7k’s resistor.
It communicate with a ESP32 over a single wire and powered direct with 3.3V.

Powering ESP32 with 12V Power Source using Buck Converter

For the ESP32’s operating voltage, I’m using a buck converter LM2596 (step-down regulator) to safely bring 12V car battery down to 5V.
The ESP32 S2 boards have a voltage regulator on VBUS, allowing safe operation with 5V input.
The battery will be charged via a solar panel.

12V Battery Monitoring

I used the INA226 DC current and power sensor to check the battery voltage.
It provides accurate measurements of car-battery voltage, load voltage, current, and power.
The INA226 has a voltage limit of 26 V and can measure a maximum current of ±3.2 A.

The INA226 Sensor has VBS Pin, which is used to measure the Load Voltage.
Therefore we need to connect the VBS pin to Vin- pin.

 

Weather Station
Connection Diagram

 

ESP32 S2 mini According to the datasheet you can find out which other GPIO pins can be used for projects.

  • GPIO03:  ADC Wind Direction
  • GPIO37:  Rain Gauge
  • GPIO39:  Anemometer (Wind speed)
  • GPIO33:  SDA
  • GPIO35:  SCL
  • GPIO07:  DHT11
  • GPIO05:  voltage divider (reserved)

Code Implementation

Here’s the code of the project:

The code is checked into GitHub at: Weather-Station-for-Home-Assistant

 

*) Alle drei Sensoren habe ich auf einem Flohmarkt in Dortmund gekauft.
Sie waren Teil einer Funkwetterstation von Conrad, Marke WH2080, aus dem Jahr 2011.
Sie lagen alle zusammen mit dem Sendergehäuse auf dem Tisch.

*) ESP32 ADC returns 0-4096 corresponding to 0V to 3.3V but it is not linear-
*) The DHT22 (or BME680) sensor offers better resolution and accuracy than the DHT11. However, we have to correct the values of the DHT11’s temperature and humidity by using the filter option in ESPHome.