ESP32Dev with sunfounder photoresistor module

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.

If you got it working with IDE, you just need to setup ADC sensor.

sensor:
  - platform: adc
    pin: GPIO33
    name: "Ambient light"
    update_interval: 10s
    attenuation: 12dB
    samples: 10

Thank you. I have saved the ESPHome Docs page. This will be gigantically helpful going forward. Knowing what to put in at “platform” is going to take some time to learn.

I’m looking at a graph of the sensor history already. I should be able to use this. :slight_smile:

You’re welcome.
Next step is sensor filters, definitely worth to learn.

Oh, cool. I like the idea of averaging values over a short time for this application. It would reduce a lot of on/off cycles. Neat!