I use a TCRT5000 to read the IR-diode from my EMH power meter. The manual of the power meter says, every light impulse is 2 ms and 10000 Imp/kWh.
So I installed the TCRT5000 in front of the IR diode. With help of the poti and the onboard output-LED I was able to change the sensitivity of the reading-diode to the correct level. The output LED on the board blinks regularly, depending on my energy consumption.
Somehow, not every impulse from the TCRT5000 gets to my ESP8266. I double-checked it with an additional LED that is connected to the ESP and the logs. Just 1 of 3 or 1 of 5 impulses of the TCRT5000 is registered by the ESP on no regular basis.
A pullup resistance is not necessary because the TCRT has one integrated.
On the same ESP I use almost the same code to read a gas meter with a reed switch. I filter this input with a delay of 10 ms. Deactivation of the filter did not change a thing.
Do you have a hint for me? Here is my config.
globals: # Stromzähler - id: total_pulses_power type: int restore_value: false initial_value: '0' # Stromzähler Pin D2 binary_sensor: - platform: gpio id: internal_pulse_counter_power pin: number: GPIO4 # mode: INPUT_PULLUP name: "Live-Impuls-Power" # filters: # - delayed_on: 1ms on_press: then: - lambda: id(total_pulses_power) += 1; - output.turn_on: led_power on_release: then: - output.turn_off: led_power sensor: # Stromzähler - platform: template name: "Stromverbrauch" device_class: power unit_of_measurement: "Wh" state_class: "total_increasing" icon: "mdi:flash" accuracy_decimals: 3 lambda: |- return id(total_pulses_power) * 0.1; output: # Stromzähler Pin D4 - platform: gpio pin: GPIO2 id: 'led_power'