Mote continuous infinite running on Raspberry Pi

I’m enjoying playing with the mote (not pHAT(, stand-alone?)) kit. I have got the examples running on a Pi 3, and have made some really simple scripts of my own.

Both the examples and my own script however, suffer from a stalling/hanging effect when I run it on the pi. I can’t keep any of the examples, or my own script continuously running. Eventually the cheerlights stop responding, and the animated rainbow example stops moving after a few minutes. No errors are printed in the windows, not commands are called, and I’m not doing anything else on the machine (which is running a recent Raspbian desktop version).

I have tested my own scripts running on a Macbook though, and they seem to be able to run infinitely, as I would expect them too.

from mote import Mote
import random
import time

mote = Mote()

mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)

while True:
    for channel in range(1,5):
        mote.clear()
        mote.set_pixel(channel, random.randint(1,15), 0, 0, 255)
        mote.show()
        time.sleep(0.5)

This has been flashing while attached to my laptop happily for about 20 minutes now.

What can I do to maintain the animated/active script running on the Pi? Ideally I’d eventually like to have this running on my zero instead for a build I’m planning, so advice for that as well would be welcome :)

Is it just the python script that stops or is Raspbian glitching as well?
Do you have a monitor attached to the Pi? If yes have you noticed a lightning bolt flashing on screen?
I’m not familiar with mote, how does it get its power? If from the PI, does your Pi have a good beey high current power supply attached?

Just a side note, apparently the Pimoroni Mote pixels are 0 indexed so according to your code if I read it correctly, the first LED will never light as the lowest number from randint would be 1.

To check the power as alphanumeric suggested, maybe turn the lights one one at a time slowly to increase power draw and see if the Pi freezes at any point.

Although that script looks like it only turns on one light per channel anyway so not sure if power would be an issue with that script.

1 Like

LED Shim is the same way code wise. 0 is the first LED and 27 the last, for a total of 28.
That caught me off guard at first. I got some “out of range” or something errors in my python code.

One more thing to try. Try increasing the cooldown from 0.5 seconds to something like 2 seconds. It really shouldn’t be the case but perhaps the USB serial comms on the Pi is locking up?

The other thing with a Pi is, other than the Zero, they have a poly fuse that limits the max current. 1.2 A total to all 4 USB ports. You can pull 1.2A from one port, or that total from any combination of the 4 ports. Exceed 1.2A though and the poly fuse will overheat and effectively become an open circuit. It becomes a very high series resistance. It will reset after it cools down though. That could takes hours though. Likely not the issue but I thought it merited mentioning. If you fully lite 4 mote strips up at the same time, it might be an issue. I haven’t looked up the specs though.

Thanks for the detailed diagnosis questions :)

I didn’t notice a lightning bolt flash, where should I be looking?

The mote was getting power from the pi via usb, as per this with the ‘red cable’: https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-mote

There is a ‘spare’ port with a lightning bolt attached, but it isn’t documented what I should be doing with it anywhere I’ve seen so I’ve left it alone.

The power supply to the pi is via the usb power input and an official pi UK power plug.

No matter what script it is it appears to be a time issue. Either way the lights stay lit. No visible change to appears on the screen connected by hdmi. The script doesn’t crash, the OS behaves normally, all that happens is that if I’m running a script where the lights change, they just stop changing, but stay lit.

I was wondering if it might be something to do with the OS pausing the process as it doesn’t appear to be active enough, or if there might be a way I can modify the script to prevent the OS potentially shutting it down.

If your running Raspbian, with a monitor attached to the HDMI, a lightning bolt symbol / icon will flash on your monitor if an under volt condition is detected. Under volt is usually caused by high current draw. You get a voltage drop over the power supply power cable. I think the power LED will also flash when this happens.

1 Like

From the link you posted above.
The remaining port on the controller, marked with the lightning bolt power symbol, can be used to supply extra power to the Mote strips provided by a micro-USB power supply, to take them to full brightness. You can safely plug this additional power supply in and out while your Mote strips are connected and running quite safely.

1 Like

If you open your python script in idle, and run it from there “F5”. You may get an error message you wouldn’t normally see if and when it glitches. If thats what’s happening.
I run my python code on bootup via crontab. If I don’t have any errors in my code they pretty well run 24/7 without issue. I can’t run my code on my PC though, its tied to hardware that will only connect to a Pi. i2c breakout boards and hats and pHats. I have very little that I run from USB other than keyboards mice and wifi adapters.