Added LUX calculation to the APDS9960 sensor configuration.
This commit is contained in:
parent
ea376846f5
commit
9d21170f06
2 changed files with 167 additions and 0 deletions
2
esphome_config/esphome_run_weatherstation.sh
Normal file
2
esphome_config/esphome_run_weatherstation.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
sudo docker-compose exec esphome esphome run /config/weatherstation.yml
|
165
esphome_config/weatherstation.yml
Normal file
165
esphome_config/weatherstation.yml
Normal file
|
@ -0,0 +1,165 @@
|
|||
esphome:
|
||||
name: weatherstation
|
||||
platform: ESP8266
|
||||
board: d1_mini
|
||||
|
||||
i2c:
|
||||
- id: bus_a
|
||||
sda: 4 # D2
|
||||
scl: 5 # D1
|
||||
scan: true
|
||||
|
||||
apds9960:
|
||||
address: 0x39
|
||||
update_interval: 300s
|
||||
|
||||
sensor:
|
||||
#
|
||||
#################### wind sensor
|
||||
- platform: pulse_counter
|
||||
pin:
|
||||
# pin D8
|
||||
number: GPIO15
|
||||
mode: INPUT # TODO check if required
|
||||
unit_of_measurement: 'm/s' ##change to m/s if metric
|
||||
name: 'wind_speed'
|
||||
icon: 'mdi:weather-windy'
|
||||
id: my_wind
|
||||
count_mode:
|
||||
rising_edge: DISABLE
|
||||
falling_edge: INCREMENT
|
||||
internal_filter: 50us
|
||||
update_interval: 60s
|
||||
#rotations_per_sec = pulses/2/60
|
||||
#circ_m=0.09*2*3.14 = 0.5652
|
||||
#mps = 1.18*circ_m*rotations_per_sec
|
||||
#mps = 1.18*0.5652/2/60 =0,0055578
|
||||
filters:
|
||||
- multiply: 0.0055578 #use for m/s
|
||||
# - multiply: 2.237 #m/s to mph
|
||||
# - sliding_window_moving_average:
|
||||
# window_size: 4
|
||||
# send_every: 1
|
||||
#- multiply: 0.04973 #1.492mph switch to close 1/sec per spec, pulse/sec (/60/2)*1.492
|
||||
#- multiply: 0.0124327986 #m/s * mph conversion
|
||||
|
||||
#################### apds9960 sensor i2c
|
||||
- platform: apds9960
|
||||
type: CLEAR
|
||||
name: "APDS9960_clear_channel"
|
||||
- platform: apds9960
|
||||
type: RED
|
||||
name: "APDS9960_red_channel"
|
||||
id: apds9960_red
|
||||
- platform: apds9960
|
||||
type: GREEN
|
||||
name: "APDS9960_green_channel"
|
||||
id: apds9960_green
|
||||
- platform: apds9960
|
||||
type: BLUE
|
||||
name: "APDS9960_blue_channel"
|
||||
id: apds9960_blue
|
||||
- platform: template
|
||||
name: "lux"
|
||||
lambda: |-
|
||||
return (-0.32466F * id(apds9960_red)..raw_state) + (1.57837F * id(apds9960_green)..raw_state) + (-0.73191F * id(apds9960_blue)..raw_state);
|
||||
update_interval: 300s
|
||||
unit_of_measurement: 'lux'
|
||||
|
||||
#################### bme280 sensor i2c
|
||||
- platform: bme280
|
||||
temperature:
|
||||
name: "BME280_temperature"
|
||||
id: bme280_temperature
|
||||
pressure:
|
||||
name: "BME280_ressure"
|
||||
id: bme280_pressure
|
||||
humidity:
|
||||
name: "BME280 Relative Humidity"
|
||||
id: bme280_humidity
|
||||
address: 0x76
|
||||
update_interval: 300s
|
||||
|
||||
- platform: template
|
||||
name: "altitude"
|
||||
lambda: |-
|
||||
const float STANDARD_SEA_LEVEL_PRESSURE = 1013.25; //in hPa, see note
|
||||
return ((id(bme280_temperature).state + 273.15) / 0.0065) *
|
||||
(powf((STANDARD_SEA_LEVEL_PRESSURE / id(bme280_pressure).state), 0.190234) - 1); // in meter
|
||||
update_interval: 300s
|
||||
icon: 'mdi:signal'
|
||||
unit_of_measurement: 'm'
|
||||
|
||||
- platform: template
|
||||
name: "absolute_humidity"
|
||||
lambda: |-
|
||||
const float mw = 18.01534; // molar mass of water g/mol
|
||||
const float r = 8.31447215; // Universal gas constant J/mol/K
|
||||
return (6.112 * powf(2.718281828, (17.67 * id(bme280_temperature).state) /
|
||||
(id(bme280_temperature).state + 243.5)) * id(bme280_humidity).state * mw) /
|
||||
((273.15 + id(bme280_temperature).state) * r); // in grams/m^3
|
||||
accuracy_decimals: 2
|
||||
update_interval: 300s
|
||||
icon: 'mdi:water'
|
||||
unit_of_measurement: 'g/m³'
|
||||
|
||||
- platform: template
|
||||
name: "dew_point"
|
||||
lambda: |-
|
||||
return (243.5*(log(id(bme280_humidity).state/100)+((17.67*id(bme280_temperature).state)/
|
||||
(243.5+id(bme280_temperature).state)))/(17.67-log(id(bme280_humidity).state/100)-
|
||||
((17.67*id(bme280_temperature).state)/(243.5+id(bme280_temperature).state))));
|
||||
unit_of_measurement: °C
|
||||
update_interval: 300s
|
||||
icon: 'mdi:thermometer-alert'
|
||||
|
||||
# battery power adc
|
||||
- platform: adc
|
||||
pin: A0
|
||||
name: "battery_power"
|
||||
update_interval: 300s
|
||||
|
||||
binary_sensor:
|
||||
# battery charged pin
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: 12 # D6
|
||||
mode:
|
||||
input: true
|
||||
pullup: false
|
||||
name: "battery_charged"
|
||||
|
||||
# battery charging pin
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: 14 # D5
|
||||
mode:
|
||||
input: true
|
||||
pullup: false
|
||||
name: "battery_charging"
|
||||
|
||||
time:
|
||||
- platform: sntp
|
||||
id: my_time
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
|
||||
ota:
|
||||
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
|
||||
wifi:
|
||||
ssid: UPC4556888
|
||||
password: emmydhvZ4faw
|
||||
manual_ip:
|
||||
# Set this to the IP of the ESP
|
||||
static_ip: 192.168.0.91
|
||||
# Set this to the IP address of the router. Often ends with .1
|
||||
gateway: 192.168.0.1
|
||||
# The subnet of the network. 255.255.255.0 works for most home networks.
|
||||
subnet: 255.255.255.0
|
||||
|
||||
captive_portal:
|
Loading…
Reference in a new issue