As7341 sensor

I have the sensor as in the instructions.
it works well too
I’m just not clear about this log entry?

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:714
Integration: Sensor (documentation, issues)
First occurred: 22:20:32 (16 occurrences)
Last logged: 22:20:33

Entity sensor.wetterstation_590nm (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
Entity sensor.wetterstation_630nm (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
Entity sensor.wetterstation_680nm (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
Entity sensor.wetterstation_clear (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
Entity sensor.wetterstation_nir (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22<sub>Tex

Please post the yaml for the sensor. Also please use the correct formatting. Logs and yaml should be enclosed by preformatted text tags - these are accessed by using </> on the posting toolbar.

The system is of course always up to date

esphome:
  name: "wetterstation"
  friendly_name: Blitzsensor

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  #level: VERY_VERBOSE
  #hardware_uart: UART1
# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

ota:
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.174
    gateway: 192.168.1.100
    subnet: 255.255.0.0
    dns1: 192.168.1.100 


    # NONE (geringste Energieeinsparung, Standard für ESP8266)

    # LIGHT (Standard für ESP32)

    # HIGH (höchste Energieeinsparung)

  power_save_mode: HIGH  

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Blitzsensor Fallback Hotspot"
    password: "MiiVL8RCAav3"

captive_portal:

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

spi:
- id: spi_bus0
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19


number:
  - platform: template
    name: Stepper Control
    min_value: 0
    max_value: 1024
    step: 1.00
    set_action:
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return x;'


stepper:
  - platform: uln2003
    id: my_stepper
    pin_a: 32
    pin_b: 33
    pin_c: 25
    pin_d: 26
    max_speed: 250 steps/s
    sleep_when_done: true
    step_mode: FULL_STEP               #   HALF_STEP # FULL_STEP # WAVE_DRIVE





sensor:
  
#sensor:
  - platform: tsl2591
    name: "TSL2591"
    id: "my_tls2591"
    address: 0x29
    update_interval: 3s
    gain: auto
    device_factor: 53
    glass_attenuation_factor: 14.4
    visible:
      name: "TSL2591 visible light"
    infrared:
      name: "TSL2591 infrared light"
    full_spectrum:
      name: "TSL2591 full spectrum light"
    calculated_lux:
      id: i_lux
      name: "TSL2591 Lux"
    actual_gain:
      id: "actual_gain"
      name: "TSL2591 actual gain"

  
# Example shared configuration


#sensor:
  - platform: ltr390
    i2c_id: bus_a
    address: 0x53
    update_interval: 5s
    window_correction_factor: 2.0
    resolution: 20
    gain: X3

    uv:
      name: "UV counts"
    light:
      name: "Light"
    ambient_light:
      name: "Ambient counter"
    uv_index:
      name: "UV index"    

#sensor:
  - platform: sht3xd
    i2c_id: bus_a
    address: 0x44
    heater_enabled: True
    update_interval: 7s  
    temperature:
      name: "Luft Temperatur"
      id: air_temperature
    humidity:
      name: "Luftfeuchte"
      id: relative_humidity

#sensor:
  - platform: absolute_humidity
    name: Absolute Luftfeuchte
    temperature: air_temperature
    humidity: relative_humidity
    equation: Wobus  
#sensor:
  - platform: max44009
    i2c_id: bus_a
    name: "Lichtleistung"
    mode: auto
    address: 0x4A
    update_interval: 3s    

             


#sensor: #station status
  - platform: internal_temperature
    name: "Interne Temperatur"
    update_interval: 5s
    unit_of_measurement: "°C"
    device_class: "temperature"    
    accuracy_decimals: 2  
    entity_category: "diagnostic"                      

#sensor:
  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"  

  - platform: uptime
    name: Betriebszeitsensor
    update_interval: 60s
    entity_category: "diagnostic"



#0-Kanal Licht-/Farbsensor
  - platform: as7341
    i2c_id: bus_a
    gain: X8
    astep: 599
    atime: 29
    
    f1:
     name: "415nm"
    f2:
     name: "445nm"
    f3:
     name: "480nm"
    f4:
     name: "515nm"
    f5:
     name: "555nm"
    f6:
     name: "590nm"
    f7:
     name: "630nm"
    f8:
     name: "680nm"
    clear:
     name: "Clear"
    nir:
     name: "NIR"
#sensor: #station status end    




  - platform: bme280
    i2c_id: bus_a
    address: 0x77
    update_interval: 5s  
    iir_filter: 16x  
    temperature:
      name: "BME280 Temperature"
      oversampling: 16x
    pressure:
      name: "BME280 Pressure"
      oversampling: 16x
    humidity:
      name: "BME280 Humidity"
      oversampling: 16x




missing unit_of_measurement in the as7341 sensor area

unit_of_measurement: nm

this sensore measures the spectrum of light not LUX as far as i know

Yes, that’s right, I took that 1:1 from the documentation
The display is in a standard statistics chart card configuration

  - platform: as7341
    i2c_id: bus_a
    gain: X8
    astep: 599
    atime: 29
    
    f1:
     name: "415nm"
    f2:
     name: "445nm"
    f3:
     name: "480nm"
    f4:
     name: "515nm"
    f5:
     name: "555nm"
    f6:
     name: "590nm"
    f7:
     name: "630nm"
    f8:
     name: "680nm"
    clear:
     name: "Clear"
    nir:
     name: "NIR"

Everything works, but there are warnings in the core protocol

 Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:714
Integration: Sensor (documentation, issues)
First occurred: 31. Januar 2024 um 13:23:55 (17 occurrences)
Last logged: 31. Januar 2024 um 17:08:42

    Entity sensor.wetterstation_630nm (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
    Entity sensor.wetterstation_680nm (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
    Entity sensor.wetterstation_clear (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
    Entity sensor.wetterstation_nir (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement '#' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
    Entity sensor.bewegungmelder_light (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22

well sometimes you cant just take the code from documentation 1:1 bc things change.
the error clearly says that you cant use only a number value “#” or “none” you need to define a unit_of_measurement for each sensor from f1 to nir

ex:
f1:
name: “415nm”
unit_of_measurement: nm

if everything works you sould have a light spectrum graph, how did u archive that?
can you post a screenshot of it?
If everything works you should report this as a bug!

chart_type: line
period: 5minute
type: statistics-graph
entities:
  - sensor.wetterstation_415nm
  - sensor.wetterstation_445nm
  - sensor.wetterstation_480nm
  - sensor.wetterstation_515nm
  - sensor.wetterstation_555nm
  - sensor.wetterstation_590nm
  - sensor.wetterstation_630nm
  - sensor.wetterstation_680nm
  - sensor.wetterstation_clear
  - sensor.wetterstation_nir
stat_types:
  - mean
hide_legend: true

I will deal with each value individually on Monday
Unfortunately I have to work on the weekend

https://ams.com/documents/20143/36005/AS7341_DS000504_3-00.pdf/5eca1f59-46e2-6fc5-daf5-d71ad90c9b2b
I can’t figure it out from the datasheet
The measuring range is clear, but what kind of values come out of it
I think you have to look at this like a miscalculation

The value of the sensor are photons.

ex. at 415nm wavelength = 40000 photos

Thanks, I could hardly imagine that such a cheap sensor could do that

  - platform: as7341
    i2c_id: bus_a
    gain: X8
    astep: 599
    atime: 29
    
    f1:
     name: "415nm"
     unit_of_measurement: "y"
    f2:
     name: "445nm"
     unit_of_measurement: "y"
    f3:
     name: "480nm"
     unit_of_measurement: "y"
    f4:
     name: "515nm"
     unit_of_measurement: "y"
    f5:
     name: "555nm"
     unit_of_measurement: "y"
    f6:
     name: "590nm"
     unit_of_measurement: "y"
    f7:
     name: "630nm"
     unit_of_measurement: "y"
    f8:
     name: "680nm"
     unit_of_measurement: "y"
    clear:
     name: "Clear"
    nir:
     name: "NIR"
     unit_of_measurement: "y"

Now I just used “Gamma”.
The error message in the log has disappeared
But it doesn’t matter what you use

I’ll think about a better evaluation/display
The task of the sensor should be a daylight analysis

We cannot be sure of exact measurement unit. Definitely its photons engaging electrons related ) It would be great if its Quantums of photons.

  1. Datasheet is written by crippled ugly monsters to make people’s life more complex. It has many unclear things and many important things split between 10 different documents.
  2. Readings are unitless ADC counts which - as per datasheet - represent irradiance.
    For each channel there is different ratio between irradiance (in W/m2) and number of counts.
  3. Number of counts also affected by current selected gain (x1, x2, x4…) ratio and integration time
  4. To get value not related to particular time and gain there is concept of BasicCounts = AdcCounts / (Gain ratio x Integration time in ms)
    Integration time in ms = (astep+1)x(atime+1)x2.78us/1000.
  5. to get ratios for (1) check datasheet section 6. for each band there is typical number of counts for particular radiance.
    for example band F3: 210 counts per 107.67μW/cm2 = 1.95 counts per μW/cm2 FOR GAIN: 64x, Integration Time: 27.8ms!!! it shall be converted to basic counts → 210/(64*27.8) = 0.1180. So the ration is 0.1180 basic counts for 107.67 uW/cm2 :slight_smile: means 1 basic count = 912.45 uW/cm2
  6. SATURATION. Sensor easily gets saturated, not sure this component exposes that. There is STATUS Register (Address 0x93) in the device which shall be read to get this info. When saturated - data is wrong and unusable.
  7. Haha. Saturation can be analog :)))) sensor is overwhelmed :slight_smile: and digital - adc is too happy. ADC value shall not be more than (atime+1)x(astep+1), in another case its unreliable.
  8. happy reading :slight_smile:
1 Like