Weather Station (Home Assistant)

by mpg28 in Circuits > Arduino

7628 Views, 15 Favorites, 0 Comments

Weather Station (Home Assistant)

Screenshot 2021-11-08 132805.jpg

For this project you will need Home Assistant set up and running. You can learn how to do that here https://www.home-assistant.io/

My goal for this project is to have a self-sufficient device that I can leave outside and it will continuously send weather sensor data back to my computer over Wi-Fi and record that data so I can view it on nice looking graphs. The device will measure Temperature, Humidity, Ambient Air Pressure, Light, and Battery Voltage.

Supplies

Hardware

  • Wemos D1 Mini
  • BME280 temp/humidity/pressure sensor
  • BH1750 light sensor
  • TP4056 Lithium battery charger
  • Dallas DS18B20 temperature probe
  • Lithium battery 18650
  • Solar panel 5.5v 50mA x 3

Software

Home Assistant

ESP Home Flasher

IMG_4985.jpg
IMG_4983.jpg
Weather Station Wiring.jpg
IMG_5093.jpg

The first task is to find an enclosure to put it all in, I have a waterproof terminal box so I will use that. The next task was to wire all the components together, the diagram shows all the connections.


Screenshot 2021-11-09 163902.jpg
Screenshot 2021-11-09 164012.jpg
Screenshot 2021-11-09 164113.jpg
Screenshot 2021-11-09 164218.jpg
Screenshot 2021-11-09 164316.jpg
Screenshot 2021-11-09 164421.jpg
Screenshot 2021-11-09 164530.jpg
Screenshot 2021-11-09 164941.jpg
Screenshot 2021-11-09 165141.jpg

The next task is to get the WeMos D1 mini ESP8266 programmed. You will need to download ESPHome-Flasher from here https://github.com/esphome/esphome-flasher/releases

Then in Home Assistant install ESPHome from the Addon Store. Open up the Web UI and click on the green + at the bottom right. Next name the board, mine's "bob5" and enter your wifi details for it to connect to. The WeMos is a ESP8266 so select that one. Next click on the three dots and select manual download, this will compile the code, save the file when ready mine's bob5.bin. Then plug the WeMos into your computer via USB, select the Serial port for that device and open the file (bob5.bin). Click Flash ESP and it will install the code onto the WeMos. Now your Home Assistant can see bob5 on the network as a device and is ready to start being useful.

Screenshot 2021-11-09 171102.jpg
Screenshot 2021-11-09 170703.jpg
Screenshot 2021-11-09 170725.jpg

Next click Edit and insert the YAML settings for the board. Now that the device is connected to Home Assistant you can install the changes over wifi.

The YAML code can be found here

Code:

Weather Station Code


Screenshot 2021-11-11 082650.jpg
Screenshot 2021-11-11 083007.jpg
Screenshot 2021-11-11 083526.jpg

The Wemos board should now be transmitting sensor data back to Home Assistant. So we can start taking that data and display it in nice graphs.

In Home Assistant Install HACS, then under Frontend install 'Lovelace Mini Graph card'.

Now when you add a card to your dashboard you can select the Mini Graph.

Screenshot 2021-11-11 083851.jpg
Screenshot 2021-11-11 083919.jpg
Screenshot 2021-11-11 083959.jpg
Screenshot 2021-11-08 1328055.jpg

Here are some examples of the YAML code that you can put into it. These cards have lots of options to experiment with. The color_thresholds is a good one that changes the colour of the line when it passes a certain value.

type: custom:mini-graph-card
name: Outside Temperature
icon: mdi:thermometer
entities:
  - entity: sensor.bme280_temperature
    name: Temperature
show:
  extrema: false
  labels: true
  points: false
height: 300
align_state: left
color_thresholds:
  - value: 3
    color: '#BE1CEA'
  - value: 15
    color: '#0066AF'
  - value: 20
    color: '#d35400'
  - value: 22
    color: '#c0392b'
hours_to_show: 72
points_per_hour: 4


Screenshot 2021-11-08 133653.jpg
Screenshot 2021-11-08 133956.jpg
InkedIMG_4989_LI.jpg

You can also download Graphana and view the data. I have about 3 months of history now and it hasn't used up much memory or slowed Home Assistant down at all.