And emoncms will detect when the switch changes its state? Or do i need to change something on emoncms configuration to see the input?
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.
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.
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.
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.
You can edit the script with nano if you need to change pin numbers etc
Then you should have a working pulses.py script that can be run with
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
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.
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
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
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.