Open collector

And emoncms will detect when the switch changes its state? Or do i need to change something on emoncms configuration to see the input?

Thanks!
Celso

EDIT: Forguet that!
With a little more time to read the pulses.py script, i can now understand more about how it works.

By the way, node-red has a node that receives a state change from digital input on a selected pin. I am exploring it to receive state change on gpio pin 13 since is more easy for me, as i don’t understand much of programing.
Just don’t know what means the “HTTP Issue” and how to acumulate the raw pulse, i don’t know yet how to do it.

Here is some screenshots:

What do you think, Paul?

Regards
Celso

Sorry you’re asking the wrong person there, I don’t know much about using node-red.

@Paul might be able to help you.

Regards accumulating pulses in emoncms you should look at using a “whaccumulator” or a “total pulse count to pulse increment” process if there is any chance of the pulsecount ever resetting eg a reboot or power outage or variable rollover. These 2 processes have a “ratchet” type input so that the difference between the current and last pulsecount is added to the persisted running total rather than using the live running total.

Ah I see that you are using the ‘node-red emoncms’ node!
I personally do not use it as it doesn’t work well at the moment, and others are finding the same problem as you, see Node-red error with update
You could log an issue in the git repo for that node if you wish.

Paul

Thanks @pb66
I change it to a whaccumulator now.

Regarding the script, how do i install it on the rpi? Since i don’t know how to transfer it to the rpi i tryied to login by ssh, create a file pulses.sh and running it but i got some errors.
Then i login by ssh on my ubuntu files manager but don’t know where to put the script and i don’t find any reference about the place where i shall put the script and run it.
I can login as ssh on my pc file manager and see the rpi folders but don’t know where to put the script.

@Paul
Appart from the http issue, i still get the input info to emoncms localhost and emoncms.org, so, for now, everything is fine, from what i can see.
I must say, its way more easy to use node red from a newbie perspective but i would like to try it from the both ways.

Thank you both for the help!

Sorry @pb66 but i have been trying to use the script but really don’t know how to install it.
Can you tell me what commands do i need to use?
Sorry bothering you again with this.

Best Regards

The pulses.py file is Python not Bash/Shell. so it needs the “.py” extension, not “.sh”.

Try this

using wget download the file from the forum to your home folder and rename it pulses.py, then make it and executable file with chmod

wget -O ~/pulses.py https://community.openenergymonitor.org/uploads/default/original/2X/b/b7b150dec028e86f25d5a6e4b0a959e4a774448f.txt
chmod +x ~/pulses.py

You can edit the script with nano if you need to change pin numbers etc

nano ~/pulses.py

Then you should have a working pulses.py script that can be run with

~/pulses.py

To stop the script use CTRL-C

In the script there are some print statements commented out with a hash at the beginning of the line, whilst getting set up and debugging you can edit the file using nano to comment/uncomment those lines and the data will be output to screen when run from the commandline.

In the above instance, closing your shell console (ssh or login screen) will terminate the script. You can as a temporary thing start the script will

~/pulses.py&

make a note of the PID number that command gives you as you need that to terminate the script at a later date with a command like

sudo pkill -9 123

where “123” is the PID number of pulses.py

Eventually you will want to start this as a daemon service so that the OS manages it’s start up at boot time etc.

I will try to write a post on that in the coming days I do not have anything prepared and you are not the first to ask so I will try and find the time to put something together. But the above should get you started at least.

Thanks.
A few weeks i was able to make it work but now , on a new installation, it guives this error on terminal:
File “/home/pi/pulses.py”, line 118, in
main()
File “/home/pi/pulses.py”, line 103, in main
GPIO.add_event_detect(pulse_pin1, GPIO.BOTH, callback=eventHandler1, bouncetime=bounce)
RuntimeError: Failed to add edge detection

Any idea why?
Note: I didn’t edited the script.

No sorry I don’t, i just had a quick web search and found nothing that stands out. You check you do not have other stuff trying to use the same gpio pins and check the pin numbers you are using are correct.

Thanks.
I already search it too and couldn’t find anything either.
I will try to find out why and will report it here.
Regards
Celso