Hello everyone. I am struggling with adding a home made ambient light sensor into ESPHome in Home Assistant. I have spent hours looking for code to drop into my yaml editor in order to read the feedback on the appropriate pin, but none of the examples match my use case, which is surprising. Anyway, here are some details:
Espressif ESP32Dev board
Sunfounder photoresistor module with the words “MH-Sensor_Series” on the back.
Analog out from the module is attached to D33 on the ESP board.
The circuit functioned properly with Arduino IDE written to it, returning values between 0 and 4000ish printed to the serial monitor, so I have proof of concept.
I managed to get the module installed into ESPHome and it shows up as online through the web UI in addons with only firmware as the single entity.
Yaml is as follows:
esphome:
name: esphome-web-180ce8
friendly_name: ESPHome Ambient Light Sensor 1
min_version: 2025.9.0
name_add_mac_suffix: false
esp32:
variant: esp32
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
What I don’t know is how to code to retrieve (and probably log?) the feedback in order to be useful. I think I understand that it has to do with the following coding:
sensor
- platform:
name:
address:
update_interval:
…but I don’t know how to apply it using my hardware setup.
I have some controls background in my field of employment, but most of it doesn’t really transfer well. Any help would be wonderful.