LDR in power meter

Hi.
I’m new to HA and also to ESPHome. I’m trying to create this “Home Assistant Glow” as descriped in this github repo https://github.com/klaasnicolaas/home-assistant-glow#faq

I’m tyring to get a witty cloud ESP8266 work with this setup as it has a build-in LDR. I have the LDR working on A0 (analog) as a stand-alone input. But when I try to use the A0 pin on as the “pulse_pin” I get an error message saying: “GPIO17 (TOUT) is an analog-only pin on the ESP8266”.

So how do I convert or get the LDR to input on the power_meter sensor?

Thanks in advance for any help I can get!


substitutions:
  pulse_pin: A0 #GPIO14

# LDR Light Sensor
sensor:
  - platform: adc
    pin: A0
    id: 'LDR_1'
    name: "ESP8266 ESP-12E Brightness"
    update_interval: 10s
    filters:
      - multiply: 3.3

# Pulse meter
  - platform: pulse_meter
    name: '${friendly_name} - Power Consumption'
    id: sensor_energy_pulse_meter
    unit_of_measurement: 'W'
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    accuracy_decimals: 0
    pin: ${pulse_pin}
    # internal_filter: 100ms

You can’t (at least not without more tinkering). You would need a digital pin (which is ether high or low) and not a analog one you a trying to make use of.

Think about it that you want to detect if the light is on or off but on the other hand your a not interesting at all in the particular light level. Your setup (LDR on a analog pin) is more to estimate brightness levels but doesn’t give the output you need for a pulse meter.

Btw. your link even mentions that A0 is not used: https://github.com/klaasnicolaas/home-assistant-glow#photodiode

Photodiode

How the photodiode is connected to the ESP board of your choice.

PHOTODIODE ESP32 Wemos D1 / ESP8266
A0 NOT USING NOT USING
DO D12 (GPIO12) D6 (GPIO12)
VCC 3V3 3V3
GND GND GND

I did not know if this also applyed to the witty cloud as it’s an other type of board. But I guess it dose :frowning: I’ll get the parts used in the project.

Thanks for verifying that I can’t use the board I have.

You can still use your witty cloud (essentially a esp82xx) for that use case. You only need to invest a dollar or a half one for a sensor mentioned in the github (TCRT5000 for example) that you can connect to your witty thingy (follow the d1 mini / esp8266 instructions) and you should be good to go :rocket: