Hypfer / esp8266-vindriktning-particle-sensor

Wifi MQTT Data Logging via an esp8266 for the Ikea VINDRIKTNING PM2.5 air quality sensor
Apache License 2.0
1.18k stars 128 forks source link

No mqtt topic is visible #60

Closed mStirner closed 1 year ago

mStirner commented 1 year ago

I use MQTT Explorer & mosquitto broker. However, i cant see the mqtt topic "air-sensor/sensor/particulate_matter_25m_concentration/state" grafik

What do i have todo that i can see the values? Are they values/topics only published if the hardware reading is possible. Because my wiring is wrong i dont even see the topic?

Logging seems good to me, but there isnt any measurement either.

[17:18:23][C][logger:293]: Logger:
[17:18:23][C][logger:294]:   Level: DEBUG
[17:18:23][C][logger:295]:   Log Baud Rate: 0
[17:18:23][C][logger:296]:   Hardware UART: UART0
[17:18:23][C][uart.arduino_esp8266:102]: UART Bus:
[17:18:23][C][uart.arduino_esp8266:104]:   RX Pin: GPIO3
[17:18:23][C][uart.arduino_esp8266:106]:   RX Buffer Size: 256
[17:18:23][C][uart.arduino_esp8266:108]:   Baud Rate: 9600 baud
[17:18:23][C][uart.arduino_esp8266:109]:   Data Bits: 8
[17:18:23][C][uart.arduino_esp8266:110]:   Parity: NONE
[17:18:23][C][uart.arduino_esp8266:111]:   Stop bits: 1
[17:18:23][C][uart.arduino_esp8266:113]:   Using hardware serial interface.
[17:18:23][C][pm1006:017]: PM1006:
[17:18:23][C][pm1006:018]:   PM2.5 'Particulate Matter 2.5µm Concentration'
[17:18:23][C][pm1006:018]:     Device Class: 'pm25'
[17:18:23][C][pm1006:018]:     State Class: 'measurement'
[17:18:23][C][pm1006:018]:     Unit of Measurement: 'µg/m³'
[17:18:23][C][pm1006:018]:     Accuracy Decimals: 0
[17:18:23][C][pm1006:018]:     Icon: 'mdi:blur'
[17:18:23][C][pm1006:019]:   Update Interval: never
[17:18:24][C][captive_portal:088]: Captive Portal:
[17:18:24][C][mdns:103]: mDNS:
[17:18:24][C][mdns:104]:   Hostname: air-sensor
[17:18:24][C][ota:093]: Over-The-Air Updates:
[17:18:24][C][ota:094]:   Address: air-sensor.local:8266
[17:18:24][C][ota:097]:   Using Password.
[17:18:24][C][api:138]: API Server:
[17:18:24][C][api:139]:   Address: air-sensor.local:6053
[17:18:24][C][api:141]:   Using noise encryption: YES
[17:18:24][C][mqtt:065]: MQTT:
[17:18:24][C][mqtt:066]:   Server Address: [redacted]:1883 ([redacted])
[17:18:24][C][mqtt:068]:   Username: [redacted]
[17:18:24][C][mqtt:069]:   Client ID: [redacted]
[17:18:24][C][mqtt:074]:   Topic Prefix: 'air-sensor'
[17:18:24][C][mqtt:076]:   Log Topic: 'air-sensor/debug'
[17:18:24][C][mqtt:079]:   Availability: 'air-sensor/status'
[17:18:24][C][mqtt.sensor:027]: MQTT Sensor 'Particulate Matter 2.5µm Concentration':
[17:18:24][C][mqtt.sensor:031]:   State Topic: 'air-sensor/sensor/particulate_matter_25m_concentration/state'

config.yaml

esphome:
  name: air-sensor

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "xxxx"

ota:
  password: "xxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Air-Sensor Fallback Hotspot"
    password: "xxxx"

captive_portal:

# Example configuration entry
uart:
  rx_pin: RX
  baud_rate: 9600

sensor:
  - platform: pm1006
    pm_2_5:
      name: "Particulate Matter 2.5µm Concentration"    

mqtt:
  broker: xxxx
  discovery: true

Board i used with a dc/dc converter for the power supply & voltage divider for the UART TX/RX pin https://www.amazon.de/dp/B074RL7YR3?psc=1&ref=ppx_yo2ov_dt_b_product_details

mStirner commented 1 year ago

Are they values/topics only published if the hardware reading is possible.

My guess where right, its only visible/published after values can/have been read. The problem was i tested it without the sensor attached... :roll_eyes: :facepalm:

[19:15:55][D][sensor:126]: 'Particulate Matter 2.5µm Concentration': Sending state 18.00000 µg/m³ with 0 decimals of accuracy
[19:15:57][D][pm1006:091]: Got PM2.5 Concentration: 18 µg/m³
[19:15:57][D][sensor:126]: 'Particulate Matter 2.5µm Concentration': Sending state 18.00000 µg/m³ with 0 decimals of accuracy
[19:15:59][D][pm1006:091]: Got PM2.5 Concentration: 18 µg/m³
[19:15:59][D][sensor:126]: 'Particulate Matter 2.5µm Concentration': Sending state 18.00000 µg/m³ with 0 decimals of accuracy

grafik

Looks good now and its working :)