Illuminance sensor with ldr: how to get lux value?

Hi everyone,
I’m throwing my bottle into the sea, after multiple vain tests…
I have installed tasmota 6.6.0 on wemosd1 mini board, And connected a 1wire sensor for illuminance. That’s an ldr connected to lm393 comparator, connected to the A0 pin, tasmota uses the sonoff-sensors bin file. Tasmota gives me a value ranging from 0 (full light) to 65535 (total dark).
Is there a way to convert the value in tasmota to get a value in lux? If not, can I simply convert the analog data into lux within HOME ASSISTANT?

Felix

Yes do that. You’ll need to look at the chip’s documentation to see how.

Hi Nick, I’ve never done this in home assistant. Can you tell me where and how you enter a formula based on input value from the sensor? Any example, just to understand where it lies.
Thanks a lot!!
Best regards, felix

Templating is the answer, see https://www.home-assistant.io/docs/configuration/templating/

So basically set up a sensor that reports the value from tasmota (0-65535) (that should be automatic) and a template sensor that takes the state from the first sensor and applies the formula.

Thanks for the pointer…! Never used templates before, that’s why… so far my ha never needed it. I’ll read the doc. Many thanks Nick!!
Felix

The other way to do it would be to use esphome. It is very integrated with home assistant, and you could to the conversion on the esp chip. But I don’t want to confuse you if you already have tasmota running :slight_smile:

Well I know I will have to look at esphome at some point, because every two responses point to that new way. It would be indeed much easier to plug the formula into the d1mini firmware. I admit I’m a bit slow to digest new stuff…
Many thanks again for taking time for me.!!
All the best!

Hi Nick, I started with Esphome, and just for info, it works like a charm, and I became a fan of that new programming approach (in comparison to customizing Tasmota).
Thanks for the tip!!

1 Like

apologies for the thread necromancy, but I don’t suppose you still have the esphome yaml etc for this sensor do you ? and how to convert to lx or a better meaningful value?

You’ll need the datasheet for your LDR. Alternatively if you have some arduino code that we could get some ideas from?