-
Notifications
You must be signed in to change notification settings - Fork 114
Pulse counter #165
Comments
Yes, it is possible: sensor:
- platform: pulse_counter
filters:
- lambda: |-
static float total_value = 0.0;
// 0.25 because of update_interval 15s
total_value += x * 0.25;
return total_value; The acceleration would be more or less the same, but I'll leave it as an exercise to the reader :P |
Yes, Lambda can convert from "pulse/min" to "Total pulse count". Saying, I can only get one of them, I got this, I lost that. But my request is: The sensor provides two or three values that they represent different meaning at the same time. |
Ok, now I understand, so you want to have all three units show up as sensor at the same time. sensor:
- platform: pulse_counter
name: "Pulses per minute"
id: pulse
filters:
- platform: template
name: "Total pulses"
lambda: |-
static float total_value = 0.0;
// 0.25 because of update_interval 15s
total_value += id(pulse).value * 0.25;
return total_value;
- platform: template
name: "Pulse Acceleration"
lambda: |-
// ... In pure C++ it would be similar, just with the use of the |
I am not able to use Yaml right now. I read a lot source code of
|
I got it .
|
I am using pulse sensor, the value unit is "pulse/min". I hope there are two measure unit. First is "Total pulses count" ,it is for "How many pulses the sensor has caught". Second is "Rate/Ratio", Just same requirement as currently what the pulse sensor is doing. Further more, I want the third value like "Acceleration", to show how much it's going faster/slower.
I tried to modify the code, But it should be one GPIO connected, Like the behavior of DHT-11, two sensors with one wire. This will be a challenge for me. @OttoWinter , Do you think my idea is doable?
I know we should consider about the counter overflow, power-down, might be other troubles I don't know right now.
BTW: one document error at https://esphomelib.com/api/sensor/pulse_counter.html at "Example usage"
the mqtt is wrong, should be pcnt.
The text was updated successfully, but these errors were encountered: