I have a LM393 sensor hooked up to an ESP32 dev board and flashed it so it shows up on my network. The light sensor seems to be working fine since I can get the LED to go on or off depending on if I cover it or not.
My problem is getting it detected in Home Assistant. I created a sensors.yaml file and also added the line “sensor: !include sensors.yaml” in the configuration.yaml file.
I assume I need to add some lines in both the sensors.yaml file and the yaml file that gets uploaded to the device but I am not sure what I need to add.
Can anyone point me in the right direction please?
You have to write additional YAML for your sensor. Not familiar with that specific sensor, but just do some googling and perusing the ESPHOME website and I’m sure you’ll be on your way.
Thanks for the info—I’ll check it out.
I simply want to be able to see if I left the lights on in the garage and thought this would be a fun little project to get my feet wet with the ESP32 board.
My LM393 has 3 pins and seems to be working the way I have it wired up. I adjusted the pot so the LED goes out when I cover the sensor. Just not sure how to get that info into HA.
Wired like this: the VCC is going to the 3.3V pin on the ESP, the ground is going to ground and the DO is going to pin 23. I guessed on the DO port so not sure if that’s correct.
We are in the dark (lol)… Please post your YAML file for the device (properly formatted for the forum- use the </> button) and a schematic of how you connected it to the ESP32.
The Texas Instruments LM393 is a dual voltage comparator that is used in lots of breakout boards. For example, Flame Sensor, Humidity Sensor, Sound Sensor, Speed Sensor, Vibration Sensor and light sensor.
To ESPHome, it is simply an analog device. The output of a comparator may drive a transistor giving a digital output to the 4th pin. Or not.
I had to invert the pin because it was reading opposite but it is all good now!
The only minor issue I have is that somehow I ended up with 2 friendly names…it shows up as “garage_light_sensor Garage Light Sensor” so I need to remove the first part but when I edit the yaml file it doesn’t like me to remove that…
could you give me the code you are using for your esphome please ? I’ve been struggling for a couple of days to get my lm393 with lightdiode to work properly with my esp8266 (its previously worked fine with an esp32 i was using it for home assistant glow… but i’ve since repurposed that esp device etc so i can’t go back to it) i simply want it to show the amount of light in the format of voltage (and i can do some fancy filters to change that into lux or something)
i’ve also tried it as a binary sensor but it again, I can’t get it to change regardless of what I try)
Some dont have an analog output and some do. Does yours have a DO pin or AO pin? If it has a potentiometer to adjust the brightness level, it most likely doesnt have AO so you cant measure voltage/light level. Those sensors just output a High or Low signal (ON/OFF) and the potentiometer is how you set the brightness threshold inorder for the sensor to send that On/Off signal.
Your code and presumably your wiring are wrong. You ca nt have the DO pin on the sensor going to 2 gpio pins.
It doesnt do Analog so remove the sensor in your code for adc and remove the wire from pin 17.
If the binary sensor still isnt working, first make sure your on the right pin. GPIO5 is D1 on the esp8266. Are you using 3.3v or 5v to power the sensor?
You can make your own light sensors and theyre super easy and it takes 2 components, an LDR and a resistor
See how it has the option for “3 Pin” and “4 Pin”? The 3 pin is only DO - Digital Out - a.k.a ON/OFF. The 4 pin has DO and AO -Analog Out a.k.a voltage level out.
yeah so mines got 3 pins, connected to a0 and it didnt do much. I’ve given up on my esp8266 for now and hooked same thing up to a spare esp32, I now get LED’s lighting up on the sensor when i put light towards it etc. so its now working fine under esphome. So i’m guessing it was something wonky with the 8266.
but yeah i now realize that i would need the 4 pin version to get some kind of analogue output of voltage. which is a shame, but not that big a deal as I can just tweak the pot to the amount of light needed and use that. its currently reversed (light = OFF) so i’ll have to add that inverted: true line i guess
Theres nothing wonky with the esp8266. The most basic function of any esp board is reading and sending digital signals from its gpio. If it wasnt working with tbat board, then you were doing something wrong, which i why i asked those specific questions. Youve got pins mixed up, a problem with how your powering it…