Closed kajmaj closed 6 years ago
Not directly, and it's not clear how useful it would be. 80Hz is actually quite fast for the way counters in Tasmota work. You can setup a counter on a GPIO pin and then send that to NodeRED and with simple math get the frequency over the last period.
(Counter - OldCounter)/(NowInSeconds - OldTimeInSeconds) That will give the average number of pulses over the period.
Do you mean count it "out" of the sonoff and do math there as well? Well, math itself is not a problem. But if I set up teleperiod let say 10 secs - do I receive number of pulses within this period i.e. 800 at 80Hz or 10 at 1Hz etc.? Next 10 secs it will count from 0, or just continue to another value, accumulating value in buffer(or memory if you wish)? First possibility would be good enough. BTW is there any way how to reset counter after teleperiod is over?
You can read all about counters in the wiki https://github.com/arendst/Sonoff-Tasmota/wiki/Commands
I found "pulse Counter or pulse Timer" there in Counters and do not fully understand what does it mean. I learned sofar that, for my purpose, it is enough to have it working as per-period counter. But I do not know (yet) how to achieve it. :(
The best way to learn about these things is to try them out and see how they behave. I am not sure exactly how pulse timer works. It is the inverse of what you requested (frequency) but I have never tried using it. I did look at the code months ago and did not find it particularly useful for my needs. The counter is exactly what it says it is. It keeps a running total of the pulses it has received. If there is a power failure, it can go backwards, since it does not continually update the flash (which would wear it out much faster).
You can pick a gpio pin and set it to counter 1 That will cause it to start counting pulses.
I' m going to start experimenting. I think that it should be possible to reset counter at the end of each telemetry period by a rule. Rules are another unknown (to me) area.
Hi,
The rule to reset a counter every teleperiod is:
rule 1
rule on tele-counter#c1>0 do counter1 0 endon
For more information see https://github.com/arendst/Sonoff-Tasmota/wiki/Rules
Thanks.
Thank you.
edit:
extended your rule to:
rule on tele-counter#c1>0 do publish cmnd/wind/counter1 %value% endon on tele-counter#c1>0 do counter1 0 endon
Now it does exactly what I need.
Rest is math and proper debouncing.
Great!
Thanks a lot for sharing. :+1:
Closing this issue.
Is possible read rpm from 5v 3 wired fan with tasmota? And is possible use pwm to control fan power directly?
Actually, is there any possibility to directly measure frequency - pulses per second - by a sensor connected to any available GPIO of Sonoff ? It might be usefull for RPM, anemometer, speed etc. In my case frequency is within the range between 0 and 80 Hz.