Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cumulative Pulse Width Sensor Request #3009

Open
patrick-kiwi opened this issue Jan 4, 2025 · 4 comments
Open

Cumulative Pulse Width Sensor Request #3009

patrick-kiwi opened this issue Jan 4, 2025 · 4 comments

Comments

@patrick-kiwi
Copy link

Describe the problem you have/What new integration you would like

I’m working on a solar-diverter energy monitor, where I need to add the cumulative daily on-time of a pulsing signal read by a GPIO pin. The pulse-widths to be summed are random and can be as short as 20 ms.

Please describe your use case for this integration and alternatives you've tried:

I’ve tried the “Pulse Meter Sensor” but that only counts the total number of pulses. I’ve also tried the “Pulse Counter Sensor” combined with the “Integration Sensor” but again, this sensor is integrating something with respect to time, which is different to simply adding the pulse-widths. I thought I had the solution when I found the "Pulse Width Sensor" but that sensor only measures single discrete pulses, ie it doesn't accumulate.

Additional context

The source code of the “Pulse Meter Sensor” looks like it’s measuring pulse-widths, but there’s no way of currently getting the daily, hourly, etc. summed up pulse-width’s. Alternatively, it looks like the "Pulse Width Sensor" functionality could be easily extended
@ssieb
Copy link
Member

ssieb commented Jan 5, 2025

Duplicate of #3008

@ssieb ssieb marked this as a duplicate of #3008 Jan 5, 2025
@ssieb ssieb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2025
@patrick-kiwi
Copy link
Author

Hi ssieb why did this get closed so quickly? A cumulative pulse width sensor would be a useful general tool.

@ssieb ssieb marked this as not a duplicate of #3008 Jan 5, 2025
@ssieb
Copy link
Member

ssieb commented Jan 5, 2025

Sorry, you created several duplicate issues and with a quick look, this appeared to be exactly the same as 3008 which you closed.

@ssieb ssieb reopened this Jan 5, 2025
@patrick-kiwi
Copy link
Author

patrick-kiwi commented Jan 24, 2025

If anyone's looking at this, then I've written a pulse_width_accumulate sensor. It works well from 20 microsecond pulses to infinity pulse lengths, (ie no microsecond buffer overflow for >72 minute pulses). Frequency is good up to 1Khz and probably beyond. I'm not so good with github so don't know how to submit it? Here's the yaml to show it working if anyone's is interested:

esphome:
  name: "esphome-web-59b8c4m"
  friendly_name: "esphome-web-59b8c4m"

external_components:
  - source:
      type: git
      url: https://github.com/patrick-kiwi/esphome
      ref: accumulate_4
    components: [pulse_width_accumulate]

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:


sensor:
  - platform: pulse_width_accumulate
    pin: GPIO32
    name: "Accumulated pulse width sensor"
    frequency:
      name: "Optional frequency sensor"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants