LaskaKit / ESP-Vindriktning

Other
82 stars 16 forks source link

Pm1006 measurement fails with basic example #19

Closed markuswebert closed 7 months ago

markuswebert commented 7 months ago

Hi,

I own two VINDRIKTNING ESP v3 boards and two IKEA sensors. When replacing the original board with the laskakit v3 (running the VINDRIKTNING.ino flashed via Arduino IDE) and connecting the pm1006 sensor (power and fan cables), I am not able to read the sensor measurements while starting am stopping the fan as well as reading the ambient light value seems to work. When reading the pm1006 sensor, the log always states Fan ON, measurement failed, fan off.

In the arduino IDE, I set the board ESP32 DEV Module. I also tried both laskakit boards with both ikea sensors.

Do you have a hint for me on how to solve that? Thanks!

Bascht74 commented 7 months ago

I am using this configuration for esphome

substitutions:
  devicename: luftegwohnzimmer
  upper_devicename: Luftsensor EG Wohnzimmer
  device_description: "IKEA LaskaKit ESP-VINDRIKTNING ESP-32 I2C"

globals:
   - id: max_brightness
     type: float
     restore_value: no
     initial_value: '0.5'
   - id: min_brightness
     type: float
     restore_value: no
     initial_value: '0.1'

esphome:
  name: ${devicename}
  friendly_name: ${upper_devicename}
  comment: "${device_description}"
  on_boot:
    priority: 240
    then:
        - light.turn_on:
            id: status
            brightness: 0%

esp32:
  board: nodemcu-32s
  framework:
    type: esp-idf

logger:
  baud_rate: 0

api:
  reboot_timeout: 240min
  encryption: 
    key: !secret encryption_key

ota:
  password: !secret ota_password

wifi:
  reboot_timeout: 10min
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  use_address: 192.168.175.237

uart:
  rx_pin: 16
  tx_pin: 17
  baud_rate: 9600
  id: uart_2

i2c:
  sda: 21
  scl: 22
  scan: true
  id: bus_a

sensor:
  - platform: homeassistant
    id: sun_elevation
    entity_id: sun.sun
    internal: true
    attribute: elevation

  - platform: pm1006
    uart_id: uart_2
    update_interval: 20s
    pm_2_5:
      name: "PM 2.5µm"
      id: pm
      state_class: "measurement"
      device_class: "pm25"
      unit_of_measurement: 'µg/m³'
      accuracy_decimals: 0
      filters:
        - throttle_average: 120s
      on_value:
        then:
        - if:
            condition:
              lambda: 'return x < 30;'
            then:
              - light.addressable_set:
                  id: status
                  range_from: 0
                  range_to: 0
                  red: 0.0
                  green: 1.0
                  blue: 0.0
                  color_brightness:  !lambda |-
                    return id(sun_elevation).state > 0 ? id(max_brightness) : id(min_brightness);
            else:
            - if:
                condition:
                  lambda: 'return x > 90;'
                then:
                - light.addressable_set:
                    id: status
                    range_from: 0
                    range_to: 0
                    red: 1.0
                    green: 0.0
                    blue: 0.0
                    color_brightness:  !lambda |-
                      return id(sun_elevation).state > 0 ? id(max_brightness) : id(min_brightness);
                else:
                - light.addressable_set:
                    id: status
                    range_from: 0
                    range_to: 0
                    red: 1.0
                    green: 0.72
                    blue: 0.0
                    color_brightness:  !lambda |-
                      return id(sun_elevation).state > 0 ? id(max_brightness) : id(min_brightness);
        - switch.turn_on: fan_delay

  - platform: scd4x
    co2:
      name: "CO2"
      state_class: "measurement"
      device_class: "carbon_dioxide"
      unit_of_measurement: "ppm"
      accuracy_decimals: 0
      filters:
        - throttle_average: 120s
      id: co2
      on_value:
        then:
        - if:
            condition:
              lambda: 'return x < 1000;'
            then:
              - light.addressable_set:
                  id: status
                  range_from: 1
                  range_to: 1
                  red: 0.0
                  green: 1.0
                  blue: 0.0
                  color_brightness:  !lambda |-
                    return id(sun_elevation).state > 0 ? 1.0 : 0.5;
            else:
            - if:
                condition:
                  lambda: 'return x > 1500;'
                then:
                - light.addressable_set:
                    id: status
                    range_from: 1
                    range_to: 1
                    red: 1.0
                    green: 0.0
                    blue: 0.0
                    color_brightness:  !lambda |-
                      return id(sun_elevation).state > 0 ? 1.0 : 0.5;
                else:
                - light.addressable_set:
                    id: status
                    range_from: 1
                    range_to: 1
                    red: 1.0
                    green: 0.72
                    blue: 0.0
                    color_brightness:  !lambda |-
                      return id(sun_elevation).state > 0 ? 1.0 : 0.5;

    humidity:
      name: "Luftfeuchtigkeit" 
      id: humidity
      state_class: "measurement"
      device_class: "humidity"
      unit_of_measurement: '%'
      filters:
        - throttle_average: 120s
      on_value:
        then:
        - if:
            condition:
              lambda: 'return x < 30;'
            then:
              - light.addressable_set:
                  id: status
                  range_from: 2
                  range_to: 2
                  red: 1.0
                  green: 0.0
                  blue: 0.0
                  color_brightness:  !lambda |-
                    return id(sun_elevation).state > 0 ? 1.0 : 0.5;
            else:
            - if:
                condition:
                  lambda: 'return x > 60;'
                then:
                - light.addressable_set:
                    id: status
                    range_from: 2
                    range_to: 2
                    red: 0.0
                    green: 0.0
                    blue: 1.0
                    color_brightness:  !lambda |-
                      return id(sun_elevation).state > 0 ? 1.0 : 0.5;
                else:
                - light.addressable_set:
                    id: status
                    range_from: 2
                    range_to: 2
                    red: 0.0
                    green: 1.0
                    blue: 0.0
                    color_brightness:  !lambda |-
                      return id(sun_elevation).state > 0 ? 1.0 : 0.5;
    temperature:
      name: "Temperatur"
      state_class: "measurement"
      device_class: "temperature"
      unit_of_measurement: '°C'
      filters:
        - throttle_average: 120s

button:
  - platform: restart
    name: Restart
    disabled_by_default: true
    entity_category: diagnostic

switch:
  - platform: gpio
    pin: 12
    id: fan
    internal: true
    restore_mode: ALWAYS_ON
    disabled_by_default: true
    entity_category: diagnostic

  - platform: template
    entity_category: diagnostic
    disabled_by_default: true
    internal: true
    id: fan_delay
    turn_on_action:
      - switch.turn_off: fan
      - delay: 50s
      - switch.turn_on: fan

light:
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    chipset: WS2812
    internal: true
    rmt_channel: 0
    pin: GPIO25
    num_leds: 3
    id: status
markuswebert commented 7 months ago

Choosing the right board (nodemcu-32s) did the trick! Thanks @Bascht74 for sharing your config!

Maybe it is worth adding this to the readme? Seems to be relevant for both ESPHome and Arduino.

Konstantin-G commented 7 months ago

added, thanks