hugokernel / esphome-weather-station

ESPHome version of Elektor weather station v2
MIT License
280 stars 19 forks source link

sensor source #3

Closed boelle closed 3 years ago

boelle commented 3 years ago

@hugokernel hi, do you know where inside eu i can get the sensors? from china takes to long and i have to pay extra tax

EDIT: i think i will just get a wind direction and speed sensor. I made an arduino weather station and from that i have both rain gauge and bme280

i dont want to get the temp in the sun but if i want to could just add another bme280

boelle commented 3 years ago

Q: could i just repeat like this? i plan to use adafruit sensor and if SDO pin is put to GND it changes from 0x76 og 0x77

i know that pressure will be the same and prob. also humidity, but i'm just looking for working code

  - platform: bme280
    address: 0x76
    update_interval: 60s
    iir_filter: 16x
    temperature:
      name: "${friendly_name} in shade temperature"
      oversampling: 16x
    humidity:
      name: "${friendly_name} in shade humidity"
      oversampling: 16x
    pressure:
      name: "${friendly_name} in shade pressure"
      oversampling: 16x
  - platform: bme280
    address: 0x77
    update_interval: 60s
    iir_filter: 16x
    temperature:
      name: "${friendly_name} in sun temperature1"
      oversampling: 16x
    humidity:
      name: "${friendly_name} in sun humidity1"
      oversampling: 16x
    pressure:
      name: "${friendly_name} in sun pressure1"
      oversampling: 16x
boelle commented 3 years ago

and i forgot to ask, (i cant figure the code yet), but does this part ever reset?

  - platform: pulse_counter
    pin:
      number: GPIO38
      mode: INPUT_PULLUP
    unit_of_measurement: 'mm'
    name: "Rain gauge"
    icon: 'mdi:weather-rainy'
    id: rain_gauge
    internal: true
    count_mode:
      rising_edge: DISABLE
      falling_edge: INCREMENT
    internal_filter: 13us
    update_interval: 60s
    filters:
      # Each 0.011" (0.2794mm) of rain causes one momentary contact closure
      - multiply: 0.2794
    accuracy_decimals: 4

i understand that rain per minute and daily rain are reset, but does the above work as a rain in total that is only reset if mcu is reset(power cycle)

hugokernel commented 3 years ago

Did you find answers to all your questions?

boelle commented 3 years ago

I think yes

My problem is more checking if my code is right

tor. 23. sep. 2021 12.33 skrev Charles R. @.***>:

Did you find answers to all your questions?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/hugokernel/esphome-weather-station/issues/3#issuecomment-925692417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5HTL2WRONDIWZGN45BYFTUDL7ARANCNFSM5EMLPRWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

boelle commented 3 years ago

But not home before evening

But if you have time to check my code for any obvious errors I would be happy

tor. 23. sep. 2021 12.33 skrev Charles R. @.***>:

Did you find answers to all your questions?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/hugokernel/esphome-weather-station/issues/3#issuecomment-925692417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5HTL2WRONDIWZGN45BYFTUDL7ARANCNFSM5EMLPRWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

hugokernel commented 3 years ago

Q: could i just repeat like this? i plan to use adafruit sensor and if SDO pin is put to GND it changes from 0x76 og 0x77

i know that pressure will be the same and prob. also humidity, but i'm just looking for working code

  - platform: bme280
    address: 0x76
    update_interval: 60s
    iir_filter: 16x
    temperature:
      name: "${friendly_name} in shade temperature"
      oversampling: 16x
    humidity:
      name: "${friendly_name} in shade humidity"
      oversampling: 16x
    pressure:
      name: "${friendly_name} in shade pressure"
      oversampling: 16x
  - platform: bme280
    address: 0x77
    update_interval: 60s
    iir_filter: 16x
    temperature:
      name: "${friendly_name} in sun temperature1"
      oversampling: 16x
    humidity:
      name: "${friendly_name} in sun humidity1"
      oversampling: 16x
    pressure:
      name: "${friendly_name} in sun pressure1"
      oversampling: 16x

If you change the address, yes, it will work but after that, I don't really see the point of measuring the temperature in the sun ;)

hugokernel commented 3 years ago

i understand that rain per minute and daily rain are reset, but does the above work as a rain in total that is only reset if mcu is reset(power cycle)

The integration will start again at the beginning but is it really a problem? The assembly may reset often?

boelle commented 3 years ago

Temperature in the sun makes sense when summer starts and you want to know if you need a jacket or t-shirt or you can go topless

tor. 23. sep. 2021 16.53 skrev Charles R. @.***>:

Q: could i just repeat like this? i plan to use adafruit sensor and if SDO pin is put to GND it changes from 0x76 og 0x77

i know that pressure will be the same and prob. also humidity, but i'm just looking for working code

  • platform: bme280 address: 0x76 update_interval: 60s iir_filter: 16x temperature: name: "${friendly_name} in shade temperature" oversampling: 16x humidity: name: "${friendly_name} in shade humidity" oversampling: 16x pressure: name: "${friendly_name} in shade pressure" oversampling: 16x
  • platform: bme280 address: 0x77 update_interval: 60s iir_filter: 16x temperature: name: "${friendly_name} in sun temperature1" oversampling: 16x humidity: name: "${friendly_name} in sun humidity1" oversampling: 16x pressure: name: "${friendly_name} in sun pressure1" oversampling: 16x

If you change the address, yes, it will work but after that, I don't really see the point of measuring the temperature in the sun ;)

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/hugokernel/esphome-weather-station/issues/3#issuecomment-925890329, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5HTL7MM4ZNRJF66HPR6FDUDM5MZANCNFSM5EMLPRWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

boelle commented 3 years ago

my code so far

esphome:
  name: vejrstation
  platform: ESP8266
  board: nodemcuv2
  esp8266_restore_from_flash: True

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: vejrstation
    password: !secret ap_password

web_server:
  port: 80

logger:

api:

ota:

captive_portal:

i2c:
  frequency: 100kHz
  sda: D2
  scl: D1

sensor:
  - platform: pulse_counter
    pin:
      number: D6
      mode: INPUT_PULLUP
    unit_of_measurement: 'm/s'
    name: "Wind speed"
    icon: 'mdi:weather-windy'
    count_mode:
      rising_edge: DISABLE
      falling_edge: INCREMENT
    internal_filter: 13us
    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
      #- sliding_window_moving_average:
      #    window_size: 2
      #    send_every: 1

  - platform: pulse_counter
    pin:
      number: D5
      mode: INPUT_PULLUP
    unit_of_measurement: 'mm'
    name: "Rain gauge"
    icon: 'mdi:weather-rainy'
    id: rain_gauge
    internal: true
    count_mode:
      rising_edge: DISABLE
      falling_edge: INCREMENT
    internal_filter: 13us
    update_interval: 60s
    filters:
      # Each 0.011" (0.2794mm) of rain causes one momentary contact closure
      - multiply: 0.2794
    accuracy_decimals: 4

  - platform: integration
    name: "rainfall per min"
    id: rain_per_min
    time_unit: min
    unit_of_measurement: 'mm'
    icon: 'mdi:weather-rainy'
    sensor: rain_gauge

  - platform: total_daily_energy
    name: "total daily rain"
    power_id: rain_gauge
    unit_of_measurement: 'mm'
    icon: 'mdi:weather-rainy'
    # x60 To convert to aggregated rain amount
    filters:
      - multiply: 60

  - platform: bme280
    address: 0x76
    update_interval: 60s
    iir_filter: 16x
    temperature:
      name: "temperature"
      id: bme280_temperature
      oversampling: 16x
    humidity:
      name: "humidity"
      id: bme280_humidity
      oversampling: 16x
    pressure:
      name: "pressure"
      id: bme280_pressure
      oversampling: 16x

  - platform: bme280
    address: 0x77
    update_interval: 60s
    iir_filter: 16x
    temperature:
      name: "temperature(sun)"
      id: bme280_temperature_sun
      oversampling: 16x

  - platform: adc
    id: source_sensor
    pin: A0
    name: ADC
    #attenuation: 11db
    internal: true
    update_interval: 5s
    accuracy_decimals: 3
    filters:
    # - multiply: 3.3 ##built into Wemos
    # - multiply: 0.0009775171   #1/1023
    # - multiply: 0.846153 # 3.9 -> 3.3V

  - platform: resistance
    sensor: source_sensor
    id: resistance_sensor
    configuration: DOWNSTREAM
    resistor: 10kOhm
    internal: true
    name: Resistance Sensor
    #reference_voltage: 3.9V
    accuracy_decimals: 1
    filters:
      #- median:
      #    window_size: 7
      #    send_every: 4
      #    send_first_at: 3
      - heartbeat: 90s
    on_value:
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 3132
              below: 3200
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "N"
            - sensor.template.publish:
                id: wind_heading
                state: 0.0
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 1600
              below: 1700
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "NE"
            - sensor.template.publish:
                id: wind_heading
                state: 45.0
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 250
              below: 350
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "E"
            - sensor.template.publish:
                id: wind_heading
                state: 90.0
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 550
              below: 650
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "SE"
            - sensor.template.publish:
                id: wind_heading
                state: 135.0
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 900
              below: 1100
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "S"
            - sensor.template.publish:
                id: wind_heading
                state: 180.0
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 2300
              below: 2450
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "SW"
            - sensor.template.publish:
                id: wind_heading
                state: 225.0
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 3900
              below: 4100
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "W"
            - sensor.template.publish:
                id: wind_heading
                state: 270.0
      - if:
          condition:
            sensor.in_range:
              id: resistance_sensor
              above: 3500
              below: 3800
          then:
            - text_sensor.template.publish:
                id: wind_dir_card
                state: "NW"
            - sensor.template.publish:
                id: wind_heading
                state: 315.0

  - platform: template
    name: "Wind heading"
    id: wind_heading
    unit_of_measurement: "°"

text_sensor:
  - platform: template
    name: "Wind cardinal direction"
    id: wind_dir_card

interval:
  - interval: 60s
    then:
      - sensor.integration.reset: rain_per_min

# Enable time component to reset energy at midnight
time:
  - platform: sntp
    timezone: "Europe/Copenhagen"
boelle commented 3 years ago

i understand that rain per minute and daily rain are reset, but does the above work as a rain in total that is only reset if mcu is reset(power cycle)

The integration will start again at the beginning but is it really a problem? The assembly may reset often?

i plan to power it from 5v usb adapter so if power goes out it will reset

hugokernel commented 3 years ago

Temperature in the sun makes sense when summer starts and you want to know if you need a jacket or t-shirt or you can go topless tor. 23. sep. 2021 16.53 skrev Charles R. @.***>:

I think there are much more reliable ways to measure the temperature felt by taking into account the wind, the humidity (dew point?).

boelle commented 3 years ago

good thinking, that escaped my mind totally

will look in to it straight away since i have nothing better to do

EDIT: https://community.home-assistant.io/t/sensor-of-temperature-feels-like/299063/23

seems that its a bit more involved and that everyone has an opinion, its understandable as some will feel cold pretty quick and it also depends if sun is hitting you or you are in shade