weather station esphome updates
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
# zorruno 2024-05-23 V1.0 Tidied up sensor info and added BMP280
|
||||
# zorruno 2024-05-24 V1.1 Tested ok and added some V calibration for mine
|
||||
# zorruno 2024-05-25 V2 A bunch more sensors added (wind direction not yet sorted)
|
||||
# zorruno 2024-05-25 V3 Shuffled some sensors, rain count added
|
||||
#############################################
|
||||
#############################################
|
||||
|
||||
@@ -19,46 +20,58 @@
|
||||
# battery voltage (adc A0)
|
||||
#
|
||||
# ads1115: 4 Channel A->D (0x48 i2c)
|
||||
# dht: DHT22 Temp/Humidity, Remote (GPIO15)
|
||||
# dht: DHT22 Temp/Humidity, Remote (GPIO13)
|
||||
# bmp280: Temp/pressure on the board (0x76 i2c)
|
||||
# pulse_meter: Wind Speed (GPIO13)
|
||||
#
|
||||
# pulse_meter: Wind Speed (GPIO14)
|
||||
# pulse_meter: Rainfall (GPIO12)
|
||||
|
||||
# text_sensor: Beaufort Wind Scale Labelling
|
||||
# text:sensor: Temp (av) Average of all temps
|
||||
# text_sensor: Temp (av) Average of all temps
|
||||
#
|
||||
# TO TEST (HAVE SENSOR or doesn't need one)
|
||||
# tsl2561: Ambient Light sensor (0x39 i2c)
|
||||
# ads1115 A1_GND: UV Index
|
||||
# ads1115 A0_GND: Wind Direction
|
||||
# pulse_meter: Rainfall (GPIO??)
|
||||
# battery life: Time from battery starting to drop (retain)
|
||||
#
|
||||
# Battery Calcs:
|
||||
# template: Last 20mins battery MAX
|
||||
# template: battery now - max (discharge/charge)
|
||||
# template binary: discharging, charging, stable
|
||||
#
|
||||
# ORDERED BUT DON'T HAVE YET
|
||||
# ltr390: Ambient Light and UV sensor (0x53 i2c)
|
||||
# pmsx003: PM Particulate Filter (UART)
|
||||
# AS3935: lightning sensor (i2c, but needs design)
|
||||
#
|
||||
# NOT USED (code commented)
|
||||
# bme280_i2c: Temp/humid/press (not used)
|
||||
#
|
||||
# POSSIBLY ADD
|
||||
# Analogue for Solar V?
|
||||
# Lightning?
|
||||
# ground movement/earthquake?
|
||||
# water sensor (rain now)
|
||||
#
|
||||
#############################################
|
||||
|
||||
#############################################
|
||||
# WIND SENSOR
|
||||
# looks like this one
|
||||
# https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf
|
||||
# WEMOS D1 Mini GPIO, and Weather station Use
|
||||
#############################################
|
||||
|
||||
#############################################
|
||||
# USEFUL LINKS
|
||||
# Wind Sensing
|
||||
# https://community.home-assistant.io/t/measuring-wind-speed/395693/20
|
||||
# https://community.home-assistant.io/t/measuring-wind-speed/395693/21
|
||||
# PIN HEADERS ON Weatherstation board:
|
||||
# D1, GPIO5 Used as SCL (I2C)
|
||||
# D2, GPIO4 Used as SDA (I2C)
|
||||
# D3, GPIO0 connected to FLASH button, boot fails if pulled LOW
|
||||
# D4, GPIO2 connected to on-board LED, boot fails if pulled LOW
|
||||
# D5, GPIO14 Used as Wind Speed Count
|
||||
# D6, GPIO12 Used as Rainfall count
|
||||
# D7, GPIO13 Used for DHT
|
||||
# D8, GPIO15 (Boot fails if pulled HIGH)
|
||||
#
|
||||
# NO HEADERS ON Weatherstation board:
|
||||
# D0, GPIO16, (used to wake up from deep sleep)
|
||||
# RX, GPIO3 (HIGH at boot)
|
||||
# TX, GPIO1 (HIGH at boot, boot fails if pulled LOW)
|
||||
# A0, ADC0 Used here to measure battery V
|
||||
#
|
||||
#############################################
|
||||
|
||||
#############################################
|
||||
@@ -79,13 +92,18 @@ substitutions:
|
||||
devicename: "esp-weatherstation"
|
||||
friendly_name: "Weather Station"
|
||||
description_comment: "Opengreen energy board, with BME280 Temp/Hum/Pres Sensor on an ESP8266 D1 Mini"
|
||||
|
||||
#if NOT using a secrets file, just replace these with the passwords etc in speech marks
|
||||
api_key: !secret esp-weatherstation_api_key #unfortunately you can't use substitutions in secrets names
|
||||
ota_pass: !secret esp-weatherstation_ota_pass #unfortunately you can't use substitutions in secrets names
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_pass: !secret wifi_password
|
||||
mqtt_server: 192.168.3.200
|
||||
mqtt_server: !secret mqtt_server
|
||||
mqtt_username: !secret mqtt_username
|
||||
mqtt_password: !secret mqtt_password
|
||||
|
||||
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
||||
update_time: 30s #update time for for temp sensors etc
|
||||
update_time: 30s #update time for for various temp sensors etc
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
@@ -177,8 +195,8 @@ wifi:
|
||||
# and not compile, or it will crash occasionally)
|
||||
# https://esphome.io/components/web_server.html
|
||||
#############################################
|
||||
#web_server:
|
||||
# port: 80
|
||||
web_server:
|
||||
port: 80
|
||||
# version: 1 #V1 occasionally works better, V2 The nicer page
|
||||
# username: !secret web_server_username #probably a good idea to secure it
|
||||
# password: !secret web_server_password
|
||||
@@ -191,16 +209,16 @@ wifi:
|
||||
mqtt:
|
||||
broker: ${mqtt_server}
|
||||
topic_prefix: ${mqtt_topic}/${devicename}
|
||||
#username: !secret mqtt_username
|
||||
#password: !secret mqtt_password
|
||||
username: ${mqtt_username}
|
||||
password: ${mqtt_password}
|
||||
|
||||
#A way to prevent deep sleep using MQTT command
|
||||
#Method to prevent deep sleep using MQTT command
|
||||
#on_message:
|
||||
#- topic: ${mqtt_topic}/${devicename}/deepsleepoff
|
||||
#- topic: ${mqtt_topic}/${devicename}/deepsleep
|
||||
#payload: 'ON'
|
||||
#then:
|
||||
#- deep_sleep.prevent: deep_sleep_1
|
||||
#- topic: ${mqtt_topic}/${devicename}/deepsleepon
|
||||
#- topic: ${mqtt_topic}/${devicename}/deepsleep
|
||||
#payload: 'ON'
|
||||
#then:
|
||||
#- deep_sleep.enter: deep_sleep_1
|
||||
@@ -277,7 +295,7 @@ sensor:
|
||||
|
||||
|
||||
################################
|
||||
# BME280 temp/humidity/pressure
|
||||
# BME280 temp/humidity/pressure (Note, BME and BMP Are different...)
|
||||
# https://esphome.io/cookbook/bme280_environment.html
|
||||
################################
|
||||
#- platform: bme280_i2c
|
||||
@@ -306,10 +324,10 @@ sensor:
|
||||
################################
|
||||
# DHT temp/humidity
|
||||
# https://esphome.io/components/sensor/dht.html
|
||||
# These DHTs are not very accurate...
|
||||
################################
|
||||
- platform: dht
|
||||
pin: GPIO15 #D8 on the D1 Mini ESP8266
|
||||
update_interval: ${update_time}
|
||||
pin: GPIO13 #D7 on the D1 Mini ESP8266
|
||||
temperature:
|
||||
name: ${friendly_name} DHT22 Temperature
|
||||
id: dht_temp
|
||||
@@ -385,30 +403,62 @@ sensor:
|
||||
id: battery_voltage
|
||||
pin: A0
|
||||
unit_of_measurement: "V"
|
||||
accuracy_decimals: 5
|
||||
update_interval: ${update_time}
|
||||
accuracy_decimals: 6
|
||||
update_interval: 10s
|
||||
#retain: true #retain useful if sleeping
|
||||
filters:
|
||||
- multiply: 5.223 # tested with multimeter
|
||||
- calibrate_linear:
|
||||
- 3.321 -> 3.125
|
||||
- 3.89 -> 3.90
|
||||
- 3.85 -> 3.92
|
||||
- 4.09 -> 4.14
|
||||
|
||||
################################
|
||||
# A Calculation of recent Av V
|
||||
# So we can see if battery is charging/discharging
|
||||
################################
|
||||
- platform: template
|
||||
name: ${friendly_name} Av Battery Voltage over 5 mins
|
||||
id: battery_voltage_5minav
|
||||
name: ${friendly_name} Av Battery Voltage over recent period
|
||||
id: battery_voltage_recentav
|
||||
unit_of_measurement: "V"
|
||||
accuracy_decimals: 5
|
||||
accuracy_decimals: 6
|
||||
update_interval: 30s #updates every 30s
|
||||
lambda: >
|
||||
return id(battery_voltage).state; //grabs values from the battery_voltage
|
||||
filters:
|
||||
- sliding_window_moving_average:
|
||||
window_size: 20 #20x 30s = 10 mins
|
||||
window_size: 40 #40x 30s = 20 min average period
|
||||
send_every: 1
|
||||
send_first_at: 1
|
||||
|
||||
################################
|
||||
# A Calculation of recent Max V
|
||||
# So we can see if battery is charging/discharging
|
||||
################################
|
||||
- platform: template
|
||||
name: ${friendly_name} Max Battery Voltage over recent period
|
||||
id: battery_voltage_recentmax
|
||||
unit_of_measurement: "V"
|
||||
accuracy_decimals: 6
|
||||
update_interval: 30s #updates every 30s
|
||||
lambda: >
|
||||
return id(battery_voltage).state; //grabs values from the battery_voltage
|
||||
filters:
|
||||
- max:
|
||||
window_size: 40 #40x 30s = 20 min average period
|
||||
send_every: 1
|
||||
send_first_at: 1
|
||||
|
||||
- platform: template
|
||||
name: ${friendly_name} Battery Voltage loss over 10 mins
|
||||
id: battery_voltage_recentloss
|
||||
unit_of_measurement: "V"
|
||||
accuracy_decimals: 5
|
||||
update_interval: 30s #updates every 30s
|
||||
lambda: >
|
||||
return {id(battery_voltage_recentmax).state - id(battery_voltage).state}; //recent av voltage - now
|
||||
|
||||
|
||||
- platform: duty_time
|
||||
id: battery_discharge_time
|
||||
name: ${friendly_name} Time battery is discharging
|
||||
@@ -420,9 +470,21 @@ sensor:
|
||||
- multiply: 0.01666666
|
||||
- round: 0
|
||||
lambda: >
|
||||
return { id(battery_voltage).state <= id(battery_voltage_5minav).state };
|
||||
return { id(battery_voltage).state <= id(battery_voltage_recentav).state };
|
||||
|
||||
|
||||
#############################################
|
||||
# WIND SENSOR
|
||||
# looks like this one
|
||||
# https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf
|
||||
#############################################
|
||||
|
||||
#############################################
|
||||
# USEFUL LINKS
|
||||
# Wind Sensing
|
||||
# https://community.home-assistant.io/t/measuring-wind-speed/395693/20
|
||||
# https://community.home-assistant.io/t/measuring-wind-speed/395693/21
|
||||
#############################################
|
||||
|
||||
################################
|
||||
# Wind Direction, Analogue on ADS115
|
||||
@@ -543,7 +605,7 @@ sensor:
|
||||
- platform: pulse_meter # https://community.home-assistant.io/t/measuring-wind-speed/395693
|
||||
id: wind_meter
|
||||
pin:
|
||||
number: GPIO13
|
||||
number: GPIO14 #D5 on D1 Mini
|
||||
mode:
|
||||
input: true
|
||||
pullup: true
|
||||
@@ -556,13 +618,14 @@ sensor:
|
||||
accuracy_decimals: 1
|
||||
timeout: 5s
|
||||
filters:
|
||||
- timeout:
|
||||
timeout: "5s" #after 5 seconds, if no pulses received....
|
||||
value: 0 #make the value = 0
|
||||
- heartbeat: 2s
|
||||
#- timeout:
|
||||
# timeout: "5s" #after 5 seconds, if no pulses received....
|
||||
# value: 0 #make the value = 0
|
||||
- multiply: 0.04 #kmh
|
||||
- sliding_window_moving_average: # Moving average to prevent too many data points
|
||||
window_size: 10
|
||||
send_every: 10
|
||||
window_size: 4
|
||||
send_every: 1
|
||||
- clamp:
|
||||
min_value: 0
|
||||
max_value: 250 #if anything over that, we have debounce issues or are going to die
|
||||
@@ -747,46 +810,47 @@ sensor:
|
||||
# Template for Beaufort for measuring wind speed
|
||||
# https://windy.app/blog/wind-speed-beaufort-scale.html
|
||||
################################
|
||||
# - platform: template
|
||||
# name: ${friendly_name} Windspeed Scale
|
||||
# icon: "mdi:weather-windy"
|
||||
# id: wind_meter_scale
|
||||
# lambda: return id(wind_meter).state;
|
||||
# unit_of_measurement: "m/s"
|
||||
# update_interval: 5s
|
||||
# filters:
|
||||
# - throttle_average: 5s
|
||||
# on_value:
|
||||
# lambda: |-
|
||||
# if (id(wind_meter_scale).state < 0.1) {
|
||||
# id(wind_scale).publish_state("Calm");
|
||||
# } else if (id(wind_meter_scale).state > 0 && id(wind_meter_scale).state < 2) {
|
||||
# id(wind_scale).publish_state("Light Air");
|
||||
# } else if (id(wind_meter_scale).state >= 2 && id(wind_meter_scale).state < 3) {
|
||||
# id(wind_scale).publish_state("Light Breeze");
|
||||
# } else if (id(wind_meter_scale).state >= 3 && id(wind_meter_scale).state < 5) {
|
||||
# id(wind_scale).publish_state("Gentle Breeze");
|
||||
# } else if (id(wind_meter_scale).state >= 5 && id(wind_meter_scale).state < 8) {
|
||||
# id(wind_scale).publish_state("Moderate Breeze");
|
||||
# } else if (id(wind_meter_scale).state >= 8 && id(wind_meter_scale).state < 11) {
|
||||
# id(wind_scale).publish_state("Fresh Breeze");
|
||||
# } else if (id(wind_meter_scale).state >= 11 && id(wind_meter_scale).state < 14) {
|
||||
# id(wind_scale).publish_state("Strong Breeze");
|
||||
# } else if (id(wind_meter_scale).state >= 14 && id(wind_meter_scale).state < 17) {
|
||||
# id(wind_scale).publish_state("Near Gale");
|
||||
# } else if (id(wind_meter_scale).state >= 17 && id(wind_meter_scale).state < 21) {
|
||||
# id(wind_scale).publish_state("Gale");
|
||||
# } else if (id(wind_meter_scale).state >= 21 && id(wind_meter_scale).state < 24) {
|
||||
# id(wind_scale).publish_state("Severe Gale");
|
||||
# } else if (id(wind_meter_scale).state >= 24 && id(wind_meter_scale).state < 28) {
|
||||
# id(wind_scale).publish_state("Storm");
|
||||
# } else if (id(wind_meter_scale).state >= 28 && id(wind_meter_scale).state < 33) {
|
||||
# id(wind_scale).publish_state("Violent Storm");
|
||||
# } else if (id(wind_meter_scale).state >= 33) {
|
||||
# id(wind_scale).publish_state("Hurricane Force");
|
||||
# } else {
|
||||
# id(wind_scale).publish_state("");
|
||||
# }
|
||||
- platform: template
|
||||
name: ${friendly_name} Windspeed Scale
|
||||
icon: "mdi:weather-windy"
|
||||
id: wind_meter_scale
|
||||
lambda: return id(wind_meter).state;
|
||||
unit_of_measurement: "m/s"
|
||||
update_interval: 5s
|
||||
filters:
|
||||
- throttle_average: 5s
|
||||
- multiply: 0.278 #to get m/s from km/h
|
||||
on_value:
|
||||
lambda: |-
|
||||
if (id(wind_meter_scale).state < 0.1) {
|
||||
id(wind_scale).publish_state("Calm");
|
||||
} else if (id(wind_meter_scale).state > 0 && id(wind_meter_scale).state < 2) {
|
||||
id(wind_scale).publish_state("Light Air");
|
||||
} else if (id(wind_meter_scale).state >= 2 && id(wind_meter_scale).state < 3) {
|
||||
id(wind_scale).publish_state("Light Breeze");
|
||||
} else if (id(wind_meter_scale).state >= 3 && id(wind_meter_scale).state < 5) {
|
||||
id(wind_scale).publish_state("Gentle Breeze");
|
||||
} else if (id(wind_meter_scale).state >= 5 && id(wind_meter_scale).state < 8) {
|
||||
id(wind_scale).publish_state("Moderate Breeze");
|
||||
} else if (id(wind_meter_scale).state >= 8 && id(wind_meter_scale).state < 11) {
|
||||
id(wind_scale).publish_state("Fresh Breeze");
|
||||
} else if (id(wind_meter_scale).state >= 11 && id(wind_meter_scale).state < 14) {
|
||||
id(wind_scale).publish_state("Strong Breeze");
|
||||
} else if (id(wind_meter_scale).state >= 14 && id(wind_meter_scale).state < 17) {
|
||||
id(wind_scale).publish_state("Near Gale");
|
||||
} else if (id(wind_meter_scale).state >= 17 && id(wind_meter_scale).state < 21) {
|
||||
id(wind_scale).publish_state("Gale");
|
||||
} else if (id(wind_meter_scale).state >= 21 && id(wind_meter_scale).state < 24) {
|
||||
id(wind_scale).publish_state("Severe Gale");
|
||||
} else if (id(wind_meter_scale).state >= 24 && id(wind_meter_scale).state < 28) {
|
||||
id(wind_scale).publish_state("Storm");
|
||||
} else if (id(wind_meter_scale).state >= 28 && id(wind_meter_scale).state < 33) {
|
||||
id(wind_scale).publish_state("Violent Storm");
|
||||
} else if (id(wind_meter_scale).state >= 33) {
|
||||
id(wind_scale).publish_state("Hurricane Force");
|
||||
} else {
|
||||
id(wind_scale).publish_state("");
|
||||
}
|
||||
|
||||
#switch:
|
||||
# - platform: template
|
||||
@@ -853,3 +917,40 @@ sensor:
|
||||
# type: float
|
||||
# restore_value: no
|
||||
# initial_value: '0.0'
|
||||
|
||||
################################
|
||||
# Pulse Meter for measuring rainfall
|
||||
# https://esphome.io/components/sensor/pulse_meter.html
|
||||
#
|
||||
################################
|
||||
# CALIBRATION HINTS
|
||||
# https://forum.mysensors.org/topic/9594/misol-rain-gauge-tipping-bucket-rain-amount/2
|
||||
################################
|
||||
- platform: pulse_meter
|
||||
id: rainfall_meter
|
||||
pin:
|
||||
number: GPIO12 #D6 on D1 Mini
|
||||
mode:
|
||||
input: true
|
||||
pullup: true
|
||||
#internal: true # If true, don't send to HA/MQTT etc
|
||||
internal_filter_mode: EDGE
|
||||
internal_filter: 10ms
|
||||
name: ${friendly_name} Rainfall
|
||||
#icon: mdi:
|
||||
unit_of_measurement: "mm"
|
||||
accuracy_decimals: 1
|
||||
timeout: 5s
|
||||
filters:
|
||||
- heartbeat: 2s
|
||||
#- timeout:
|
||||
# timeout: "5s" #after 5 seconds, if no pulses received....
|
||||
# value: 0 #make the value = 0
|
||||
- multiply: 0.2794 #mm of rain from tip bucket, 0.28 mm per pulse, or 3.57 pulse per mm (NEEDS CALIBRATION)
|
||||
- sliding_window_moving_average: # Moving average to prevent too many data points
|
||||
window_size: 4
|
||||
send_every: 1
|
||||
#- clamp:
|
||||
# min_value: 0
|
||||
# max_value: 250 #if anything over that, we have debounce issues or are going to die
|
||||
# ignore_out_of_range: true
|
Reference in New Issue
Block a user