I am considering connecting a raspberry PI 3B+ to a gate controller's RPM sensor. This sensor outputs a square wave at about 100 Hz at its maximum speed. My question is, how can I count these using node-red?
You will need the
GPIO node and set a pin as an input.
When the pin sees something change at its input it makes a message.
I'm not saying this will work, but....
Then install this guy: A handy node.
Take its output and see what you get.
Thanks. That node might be useful. My goal is to count the pulses, then determine the position of the gate by the pulse count. I guess my main question is, can node red see and count pulses at a GPIO pin at 100 Hz without missing pulses? I know that a Raspberry Pi can see pulses at a much faster rate, but not sure about node red.
I suspect that may be pushing it. You would probably be better to either run a dedicated app in a separate thread that reported back to Node-RED or use dedicated hardware like an esp chip that runs more realtime and report via network or serial etc..
Worth a try though, may work on the faster pi
Why not put the logic in the Pi to count the pulses and have it report the controller's position to NR? You don't say what position(s) you are interested in but it seems to me that you could count/calculate the number of pulses between each and report those positions.
I was hoping do everything in node-red if possible. I have limited experience in Python and am not sure how I would interface the python script to node-red. Its starting to look like it might be the best way.
Are you saying that is the only language you have experience with? Or that you think it's the only option on the Rpi? You can actually use any language on the Rpi.
I personally use shell scripts to publish to an MQTT broker and then I subscribe to those topics with the MQTT nodes in NR. My needs in this area are simple and the scripts are only a few lines. YMMV
I am not a professional programmer. I don't know what MQTT is. I don't know what YMMV is. I have some C++ experience from many years ago. I have written a few python scripts. I am using node-red to avoid programming. That's what I thought it was for. Thanks for the help.
It's a publish/subscribe messaging system. Quite simple actually and widely used in both home and industrial environments. I don't want to overload you so I'll leave it at that.
Your Mileage May Vary
Thanks, I have some reading to do. And I am not a complete dumbass, really.
Certainly not! You asked the question...a fool would not.
Marty, I see this a lot - folk shying away from MQTT because they "dont know it".
It is super simple and most definitely worth taking 5 minites to have a play. Seriously, if you have any knowledge of computers and programming, you will pretty much grasp the basics of MQTT in 5 minutes.
check out this post I did for someone else.
Once you have the basic understanding of publish (sending something) and subscribe (receiving something), it is worth reading up on MQTT to understand the finer points (like topic naming conventions etc) but I just want to say, dont shy away - it really is very very simple to utilise.
Thanks guys. I will give it a look. Thanks again for your help.