node-red / node-red-nodes

Extra nodes for Node-RED
Other
986 stars 591 forks source link

node-red-node-pi-gpio pins stopped #750

Open Jamos1988 opened 3 years ago

Jamos1988 commented 3 years ago

Which node are you reporting an issue on?

node-red-node-pi-gpio

What are the steps to reproduce?

Import this flow and in my case the pins are in the "stopped" state. Also when trying to switch, the debug says: nrgpio python command not running

[{"id":"c802d97a.995758","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"8da05ed4.9f81f","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"11","set":true,"level":"0","freq":"","out":"out","x":440,"y":80,"wires":[]},{"id":"81c1cd7c.62e9d","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"12","set":true,"level":"0","freq":"","out":"out","x":440,"y":132,"wires":[]},{"id":"e93b7190.f6715","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"13","set":true,"level":"0","freq":"","out":"out","x":440,"y":182,"wires":[]},{"id":"7a2b0e26.28e2","type":"rpi-gpio out","z":"c802d97a.995758","name":"","pin":"15","set":true,"level":"0","freq":"","out":"out","x":440,"y":234,"wires":[]},{"id":"1fcb30e2.36d20f","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":80,"wires":[["8da05ed4.9f81f"]]},{"id":"4b728ee9.6ee97","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":120,"wires":[["81c1cd7c.62e9d"]]},{"id":"4fa3548e.82336c","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":160,"wires":[["e93b7190.f6715"]]},{"id":"4ce80f4.859d6f","type":"ui_switch","z":"c802d97a.995758","name":"","label":"switch","tooltip":"","group":"ccbcb301.5f66f","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":150,"y":200,"wires":[["7a2b0e26.28e2"]]},{"id":"ccbcb301.5f66f","type":"ui_group","name":"Dashboard","tab":"8715a7c2.f768b8","order":1,"disp":true,"width":"6","collapse":false},{"id":"8715a7c2.f768b8","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

What happens?

All pins, after deploying the flow are in the stopped state. I cannot switch a pin from 0 to 1. debug says nrgpio python command not running

What do you expect to happen?

The pins should not be in a stopped state. I've tried the manual installation and the instructions in the forums https://discourse.nodered.org/t/node-red-node-pi-gpio-output-stopped/38363/4 and https://discourse.nodered.org/t/rpi-gpio-input-node-stopped/5184/8 to no avail.

Please tell us about your environment:

dceejay commented 3 years ago

Which version Pi is this ? Did you use the installation script to install it ? What does which python report and also ls -lart $(which python) ?

Jamos1988 commented 3 years ago

Hi, thanks for answering!

Version Pi: Compute Module CM3 (should be the same as 3b+) Which python outputs: /usr/bin/python ls -lart /usr/bin/python outputs: lrwxrwxrwx 1 root root 7 Mar 4 2019 /usr/bin/python -> python2

dceejay commented 3 years ago

We use board PIN numbers not the gpio BCM gpio numbers so the pins probably aren’t what you think they are.

Jamos1988 commented 3 years ago

Sorry, should've mentioned I've confirmed the pin numbers and measured them. Also using https://www.waveshare.com/compute-module-poe-board.htm so the gpio is mapped identically as a 3b+

It also worked a while back, but some software has been updated, and now I don't know the cause of it.

Jamos1988 commented 3 years ago

Ah, Dceejay, I see that you are the same person as the forum in https://discourse.nodered.org/t/node-red-node-pi-gpio-output-stopped/38363/5

Sorry, didn't recognize you there.

Some more information regarding you previous comment "The error indicates the python app that links to the gpio isn’t running. Usually this because python has got moved or broken. That doesn’t seem to be the case here. Are you running as the pi user ? Or at least the same one you used to install."

I've looked up the scripts in /home/pi/.signalk/red/node_modules/node-red-node-pi-gpio I then tried to execute some of them manually:

python nrgpio.py Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}

I also taken a look at the test script:

python testgpio.py Executing this script gives no output in the terminal.

I'm a bit lost, hope you could point me in the right direction or have any idea of troubleshooting more. Is the main problem that there is something wrong with the python script?

Update: I've also tested a node-red flow, with one gpio-output and just try all of the pins seperately and then deploy the flow. All pins are in stopped state.

dceejay commented 3 years ago

Actually see https://github.com/node-red/node-red-nodes/issues/747 Seems like the CM3 doesn't support BOARD type pins... must be BCM etc...

Jamos1988 commented 3 years ago

Thanks! I've done another test by doing a pinout in the terminal, it outputs:

Revision : a02100 SoC : BCM2837 RAM : 1024Mb Storage : eMMC / off-board USB ports : 1 (excluding power) Ethernet ports : 0 Wi-fi : False Bluetooth : False Camera ports (CSI) : 2 Display ports (DSI): 2

SODIMM: GND (1) (2) EMMC DISABLE N GPIO0 (3) (4) NC / SDX VREF GPIO1 (5) (6) NC / SDX VREF GND (7) (8) GND
GPIO2 (9) (10) NC / SDX CLK
GPIO3 (11) (12) NC / SDX CMD
GND (13) (14) GND
GPIO4 (15) (16) NC / SDX D0
GPIO5 (17) (18) NC / SDX D1
GND (19) (20) GND
GPIO6 (21) (22) NC / SDX D2
GPIO7 (23) (24) NC / SDX D3
GND (25) (26) GND
GPIO8 (27) (28) GPIO28
GPIO9 (29) (30) GPIO29
GND (31) (32) GND
GPIO10 (33) (34) GPIO30
GPIO11 (35) (36) GPIO31
GND (37) (38) GND
GPIO0-27 VREF (39) (40) GPIO0-27 VREF GPIO28-45 VREF (41) (42) GPIO28-45 VREF GND (43) (44) GND
GPIO12 (45) (46) GPIO32
GPIO13 (47) (48) GPIO33
GND (49) (50) GND
GPIO14 (51) (52) GPIO34
GPIO15 (53) (54) GPIO35
GND (55) (56) GND
GPIO16 (57) (58) GPIO36
GPIO17 (59) (60) GPIO37
GND (61) (62) GND
GPIO18 (63) (64) GPIO38
GPIO19 (65) (66) GPIO39
GND (67) (68) GND
GPIO20 (69) (70) GPIO40
GPIO21 (71) (72) GPIO41
GND (73) (74) GND
GPIO22 (75) (76) GPIO42
GPIO23 (77) (78) GPIO43
GND (79) (80) GND
GPIO24 (81) (82) GPIO44
GPIO25 (83) (84) GPIO45
GND (85) (86) GND
GPIO26 (87) (88) HDMI HPD N 1V8 GPIO27 (89) (90) EMMC EN N 1V8 GND (91) (92) GND
DSI0 DN1 (93) (94) DSI1 DP0
DSI0 DP1 (95) (96) DSI1 DN0
GND (97) (98) GND
DSI0 DN0 (99) (100) DSI1 CP
DSI0 DP0 (101) (102) DSI1 CN
GND (103) (104) GND
DSI0 CN (105) (106) DSI1 DP3
DSI0 CP (107) (108) DSI1 DN3
GND (109) (110) GND
HDMI CK N (111) (112) DSI1 DP2
HDMI CK P (113) (114) DSI1 DN2
GND (115) (116) GND
HDMI D0 N (117) (118) DSI1 DP1
HDMI D0 P (119) (120) DSI1 DN1
GND (121) (122) GND
HDMI D1 N (123) (124) NC
HDMI D1 P (125) (126) NC
GND (127) (128) NC
HDMI D2 N (129) (130) NC
HDMI D2 P (131) (132) NC
GND (133) (134) GND
CAM1 DP3 (135) (136) CAM0 DP0
CAM1 DN3 (137) (138) CAM0 DN0
GND (139) (140) GND
CAM1 DP2 (141) (142) CAM0 CP
CAM1 DN2 (143) (144) CAM0 CN
GND (145) (146) GND
CAM1 CP (147) (148) CAM0 DP1
CAM1 CN (149) (150) CAM0 DN1
GND (151) (152) GND
CAM1 DP1 (153) (154) NC
CAM1 DN1 (155) (156) NC
GND (157) (158) NC
CAM1 DP0 (159) (160) NC
CAM1 DN0 (161) (162) NC
GND (163) (164) GND
USB DP (165) (166) TVDAC
USB DM (167) (168) USB OTGID
GND (169) (170) GND
HDMI CEC (171) (172) VC TRST N
HDMI SDA (173) (174) VC TDI
HDMI SCL (175) (176) VC TMS
RUN (177) (178) VC TDO
VDD CORE (179) (180) VC TCK
GND (181) (182) GND
1V8 (183) (184) 1V8
1V8 (185) (186) 1V8
GND (187) (188) GND
VDAC (189) (190) VDAC
3V3 (191) (192) 3V3
3V3 (193) (194) 3V3
GND (195) (196) GND
VBAT (197) (198) VBAT
VBAT (199) (200) VBAT

What can I do to make at least 4 pins work with this node? Any manual modifications I can do? I'll take a look at the link you just posted, thx!

dceejay commented 3 years ago

Sadly I don't have CM3 so not really going to be easy.

Jamos1988 commented 3 years ago

If you have any test work I am happy to do it for you. Would you like the discussion to go on in this post, or in #746 ? I'll try to look online for users who are trying to use gpio on cm3.

Jamos1988 commented 3 years ago

Another update, did some digging into the documentation. I use the following pins in the flow, and they seem to be mapped one on one to the board: (see screenshot)

https://i.postimg.cc/1zskPTyY/2021-02-01-12-46-11-Untitled-paint-net-4-2-14.png

Would that mean that still it does not support board type pins, rather bcm? (not sure what the difference is)

Jamos1988 commented 3 years ago

I see here another topic that has the same problem: https://discourse.nodered.org/t/cm3-cm3-with-node-red-gpio/20407

dceejay commented 3 years ago

Thank you - I think we are now aware of the issue. the manual workaround may be to edit the .py file to change GPIO.BOARD to GPIO.BCM and then rather than select pins to enter the gpio numbers instead - so 18 instead of 12 etc... however a) the node may well complain about invalid "pins" b) I haven't tested it so I may be wrong c) any magic smoke generated is yours to keep :-)

Jamos1988 commented 3 years ago

Hahaha, yes I understand the risk. Just one question though, how would I select the other pins? Is there a manual way to do this?

Jamos1988 commented 3 years ago

Like this?

https://i.postimg.cc/HkkWHBdz/2021-02-01-13-52-55-openplotter-cm3-openplotter-VNC-Viewer.png

Jamos1988 commented 3 years ago

Or actually, more like this? Considering the pinout diagram?

https://i.postimg.cc/Y0vNJ1jC/2021-02-01-13-55-22-openplotter-cm3-openplotter-VNC-Viewer.png

Edit: Actually selecting pin 63 results in a stopped state again. So I guess I'll have to stick with 18 instead of 12 then.

dceejay commented 3 years ago

yes type into the box - don't click to select. It's the GPIOxx number you want.

Jamos1988 commented 3 years ago

Ok Thanks, status of the PIN is now OK however with a yellow icon rather than green. But, I'll test it going forward.

dceejay commented 3 years ago

If it's an input pin - it's yellow until real data arrives. If it's an output it indicates it's in PWM mode. (waiting for data)

Jamos1988 commented 3 years ago

Ok, tested it now. I got it working 75%! 3 outputs work fine, they are being put in a 3.4v state so the relais are turned on. Just one pin only goes to 1.9v which isn't enough to switch the relais. This is GPIO22 (pin 15)

Also worth mentioning, on the CM3 by default during boot this is an INPUT in HIGH mode, only after node-red starts it is an OUTPUT on LOW mode (untill I turn the dashboard switch on)

Any ideas?

dceejay commented 3 years ago

As I said. I don’t have a cm3 so I can’t really comment, apart from to suggest using another pin.

Jamos1988 commented 3 years ago

No worries, thanks for answering anyway. And sorry for my persistence. Have you ever come across such an issue on a regular Pi?

dceejay commented 3 years ago

Hi @Jamos1988 - I have changed the basic GPIO nodes to now use BCM rather than Pins - I haven't yet pushed it to the library as I think it needs testing first... you can install in manually by changing to your user directory eg

cd ~/.node-red
npm i node-red-node-pi-gpio@beta

You can now either use the usual pin selector picture - but the pin field beneath is now the BCM GPIO number - and you can enter that manually if desired and it should now work ok with cm3 modules etc...

But as I said - I don't have one to test so please try it and give me feedback...

Many thanks

Jamos1988 commented 3 years ago

Ok! Thanks! Will try it asap

Jamos1988 commented 3 years ago

One question, do I first need to uninstall the current version or will this upgrade it? If so, how do I uninstall?

Also, I have modified the python script, will this upgrade overwrite it? Or do I need to revert it back?

dceejay commented 3 years ago

it will overwrite it you shouldn't need to uninstall - to revert npm i node-red-node-pi-gpio@latest

Jamos1988 commented 3 years ago

It is working perfectly! Tested by simply choosing in the GUI the pin, or by filling in the BCM number. Note, I only push digital pins hi or lo so I don't do any PWM or anything. Thank you so much for taking the time and adjusting the plug-in for it!

WABez commented 3 years ago

I'm using a Pi 4 B+, but I can only use up to PIN 26 (GPIO7 - CE1), which is working fine. The last group of pins, from pin 29 (GPIO5) - pin 40 (GPIO21) is giving a state of "stopped" (i.e. "not running" when I inject a value, and in the debugger: "nrgpio python command not running"). The other pins, i.e. pin 26 and lower are working fine. I'm new to Node-Red (and the plug-ins), so not sure what could be the issue.

dceejay commented 3 years ago

@WABez - is this using the new beta ?

WABez commented 3 years ago

@WABez - is this using the new beta ?

I assume Beta meaning the "node-red-node-pi-gpio@beta". I am glad to feedback that I have tested with "node-red-node-pi-gpio@beta" and it is working fine. Thank you.