letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.28k stars 2.21k forks source link

New device support LTR390-UV-01 #3976

Closed almirus closed 2 years ago

almirus commented 2 years ago

Checklist

I have...

Steps already tried...

Summarize of the problem/feature request

not show any UV information

Expected behavior

UV index

Actual behavior

no UV index

Steps to reproduce

  1. Connect new device via i2c (power + SDA: GPIO-4 (D2) SCL: GPIO-5 (D1))

System configuration

Hardware: ESP32-WROOM-32D and new device LTR390-UV-01 (Datasheet)

ESP Easy version: ESP_Easy_mega_20211224_normal_ESP32_4M316k Dec 24 2021

ESP Easy settings/screenshots: Build:⋄ 20116 - Mega32 System Libraries:⋄ ESP32 SDK v3.3.4-432-g7a85334d8 Git Build:⋄ HEAD_f162ebf Plugin Count:⋄ 47 [Normal] Build Time:⋄ Dec 24 2021 14:57:55 Binary Filename:⋄ ESP_Easy_mega_20211224_normal_ESP32_4M316k Build Platform:⋄ Linux-5.4.0-54-generic-x86_64-with-glibc2.29 Git HEAD:⋄ HEAD_f162ebf

Rules or log data

LOG is empty

image

tonhuisman commented 2 years ago

Is there a specific reason you need this UV sensor? As there are a couple of other supported UV sensors already, check the list of available plugins please.

almirus commented 2 years ago

@tonhuisman Yes, it is true UV sensor

Unlike the Si1145, this sensor will not give you UV Index readings. However, the Si1145 does UV Index approximations based on light level not true UV sensing. The LTR-390, in contrast, does have a real light sensor in the UV spectrum.

VEML6070 support UVA (320-410nm) - measures UV Si1145 use approximation LTR-390 support UVA (280-430nm) - measures UV + ALS

tonhuisman commented 2 years ago

VEML6070 support UVA (320-410nm) - measures UV Si1145 use approximation LTR-390 support UVA (280-430nm) - measures UV + ALS

Well, that range claim is debatable, the documentation shows this range: Screenshot - 26_03_2022 , 09_34_51

So I don't expect the values below 300nm and above 350nm to be very usable.

I've sourced a module from a local supplier, cheaper than from Aliexpress 😮. I'll see if I can create a plugin for this (probably using a library I found that's derived from the Adafruit lib), so I've reserved Plugin ID 133 for this.

almirus commented 2 years ago

lib for waveshare LTR-390 https://gitee.com/inspiration-desktop/DEV-lib-arduino/tree/master/Waveshare_UV_C

tonhuisman commented 2 years ago

I have planned to use this one: https://github.com/RAKWireless/RAK12019_LTR390 as that's based on the Adafruit library, but without using the Adafruit IOBus library (that I'd like to avoid).

almirus commented 2 years ago

So I don't expect the values below 300nm and above 350nm to be very usable.

better than VEML6070 😎 image

almirus commented 2 years ago

ESPHome component (seems to have no dependencies) https://github.com/esphome/esphome/tree/b20760c93c3f8874e0d73d515e0e88d04a7c87aa/esphome/components/ltr390

tonhuisman commented 2 years ago

ESPHome component (seems to have no dependencies) https://github.com/esphome/esphome/tree/b20760c93c3f8874e0d73d515e0e88d04a7c87aa/esphome/components/ltr390

That extends a couple of classes from ESPHome, and would also introduce dependencies, so I'll stick with the Adafruit cloned lib. Have to pull it local anyway because it does I2C initialization, and that is already taken care of by ESPEasy.

tonhuisman commented 2 years ago

@almirus You can test this plugin using the TEST_E builds from the PR linked above (see the Checks tab, on the right side there is an Artifacts dropdown, where you can download Binaries zip-file, that contains a zip-file per build configuration). Please report your findings here 👍

almirus commented 2 years ago

@tonhuisman it looks like works

484054: LTR390: data read. Mode: 1, UV: 1, UVindex: 0.02, ALS: 417, Lux: 83.40
484957: LTR390: data read. Mode: 0, UV: 1, UVindex: 0.02, ALS: 416, Lux: 83.20
485953: LTR390: data read. Mode: 1, UV: 0, UVindex: 0.00, ALS: 417, Lux: 83.40
486953: LTR390: data read. Mode: 1, UV: 0, UVindex: 0.00, ALS: 418, Lux: 83.60
488053: LTR390: data read. Mode: 0, UV: 0, UVindex: 0.00, ALS: 418, Lux: 83.60
489053: LTR390: data read. Mode: 1, UV: 0, UVindex: 0.00, ALS: 418, Lux: 83.60
489953: LTR390: data read. Mode: 0, UV: 0, UVindex: 0.00, ALS: 418, Lux: 83.60
490953: LTR390: data read. Mode: 0, UV: 0, UVindex: 0.00, ALS: 417, Lux: 83.40
492053: LTR390: data read. Mode: 1, UV: 0, UVindex: 0.00, ALS: 418, Lux: 83.60
492978: LTR390: data read. Mode: 0, UV: 0, UVindex: 0.00, ALS: 419, Lux: 83.80
493952: LTR390: data read. Mode: 1, UV: 0, UVindex: 0.00, ALS: 418, Lux: 83.60

maybe it's swapped UV&UVindex?

tonhuisman commented 2 years ago

You can only measure UV outside, as regular window glass filters out most UV. The UVIndex value is calculated using the UV measured value, so no way I swapped them 😆

almirus commented 2 years ago

@tonhuisman not now, sorry, it's rainy today

almirus commented 2 years ago

is UV raw data? UVIndex must be Integer?

tonhuisman commented 2 years ago

The libraries (similar for Adafruit one) return a float value for the calculated values (Lux is also calculated, taking gain and resolution into account. I haven't yet looked up what unit is used for that UV value. The UVIndex value is calculated according to a formula included in the chip documentation.

it's rainy today

You can also measure from inside the house when near an open window, and directing the sensor at the outside light (I'm using a laptop and the ESP + sensor is on a ~1.8m long cable), but don't wait until it gets dark, as then there's no UV 😆

almirus commented 2 years ago

behind window image

without image

TD-er commented 2 years ago

That's remarkable similar in Lux, while it is clearly showing that the window does block some UV. I would expect the window to block more light intensity, but 8 - 10% is less than I expected.

almirus commented 2 years ago

off topic: @tonhuisman What do you think about the need to cover the sensor (small rectangle in the center) on outdoors? I planned to fill most of it with sealant.

tonhuisman commented 2 years ago

What do you think about the need to cover the sensor (small rectangle in the center) on outdoors? I planned to fill most of it with sealant.

That is totally not my area of expertise, you could search for a plastic housing that is transparent to UV, and I'd expect that a sealant could quickly become quite thick when applying, and then block (most) UV.

TD-er commented 2 years ago

Why do you want to block the sensor? If it is to attenuate the light, then you may want to look at those ND filters used in photography/film. Those attenuate for all frequencies in equal amount and have a given attenuation factor.

almirus commented 2 years ago

Why do you want to block the sensor?

@TD-er i wanted this way image

TD-er commented 2 years ago

Not sure about the melting temperature of your sealant. If it is too hot, it may damage components, or even de-solder parts. If it is too low, it may be affected on a sunny day. And since you probably want not to cover the sensor itself, you will still have water entering the circuit.

Maybe you can try to experiment with water repellent spray?