Weather Station (Home Assistant)
by mpg28 in Circuits > Arduino
8204 Views, 16 Favorites, 0 Comments
Weather Station (Home Assistant)
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
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.
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.
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:
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.
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
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.