cp2004 / OctoPrint-WS281x_LED_Status

Add some RGB LEDs to your printer for a quick status update!
https://plugins.octoprint.org/plugins/ws281x_led_status
GNU Affero General Public License v3.0
111 stars 26 forks source link

Unable to get working via GPIO10. Possibly issue with SPI? #215

Closed The5thLegend closed 1 year ago

The5thLegend commented 1 year ago

Describe your problem

I'm struggling to get this plugin to work with GPIO10, but I don't believe the issue is the plugin or the install...

First, I am able to successfully run the strandtest with GPIO18. But when I attempt the test with GPIO10, the LEDs do not light up. So I suspect the issue is somehow tied to SPI.

I have a Pi4, and have ensured all of the following:

Any idea on what else I should be checking to get SPI working? I'd imagine if I could get strandtest working with GPIO10, then I'd be able to get the plugin working shortly after

Since I'm unable to get the strandtest to work with GPIO10, I'm unsure if it'd be helpful for me to supply logs for the plugin or octoprint, but let me know if I should

Please confirm the following

Log files

No response

cp2004 commented 1 year ago

I'm unsure if it'd be helpful for me to supply logs for the plugin or octoprint, but let me know if I should

Always share them, even if you might not think they'll be helpful - it takes less time for you to share them than it does for me to type this :)

The5thLegend commented 1 year ago

Sure thing octoprint.log plugin_ws281x_led_status_debug.log

The5thLegend commented 1 year ago

Okay, maybe I'm just dumb? I posted a similar question on Reddit, and someone there said that the library I'm using for the strandtest doesn't use SPI. I was using rpi-ws281x-python for the strandtest.

Am I just approaching this from the wrong angle, and everyone here has been using some other strandtest for troubleshooting with this plugin?

The5thLegend commented 1 year ago

Now I'm starting to suspect that my GPIO10 pin is nonfunctional... Using the steps from this thread, I ran a test and am not receiving the sent byte to my MISO pin

The5thLegend commented 1 year ago

Yup, looks like my GPIO10 is fried. Ran the gpiotest from here, and GPIO10 failed. :(

I saw in some posts that GPIO20 could work. Unfortunately if I try the strandtest with that pin though, I get the following error saying use of that pin is not possible.

Traceback (most recent call last):
Gpio 20 is illegal for LED channel 0
  File "/home/nito/rpi-ws281x-python/examples/strandtest.py", line 97, in <module>
    strip.begin()
  File "/usr/local/lib/python3.9/dist-packages/rpi_ws281x-4.3.4-py3.9-linux-armv7l.egg/rpi_ws281x/rpi_ws281x.py", line 131, in begin
    raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp))
RuntimeError: ws2811_init failed with code -11 (Selected GPIO not possible)

I tried setting the channel to 1, but that just removed that one line from the error. I still get an error with the rest of the above text.

So I decided to start from scratch. Did a fresh OctoPi install, installed the plugin, set the pin to 20, and tried the test colors in utilities, and still don't get any output. Attached new logs for the plugin and octoprint

plugin_ws281x_led_status_debug (2).log octoprint (2).log

I also noticed that you had your own fork of rpi-ws281x-python. So I tried cloning that and running the strandtest again, but I still get the same "GPIO not possible" error as above.

The5thLegend commented 1 year ago

I saw that the library supports PCM with GPIO21. I tried the strandtest with that pin, and it worked. But when I try using that pin with the plugin, it doesn't work and I get an error in the log file plugin_ws281x_led_status_debug (5).log

I know the plugin's documentation says it has to be a PWM or SPI pin, but if the PCM pin works for strandtest, shouldn't it also work for the plugin?

cp2004 commented 1 year ago

With SPI in your first log, there are on errors so the system thinks that SPI is working. I trust you have wired it correctly as it worked on GPIO 18 and GPIO21 outside the plugin.

Okay, maybe I'm just dumb? I posted a similar question on Reddit, and someone there said that the library I'm using for the strandtest doesn't use SPI. I was using rpi-ws281x-python for the strandtest. Am I just approaching this from the wrong angle, and everyone here has been using some other strandtest for troubleshooting with this plugin?

You're not wrong, that's the exact library that is used in this plugin. It definitely does support SPI control, the Reddit thread is completely wrong.

I saw in some posts that GPIO20 could work. Unfortunately if I try the strandtest with that pin though, I get the following error saying use of that pin is not possible.

It should in theory be possible to do the same thing with SPI1/GPIO20, however the library doesn't support it.

I also noticed that you had your own fork of rpi-ws281x-python. So I tried cloning that and running the strandtest again, but I still get the same "GPIO not possible" error as above.

This was my attempt at adding SPI1 support to the library, but I have no hardware to test SPI1 with at the moment and so I couldn't get it to work after just a brief look, kind of flying blind.

I saw that the library supports PCM with GPIO21. I tried the strandtest with that pin, and it worked. But when I try using that pin with the plugin, it doesn't work and I get an error in the log file

All the methods of controlling the LEDs outside of using SPI require root permissions to run, which the OctoPrint plugin does not have and so it doesn't work, which is why people would normally use SPI.

Unfortunately I can't say if I will personally be able to update the library to use SPI1, maybe it doesn't work at all due to some other reason. Running OctoPrint as root is not recommended for security of your install - it is possible, but not recommended. Otherwise I am not sure what else you can do.

The5thLegend commented 1 year ago

Ah, okay, thanks for the clarification on GPIO20 & GPIO21.

Just as a test, I ran OctoPrint as root and tried the plugin with GPIO18, and it worked. So I at least know that my config in the plugin is right and my wiring is sufficient. I guess I'll have to wait until I can get my hands on another Pi to test with GPIO10 again!

I trust you have wired it correctly as it worked on GPIO 18 and GPIO21 outside the plugin.

Quick question on wiring... I've gotten it to work with no level shifting, like your diagram here I've also gotten it to work with a level shifting chip using the exact same chip & wiring as your digram here. However, this is my first time using a level shifting chip, so I'm unsure if it is actually level shifting... Is there a way that I can test it, like with a multimeter or something? Or is it the kind of thing where, if the LEDs are being lit/controlled, then the level shifting is definitely working?

cp2004 commented 1 year ago

Or is it the kind of thing where, if the LEDs are being lit/controlled, then the level shifting is definitely working?

This one - the signals have to be exactly right for the LEDs to work properly, so if it works the level shifting is working.

The5thLegend commented 1 year ago

Great, thanks! Appreciate the responses and your work with this plugin!

Since I got it working with PWM, and can't use SPI at the moment because of a fried pin, this thread can probably be closed.