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

**URL:** <https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894>\
**Category:** Hardware\
**Created:** [7 February 2022 03:12 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894 "2022-02-07T03:12:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 03:12 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/1 "2022-02-07T03:12:20Z")

</div>

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

```auto
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.

 ![Screenshot from 2022-02-07 14-06-19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/19cb430752ece1602624b699674aebf9558bfc75.png)

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.

```auto
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.

 ![Screenshot from 2022-02-07 14-07-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4cfb2a2c361b8ec98771cde75e89c488211e5074.png)

# _"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?)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 February 2022 10:32 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/2 "2022-02-07T10:32:48Z")

</div>

> [@Trying\_to\_learn](#):
>
> Why is it installing python3 when it is said that only 2.x is supported?

Isn’t this something you should ask Pimoroni?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [7 February 2022 11:11 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/3 "2022-02-07T11:11:17Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2022 11:34 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/4 "2022-02-07T11:34:28Z")

</div>

> [@Trying\_to\_learn](#):
>
> (And do I need to do the full install?)

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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 19:53 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/5 "2022-02-07T19:53:13Z")

</div>

That's kind of good to hear.

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 20:17 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/6 "2022-02-07T20:17:20Z")

</div>

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.

```auto
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`.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2022 21:24 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/7 "2022-02-07T21:24:28Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 21:27 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/8 "2022-02-07T21:27:06Z")

</div>

Alas...

```auto
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.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2022 21:31 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/9 "2022-02-07T21:31:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 21:32 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/10 "2022-02-07T21:32:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2022 21:33 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/11 "2022-02-07T21:33:45Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 21:42 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/12 "2022-02-07T21:42:53Z")

</div>

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:

```auto
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:

```auto

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

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2022 21:59 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/13 "2022-02-07T21:59:06Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 22:02 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/14 "2022-02-07T22:02:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2022 22:23 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/15 "2022-02-07T22:23:27Z")

</div>

What happens when you use the node?

```auto
[
    {
        "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": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 22:28 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/16 "2022-02-07T22:28:15Z")

</div>

☹  
Sorry. Nothing.

But the `mode` is different between yours and mine.

 ![Screenshot from 2022-02-08 09-27-11](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4e62d28b9790c52d6b9a19b32368f181b44eacb6.png)

 ![Screenshot from 2022-02-08 09-27-17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d070469cd2e94766911937797b3ce8913fd82ddc.png)

Not sure if that is/not helping.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2022 22:43 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/17 "2022-02-07T22:43:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 February 2022 22:45 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/18 "2022-02-07T22:45:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [8 February 2022 08:44 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/19 "2022-02-08T08:44:32Z")

</div>

🙂

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

🙂

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [8 February 2022 08:48 UTC](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894/20 "2022-02-08T08:48:11Z")

</div>

Interesting development:

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

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

[Next page](https://discourse.nodered.org/t/neopixel-not-working-ive-done-my-homework-this-time/57894.md?page=2)
