Bought a BlinkStick

Computer Hardware and electronics in general.
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Bought a BlinkStick

Post by ayu »

BlinkStick

Image

So this is a lot of coding but since the actual topic is about the hardware that I'm playing with I figured it belongs here :).

I wanted to have little lights on my desk that I could control with scripts for various reasons. Say someone tags me in IRC then I would want it to flash blue. After lurking on Google for an hour or so I stumbled upon this site https://www.blinkstick.com/. It's a small device with integrated LEDs and built-in firmware. The most simple setup is one chip connected via USB to your computer, which can then be controlled via CLI or script. I ordered one unit together with a little plastic cube that you can put the device in to get a cool flashing cube. Much fancier.

Image

There's very good documentation on their site but I will go through what I did since I had to do a few extra steps to make it work.

Setup for Linux
sudo pip install blinkstick
apt install python-is-python3 (probably optional)
chmod +x
Open /usr/local/bin/blinkstick in vim then do :set ff=unix and :wq
sudo blinkstick --add-udev-rule (Probably need to restart after this)
And that's it. After this the below can be run without root privs.

Code: Select all

from blinkstick import blinkstick

for bstick in blinkstick.find_all():
    print ("Found device:")
    print ("    Manufacturer:  " + bstick.get_manufacturer())
    print ("    Description:   " + bstick.get_description())
    print ("    Serial:        " + bstick.get_serial())
    print ("    Current Color: " + bstick.get_color(color_format="hex"))
    print ("    Info Block 1:  " + bstick.get_info_block1())
    print ("    Info Block 2:  " + bstick.get_info_block2())

while True:
    for bstick in blinkstick.find_all():
        bstick.set_random_color()
        print (bstick.get_serial() + " " + bstick.get_color(color_format="hex"))
    time.sleep(5)
You might get an I/O exception like the below one (I've emailed them about this to see if it's a faulty unit or something else. Tried different cables without change).
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/blinkstick/blinkstick.py", line 249, in _usb_ctrl_transfer
return self.device.ctrl_transfer(bmRequestType, bRequest, wValue, wIndex, data_or_wLength)
File "/usr/lib/python3/dist-packages/usb/core.py", line 1036, in ctrl_transfer
ret = self._ctx.backend.ctrl_transfer(
File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 875, in ctrl_transfer
ret = _check(self.lib.libusb_control_transfer(
File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "bl.py", line 36, in <module>
bstick.set_random_color()
File "/usr/local/lib/python3.8/dist-packages/blinkstick/blinkstick.py", line 696, in set_random_color
self.set_color(name="random")
File "/usr/local/lib/python3.8/dist-packages/blinkstick/blinkstick.py", line 410, in set_color
self._usb_ctrl_transfer(0x20, 0x9, report_id, 0, control_string)
File "/usr/local/lib/python3.8/dist-packages/blinkstick/blinkstick.py", line 255, in _usb_ctrl_transfer
return self.device.ctrl_transfer(bmRequestType, bRequest, wValue, wIndex, data_or_wLength)
File "/usr/lib/python3/dist-packages/usb/core.py", line 1036, in ctrl_transfer
ret = self._ctx.backend.ctrl_transfer(
File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 875, in ctrl_transfer
ret = _check(self.lib.libusb_control_transfer(
File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error
The code can be changed to catch the exception and simply try again, which temporarily solves the problem.

Code: Select all

from blinkstick import blinkstick
import time

for bstick in blinkstick.find_all():
    print ("Found device:")
    print ("    Manufacturer:  " + bstick.get_manufacturer())
    print ("    Description:   " + bstick.get_description())
    print ("    Serial:        " + bstick.get_serial())
    print ("    Current Color: " + bstick.get_color(color_format="hex"))
    print ("    Info Block 1:  " + bstick.get_info_block1())
    print ("    Info Block 2:  " + bstick.get_info_block2())

while True:
    try:
        for bstick in blinkstick.find_all():
            bstick.set_random_color()
            print (bstick.get_serial() + " " + bstick.get_color(color_format="hex"))
    except e:
        time.sleep(1)
    time.sleep(5)
There are multiple ways the unit can be used, I picked Python but lots of languages and OSes are supported.

https://www.blinkstick.com/help/api-implementations
https://arvydas.github.io/blinkstick-python/

That's about it :). Will post some more later for what I decide to use it for. The first project I want to use it with is a script that will use it together with an alarm sound to notify me when the script throws an error :P.
"The best place to hide a tree, is in a forest"

User avatar
ph0bYx
Staff Member
Staff Member
Posts: 2039
Joined: 22 Sep 2008, 16:00
15
Contact:

Re: Bought a BlinkStick

Post by ph0bYx »

Open /usr/local/bin/blinkstick in vim then do :set ff=unix and :wq
Wait, you need to set the file format in vim for it to work? :-k

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: Bought a BlinkStick

Post by ayu »

ph0bYx wrote:
19 Nov 2020, 05:47
Open /usr/local/bin/blinkstick in vim then do :set ff=unix and :wq
Wait, you need to set the file format in vim for it to work? :-k
Yeah the scripts came with Windows CR line endings. Took a while to realize that :|.
"The best place to hide a tree, is in a forest"

User avatar
ph0bYx
Staff Member
Staff Member
Posts: 2039
Joined: 22 Sep 2008, 16:00
15
Contact:

Re: Bought a BlinkStick

Post by ph0bYx »

Ouch! Hate when that happens.

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: Bought a BlinkStick

Post by bad_brain »

damn, here I was dreaming about something like a USB hub on the wall with one stick for each server I am running and the color represents the server status (triggered by server load or process count for example)....but then I saw all the APIs are for languages I have none to zero experience with... ](*,) :lol:
Image

User avatar
ph0bYx
Staff Member
Staff Member
Posts: 2039
Joined: 22 Sep 2008, 16:00
15
Contact:

Re: Bought a BlinkStick

Post by ph0bYx »

We could hack something for you :-k

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: Bought a BlinkStick

Post by bad_brain »

ph0bYx wrote:
19 Nov 2020, 17:12
We could hack something for you :-k
that's a really nice offer buddy....:D maybe something for the christmas time, I think I'll order 1 first and give it a try myself....and then give up after a few weeks and come back... :lol: :oops:
Image

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: Bought a BlinkStick

Post by ayu »

So far so good. No answer from their support yet though regarding the I/O errors, but my fix works good for now.
20201120_110858.jpg
20201120_110858.jpg (2.43 MiB) Viewed 7499 times
"The best place to hide a tree, is in a forest"

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: Bought a BlinkStick

Post by bad_brain »

ayu wrote:
20 Nov 2020, 04:13
PS: How do we fix size via bbcode?
simply upload/attach the image and display it inline, it'll automatically resize and link to lightbox when one side is bigger than 500px. :wink:
Image

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: Bought a BlinkStick

Post by ayu »

bad_brain wrote:
20 Nov 2020, 05:13
ayu wrote:
20 Nov 2020, 04:13
PS: How do we fix size via bbcode?
simply upload/attach the image and display it inline, it'll automatically resize and link to lightbox when one side is bigger than 500px. :wink:

That worked like a charm *thumb*
"The best place to hide a tree, is in a forest"

User avatar
ph0bYx
Staff Member
Staff Member
Posts: 2039
Joined: 22 Sep 2008, 16:00
15
Contact:

Re: Bought a BlinkStick

Post by ph0bYx »

Looks good! What size is it? Can you a banana next to it for scientific comparison? :D

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: Bought a BlinkStick

Post by ayu »

ph0bYx wrote:
20 Nov 2020, 07:00
Looks good! What size is it? Can you a banana next to it for scientific comparison? :D
Someone threw away my measuring bananas apparently, so here's some other items for comparison :P.
20201120_141227.jpg
20201120_141227.jpg (2.7 MiB) Viewed 7493 times
"The best place to hide a tree, is in a forest"

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: Bought a BlinkStick

Post by bad_brain »

measuring bananas...what happened to the good ol' days when it was a box of cigarettes... :o :lol:

I know it's kinda hard to capture, but can you post a pic in a (semi)dark environment? would like to see how bright it is....or is it non just on/off and the brightness also can be adjusted? :-k
Image

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: Bought a BlinkStick

Post by ayu »

bad_brain wrote:
20 Nov 2020, 15:30
measuring bananas...what happened to the good ol' days when it was a box of cigarettes... :o :lol:

I know it's kinda hard to capture, but can you post a pic in a (semi)dark environment? would like to see how bright it is....or is it non just on/off and the brightness also can be adjusted? :-k
Yup, will take another shot tonight :)
"The best place to hide a tree, is in a forest"

User avatar
ph0bYx
Staff Member
Staff Member
Posts: 2039
Joined: 22 Sep 2008, 16:00
15
Contact:

Re: Bought a BlinkStick

Post by ph0bYx »

That's a decent size, I might consider getting one as well although have no idea what to use it for (just yet).

Post Reply