Neopixel not working. (I've done my homework this time)

I've done the extra install of the other stuff needed:

The Neopixel python driver need to be pre-installed... The easiest way to get the driver installed is to use the Unicorn HAT drivers install script... see the Pimoroni Getting Started with Unicorn HAT page.

Well, to the best of my knowledge I have.

Back story:
A long time ago I messed up and turned a machine off halfway through an upgrade.
It wouldn't boot any more.

Today it has become my mission to get it working.

New SD card, flashed, all going good.

Installed NR - latest version.
Buster - up to date.

went into .node-red and did npm install to get all the required nodes installed.
Flow running. (Not perfectly, but that's another thread)

Did the stuff as described above.
It then went on to audio stuff - which I don't want and it seemed optional.

Set the pin in the node to 12 (GPIO 18)
Nothing.

For the sake of sharing, I am doing it again.

Screen shots to follow.
And there is/are some concerns.

So I am starting the install. As it has already (recently) been done a lot of stuff is existing.
No worries.

Here is something from the install page which is of some interest.

This command downloads an install script from the internet, which should then run automatically through all the steps required to get Unicorn Hat installed and working.

Note: Unicorn Paint is only supported in Python 2.x!

During installation, you'll be asked if you want to install Flask for Unicorn Paint. It's up to you, but I'd recommend it! Unicorn Paint is fun.

python2.x ONLY!

The next screen shot.

"Huston: we have a problem."

Why is it installing python3 when it is said that only 2.x is supported?

Anyway, I'm just asking.

I have the working version on the old SD card, but have no way of knowing which files are needed and if I can just copy them, or do they need to be installed?

(And do I need to do the full install?)

Isn’t this something you should ask Pimoroni?

I haven't installed this in a while but in the past - I've always done the full install.

Then I test that the demo's work by directly running them from the command line

Then I try and use them in other software enviroments such as Node-RED

So pop over to Raspberry Pi forums to get the basics working and then come back here if Node-RED doesn't work afterwards :slight_smile:

The full install includes sample python scripts in ~/Pimoroni/unicornhat/examples. You probably do need them.

The install script does say

We need to reconfigure your audio configuration!
This is a necessary step to ensure Unicorn HAT/pHAT works correctly

but it fails for me on Bullseye and the unicorn works, using python3. No idea if sound works too.
I did not get a warning about Unicorn Paint, but as far as I know I don't use it.

Once it's installed and you reboot you can test it by eg sudo ~/Pimoroni/unicornhat/examples/rainbow.py

Pimoroni's unicorn libraries have not been updated for a couple of years so it's not surprising if they show some eccentricities with Bullseye. It still works though.

That's kind of good to hear.

I have had no end of trouble with other things updating to Buster.

Just went through and did the full install and reboot.

Tried some of the examples and they won't run.

Ok I even tried it with python3 at the last one.
Still no luck.

pi@MusicPi:~/Pimoroni/unicornhat/examples $ python demo.py
Traceback (most recent call last):
  File "demo.py", line 7, in <module>
    import unicornhat as unicorn
ImportError: No module named unicornhat
pi@MusicPi:~/Pimoroni/unicornhat/examples $ python rainbowpy
python: can't open file 'rainbowpy': [Errno 2] No such file or directory
pi@MusicPi:~/Pimoroni/unicornhat/examples $ python rainbow.py
Traceback (most recent call last):
  File "rainbow.py", line 6, in <module>
    import unicornhat as unicorn
ImportError: No module named unicornhat
pi@MusicPi:~/Pimoroni/unicornhat/examples $ python3 rainbow.py
Can't open /dev/mem: Permission denied
Traceback (most recent call last):
  File "rainbow.py", line 6, in <module>
    import unicornhat as unicorn
  File "/usr/local/lib/python3.7/dist-packages/unicornhat.py", line 35, in <module>
    ws2812.begin()
  File "/usr/local/lib/python3.7/dist-packages/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 -5 (mmap() failed)
Segmentation fault
pi@MusicPi:
pi@MusicPi:~/Pimoroni/unicornhat/examples $ python rainbow_blinky.py 
Traceback (most recent call last):
  File "rainbow_blinky.py", line 12, in <module>
    import unicornhat as unicorn
ImportError: No module named unicornhat
pi@MusicPi:~/Pimoroni/unicornhat/examples $ 

I'll go and bother pimoroni.

You have to call the scripts with sudo because they perform jiggery-pokery with /dev/mem.

Try sudo ~/Pimoroni/unicornhat/examples/rainbow.py

1 Like

Alas...

pi@MusicPi:~/Pimoroni/unicornhat/examples $ sudo python toggle.py 
Traceback (most recent call last):
  File "toggle.py", line 6, in <module>
    import unicornhat as unicorn
ImportError: No module named unicornhat
pi@MusicPi:~/Pimoroni/unicornhat/examples $ cd ~
pi@MusicPi:~ $ sudo ~/Pimoroni/unicornhat/examples/rainbow.py
Traceback (most recent call last):
  File "/home/pi/Pimoroni/unicornhat/examples/rainbow.py", line 6, in <module>
    import unicornhat as unicorn
ImportError: No module named unicornhat
pi@MusicPi:~ $ 

After the install I did reboot.

Hmm. Maybe the unicorn library is only installed for one python version.

Do either sudo python3 rainbow.py or sudo python2 rainbow.py work?
Not toggle.py, don't know what that does except it errors for me.

Just before we go too far down this road... I only have the 8 LED strip.

So it is a good idea to make sure what we are using as the test bed works on just 8 leds.

Not Unicornhat but Blinkt?. You used the wrong install script then.

curl https://get.pimoroni.com/blinkt | bash

Blinkt comes with a different set of examples in ~/Pimoroni/blinkt/examples.
Unlike unicorn, I don't think they need sudo.

Yeah, well..... It is a Neopixel strip which is 8 leds long.

the node (node-red-node-pi-neopixel) says I have to install the pimoroni stuff.

HANG ON!

When I went to get the name of the node the version was.... OLD...
and it had an update to a more recent version.

Weird in a lot of ways, as this was a clean build.
I only installed the node the other day.

So unless the update came out very recently....
And it was from 0.1.2 to 1.0.0 (Just checked as I hadn't closed the update window.)

On other things:

pi@MusicPi:~ $ sudo python3 ~/Pimoroni/unicornhat/examples/rainbow.py
Rainbow

Displays a beautiful rainbow across your HAT/pHAT :D

If you're using a Unicorn HAT and only half the screen lights up, 
edit this example and  change 'unicorn.AUTO' to 'unicorn.HAT' below.

Reticulating splines
Enabled unicorn poop module!
Pooping rainbows...
^CTraceback (most recent call last):
  File "/home/pi/Pimoroni/unicornhat/examples/rainbow.py", line 45, in <module>
    time.sleep(0.01)
KeyboardInterrupt
pi@MusicPi:~ $ cd Pimoroni/unicornhat/
pi@MusicPi:~/Pimoroni/unicornhat $ cd examples
pi@MusicPi:~/Pimoroni/unicornhat/examples $ ls
ascii_pic.py           demo.py                   drop.py          hat                rainbow.py          README.md  test_rotation.py
bluesky_greengrass.py  detect.py                 figlet.py        phat               random_blinky.py    simple.py  toggle.py
cross.py               drop_four_orientation.py  game_of_life.py  rainbow_blinky.py  random_sparkles.py  snow.py
pi@MusicPi:~/Pimoroni/unicornhat/examples $ sudo python3 demo.py 
Demo

This pixel shading demo transitions between 4 classic graphics demo effects.

If you're using a Unicorn HAT and only half the screen lights up, 
edit this example and  change 'unicorn.AUTO' to 'unicorn.HAT' below.

^CTraceback (most recent call last):
  File "demo.py", line 173, in <module>
    unicorn.show()
  File "/usr/local/lib/python3.7/dist-packages/unicornhat.py", line 344, in show
    ws2812.show()
  File "/usr/local/lib/python3.7/dist-packages/rpi_ws281x/rpi_ws281x.py", line 135, in show
    resp = ws.ws2811_render(self._leds)
KeyboardInterrupt
pi@MusicPi:~/Pimoroni/unicornhat/examples $ 

Something's going on with the sudo and python3 bits.

From the node's page:


node-red-node-pi-neopixel 1.0.0

A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.

npm install node-red-node-pi-neopixel

A Node-RED node to drive a strip of Neopixel or WS2812 LEDs from a Raspberry Pi.
Pre-requisites

The Neopixel python driver need to be pre-installed... The easiest way to get the driver installed is to use the Unicorn HAT drivers install script... see the Pimoroni Getting Started with Unicorn HAT page.

curl -sS get.pimoroni.com/unicornhat | bash

Yeah, well..... It is a Neopixel strip which is 8 leds long.
the node (node-red-node-pi-neopixel) says I have to install the pimoroni stuff.

Oh sorry, I assumed it was a Unicorn hat since that's what you installed.
I don't know anything about using the libraries for other neopixel setups.

No problems.

I don't know the difference between unicorn and neopixel. I thought that unicorn was (maybe) just a bigger array of neopixel leds.

But the node's install page says to do unicorn.

A long - LONG - time ago I fell for the trap after rebuilding the machine and installing the node to not include this install and spent a few days running around.

I'm not sure who it was was but I got a reply saying something like:
Are you sure you installed ALL the packages?

I went to the node's page and saw that line....
Did it and all was sweet.

But this was back in the days of either Jessie or Stretch.
Not Buster.

And as python (2) is past EOL.... It has left a few problems to be resolved I believe.

What happens when you use the node?

[
    {
        "id": "f4ed8a6d4773b754",
        "type": "inject",
        "z": "b946eb07.fa1b98",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "25",
        "payloadType": "num",
        "x": 710,
        "y": 400,
        "wires": [
            [
                "c6239953020ac473"
            ]
        ]
    },
    {
        "id": "c6239953020ac473",
        "type": "rpi-neopixels",
        "z": "b946eb07.fa1b98",
        "name": "",
        "gpio": 18,
        "pixels": "8",
        "bgnd": "",
        "fgnd": "",
        "wipe": "40",
        "mode": "pcent",
        "rgb": "rgb",
        "brightness": "100",
        "gamma": true,
        "x": 870,
        "y": 400,
        "wires": []
    }
]

:frowning:
Sorry. Nothing.

But the mode is different between yours and mine.

Not sure if that is/not helping.

I can only suggest you check the pin number and wiring.

For me, set to Pin No 12 (which is GPIO 18), it lights up some pixels on my actual Unicorn hat.

Yeah, I agree.

It used to work. But that was either Jessie or Stretch.

I messed up one day when updating and shut the machine down by mistake.
It wouldn't boot any more.

Alas I am wanting to get that machine working again and so rebuilt it with Buster and now I have all these problems.

Thanks very much for the help.

I'll keep digging.

:slight_smile:

Wipe card - start again - only install full UnicornHAT software
If it doesn't work from command line - don't play around but seek help on the Raspberry Pi forum

Come back here when you can get the software to work from a command line and it doesn't work from Node-RED

:slight_smile:

Interesting development:

I powered up the machine again and now 2 of the LEDs are glowing.
But I can't turn them off now. :frowning:

But to me it implies that somewhere in the booting/initial stages the code can work.
Something is happening to prevent further interactions.