Re: [PATCH] iio: light: veml6075: fix UV index reported at half value

From: Andy Shevchenko

Date: Fri Jun 26 2026 - 08:22:51 EST


On Fri, Jun 26, 2026 at 04:34:00PM +0530, Shardul Deshpande wrote:
> veml6075_get_uvi_micro() normalises the UV index for the configured
> integration time by dividing the summed, responsivity-weighted UVA/UVB
> components by the integration-time scale factor relative to the 50 ms
> base case (which is returned undivided).
>
> The supported integration times are 50, 100, 200, 400 and 800 ms, i.e.
> the register field index int_index in 0..4 selects (50 << int_index) ms,
> so the correct scale factor is 2^int_index == (1 << int_index).
>
> The code instead divides by (2 << int_index) == 2^(int_index + 1), which
> is twice the correct value. The reported UV index is therefore half of
> the true value for every integration time except 50 ms (handled as a
> separate case). As the driver powers up with VEML6075_IT_100_MS, the UV
> index is reported at half value out of the box.
>
> Divide by (1 << int_index) instead; this also matches the undivided
> 50 ms case (1 << 0 == 1).

Can you add more datasheet references to this?
Also I assume you possess such a sensor and you have seen this IRL, correct?


--
With Best Regards,
Andy Shevchenko