Raspberry pi gpio led not working

node-red version:V1.3.5
node.js version: v14.17.2
linux 5.10.17-v7l +arm LE

So I am running simple LED on/off and capturing image using nodered and picamera.

So my led was not turned on when I press 1. and picamera capture image but there is no image data. So can anyone guide me to get the correct result?

The picture doesn't help - sorry.

To which GPIO pins is the LED connected?

Obviously one side is connected to a GPIO pin, but the other is either connected to +5, +3.3 or 0v.

Until that is known it is difficult to know what is happening.

And is the LED the right way around? (Gotta ask)

Should be GPIO and GND (Yes, it can technically work the other way, but not normal except when using common anode RGB LED... but then all the GPIO code is backward :stuck_out_tongue: And when rereading your post I think you technically covered all dem bases :blush: )

Hi yes, thanks for the info. So I have connected to pin40(GPIO21) yellow wire, and then Ground-39 as ground pin(black wire). And LED is connected in the right way also.

Annnd.... how are you setting up the node? Digital or PWM?

Have you tested the LED without Node-Red and thus confirmed all the hardware and wiring work?

I am setting the node as Digital output node. And I haven't tested the LED without Node-Red. But I can confirm that the hardware and wiring is correct and is working.

Then you probably haven't installed any GPIO libraries... as per the Help files for that node.

And depending on the OS you installed, one may not have been pre-installed.

BTW, while I have tested that node OK with Boolean (TRUE/FALSE), number (1/0) is the preferred payload

This is what should be pre-installed with some OS (for the pi)


And I believe this is the one specifically referenced by the node

Thank you for your help. I have installed that library but the issue still persists. After I doublechecked, I think there is some problem with LED. And could you suggest any tutorials for taking picture with pi camera once I press the push button and using MQTT module?

I have this experiment... No MQTT for it yet, but is shows the image in the workspace and on dashboard. Button will only let you press it once every 10 seconds (it can take about 5 to show the image), and I have a Pan and Tilt setup with my camera, but it uses the PCA9685 i2c expander for stable hardware based PWM... I left those nodes in, in case you might want to experiment with that adapter and servos as well, but they can simply be deleted if not needed.

You will have to install any missing nodes.

[{"id":"43e3cfc0.306c3","type":"tab","label":"Raspi Cam Dashboard","disabled":false,"info":""},{"id":"93aaa19c.0ef06","type":"inject","z":"43e3cfc0.306c3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"str","x":110,"y":80,"wires":[["72a38d28.e63e04"]]},{"id":"72a38d28.e63e04","type":"exec","z":"43e3cfc0.306c3","command":"raspistill","addpay":"","append":"-w 640 -h 480 -o -","useSpawn":"false","timer":"","oldrc":false,"name":"","x":200,"y":160,"wires":[["ffb21a3d.76da08","dae5e474.b69b58"],[],[]]},{"id":"ffb21a3d.76da08","type":"base64","z":"43e3cfc0.306c3","name":"","action":"str","property":"payload","x":280,"y":80,"wires":[["d408ccb2.5e315"]]},{"id":"d408ccb2.5e315","type":"template","z":"43e3cfc0.306c3","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img width=\"320px\" height=\"240px\" src=\"data:image/jpg;base64,{{{payload}}}\">","output":"str","x":440,"y":80,"wires":[["34a5983f.0a1118"]]},{"id":"34a5983f.0a1118","type":"ui_template","z":"43e3cfc0.306c3","group":"eb23a053.4aa63","name":"Snapshot Template","order":1,"width":"7","height":"5","format":"<div ng-bind-html=\"msg.payload\"></div>\n<style>\n    body.nr-dashboard-theme md-content md-card {\n        border-radious: 20px;\n}\n.nr-dashboard-theme ui-card-panel {\n    border-radius: 20px;\n}\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":630,"y":80,"wires":[[]]},{"id":"dae5e474.b69b58","type":"imageSimple","z":"43e3cfc0.306c3","imageData":"payload","imageType":"msg","autoresize":true,"original":false,"localfile":false,"flipX":false,"flipY":false,"width":"320","height":"480","rotate":0,"crop":true,"cropX":0,"cropY":0,"cropWidth":200,"cropHeight":200,"x":510,"y":140,"wires":[[]]},{"id":"ca3a98d1.adf308","type":"ui_slider","z":"43e3cfc0.306c3","name":"","label":"Pan","tooltip":"","group":"2b5eec28.269ea4","order":1,"width":0,"height":0,"passthru":true,"outs":"end","topic":"topic","topicType":"msg","min":"900","max":"2100","step":"10","x":110,"y":380,"wires":[["7509378f.2c9198"]]},{"id":"7509378f.2c9198","type":"PCA9685 out","z":"43e3cfc0.306c3","name":"PWM Output 0 (Pan Servo)","pca9685":"6ce45bce.cdff94","channel":"0","payload":"","unit":"microseconds","onStep":"0","x":320,"y":380,"wires":[]},{"id":"1a94fb4c.338225","type":"ui_slider","z":"43e3cfc0.306c3","name":"","label":"Tilt","tooltip":"","group":"2b5eec28.269ea4","order":1,"width":0,"height":0,"passthru":true,"outs":"end","topic":"topic","topicType":"msg","min":"900","max":"2100","step":"10","x":110,"y":420,"wires":[["95f4e1f5.3c411"]]},{"id":"95f4e1f5.3c411","type":"PCA9685 out","z":"43e3cfc0.306c3","name":"PWM Output 1 (Tilt Servo)","pca9685":"6ce45bce.cdff94","channel":"1","payload":"","unit":"microseconds","onStep":"0","x":320,"y":420,"wires":[]},{"id":"81d5fa20.7db83","type":"ui_button","z":"43e3cfc0.306c3","name":"","group":"d3d5aef6.5754d","order":6,"width":0,"height":0,"passthru":false,"label":"CLICK ME","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"num","topic":"topic","topicType":"msg","x":130,"y":280,"wires":[["7245af5f.dbbb08"]]},{"id":"7245af5f.dbbb08","type":"trigger","z":"43e3cfc0.306c3","name":"Trigger delay","op1":"","op2":"","op1type":"pay","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":330,"y":280,"wires":[["2c2b4174.0aa20e","72a38d28.e63e04"],["fc0c5794.cd3948"]]},{"id":"2c2b4174.0aa20e","type":"change","z":"43e3cfc0.306c3","name":"msg.enabled FALSE","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":160,"y":240,"wires":[["81d5fa20.7db83"]]},{"id":"fc0c5794.cd3948","type":"change","z":"43e3cfc0.306c3","name":"msg.enabled TRUE","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":320,"wires":[["81d5fa20.7db83"]]},{"id":"4ec50c05.eedd24","type":"comment","z":"43e3cfc0.306c3","name":"Snap a RPiCam picture for display- with P&T","info":"","x":210,"y":20,"wires":[]},{"id":"eb23a053.4aa63","type":"ui_group","name":"Snapshot","tab":"75252f1b.e6fdd","order":2,"disp":true,"width":"7","collapse":false},{"id":"2b5eec28.269ea4","type":"ui_group","name":"P&T","tab":"75252f1b.e6fdd","order":3,"disp":true,"width":"6","collapse":false},{"id":"6ce45bce.cdff94","type":"PCA9685","deviceNumber":"1","address":"64","frequency":"50"},{"id":"d3d5aef6.5754d","type":"ui_group","name":"Trigger","tab":"75252f1b.e6fdd","order":1,"disp":true,"width":"6","collapse":false},{"id":"75252f1b.e6fdd","type":"ui_tab","name":"Raspi Cam","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

Thanks for the help. I still have one more question. I don't know why my button got no signal. could you help me with that?

Honestly, camera pictures of your display is not very useful for diagnosis.

Possibly the same issue with GPIO setup/support. Test it first without Node Red... lots of examples on Google that will step you through the whole process.


BTW... is your Node-Red actually installed ON the RPi?? Or if so, not using Raspbian with root access?
It has to be in order to actually control the GPIO. That might explain the N/A on your GPIO nodes :stuck_out_tongue:

I think I have installed nodered on my pi. I just type in some commands from google to install it. Currently I am using Pi for that. But I don't know how to check whether my installation is correct.

I never put sudo once I start node-red. So I will try again with sudo and see how it works. Thank you.

I know this doesn't answer your question and goes off on a tangent, but here's goes anyway.

I've seen so many questions on the forum recently about... driving an OLED panel, connecting LEDs, handling push-buttons, etc... and the pain and effort it takes (installing Python etc..).

I won't let my IoT students connect anything to a Raspberry Pi as the resource is expensive and can be destroyed in a second by connecting a wire to the wrong pin. What each of them do instead is use an inexpensive microcontroller like a Wemos D1 Mini (flashed with ESP-Easy or Tasmota) and connect things to that. This means in the unlikely event that they have an accident (which up till now they haven't) the worst that can happen is the death of a cheap microcontroller (less than GBP 2 in UK money).

ESP-Easy and Tasmota support MQTT so establishing two-way communication between the Pi (running Node-RED) and the Wemos is fairly straightforward and well documented.

Here are some examples of my students' breadboard prototypes.
Controlling LEDs (using 330 ohm resistor in series with each LED)


OLED panel and temperature sensor

Matrix-keypad and OLED panel (part of a model train controller)

Infrared detector


1 Like

In your button picture you seem to have the button wired to ground... and the input pin setup with a pulldown (to ground) - so it will always be at ground = 0.

With your LED - what value resistor are you using ?

1 Like

Hi I have solved the issue. The issue is that I don't properly installed the npm with gpio library.Thank you all for your suggestion.

Thank you for that. I will have a look on that.

Thank you gunner, I have solved the issue and it is with the broken library.

1 Like