BlinkStick (HPR Show 1971)

Dave Morriss


Table of Contents

Introduction

In late 2013 I noticed the local Edinburgh Hacklab were offering soldering courses building a BlinkStick. I offered to sign my son Tim up to the next course since he wanted to learn to solder. He couldn't afford the time at that point, but we agreed to buy some BlinkSticks to build at home.

This episode describes some of our experiences with building and using the device.

The version we bought and built was the v1.0 release, since that and the BlinkStick Pro were all that was available. The base version now available is v1.1, and there are several other products available from the manufacturer in addition to these. The company is called Agile Innovative Ltd, based in the UK.

Building the kit

The v1.0 BlinkStick kit came with a nice quality PCB, a male USB type A connector, resistors, diodes and capacitors, an RGB LED and a socketed ATtiny85 micro-controller.

Components of the BlinkStick
Components of the BlinkStick

The build instructions were great and very easy to follow. We had the suggested helping hands as you can see in the picture, as well as side and end cutters. The side cutters were better in general.

We added the six resistors first as recommended. For a first-timer this allows some chances to learn about bending the wires, properly and soldering neatly.

Note: I don't know which picture belongs to which BlinkStick in this group. Some are mine, and some are Tim's. He's now an excellent solderer and has recently taught himself how to do Surface Mount soldering, which is more than I can do!

Adding the resistors 1
Adding resistor number 1, before cutting the wires

Adding the resistors 2
Now resistor 2 has been added, as seen from the top of the board

Adding the resistors 3
Now resistors 3, 4 and 5 have been added

The polarity of the Zener diodes is important as was made clear from the instructions.

Adding the diodes
Now we have resistor 6 and have added the two diodes

Next the capacitors were added, again being careful about polarity. This was not difficult given the excellent instructions. We didn't take any pictures of this stage.

This was followed by fitting the USB plug which needs to be anchored to the board and soldered to the circuit, making sure it is straight.

Adding the USB plug
The underside of the board while the USB plug is being fitted

Next the IC (integrated circuit) socket needed to be soldered on ready for the ATtiny85 chip. Then the RGB could be added. It was a little difficult to get this level and close to the board as you can see from the next picture.

The RGB LED close up
The RGB LED close up

Finally, the ATtiny85 chip was inserted into the socket, making sure to get the orientation right. This completed the board as can be seen in the final image.

The finished board 1
The finished board side view

The finished board 2
The finished board from above

The software

There are Python, Ruby and Node.js versions of the software available on GitHub.

I installed the Python version thus:

$ sudo apt-get install python-pip
$ sudo pip install blinkstick

Just before preparing these notes I updated the software since it had been a while since I originally installed it:

$ sudo pip install --update blinkstick

Version 1.1.8 is the latest release at the time of writing.

This provides a command-line interface through the blinkstick command.

There is no manual page, but details of how to run the command can be obtained with the command:

$ blinkstick --help

Access to the BlinkStick device normally requires root access but the blinkstick command has the capability of creating a udev rule thus:

$ sudo blinkstick --add-udev-rule

Thereafter root permissions are not required. The rule is placed in the file:

/etc/udev/rules.d/85-blinkstick.rules

Note: In the audio I said that the BlinkStick device is visible as a /dev/* device. This is not strictly true and probably misleading. It can be seen when using the lsusb command, but is not a mounted device that can be seen with df, which is what I implied.

Some of the features of the blinkstick command are:

--brightness=LIMIT  Limit the brightness of the color 0..100
--limit=LIMIT       Alias to --brightness option
--set-color=COLOR   Set the color for the device. This can also be the
                    last argument for the script. The value can either be
                    a named color, hex value, 'random' or 'off'. CSS color
                    names are defined http://www.w3.org/TR/css3-color/
                    e.g. red, green, blue. Specify color using hexadecimal
                    color value e.g. 'FF3366'
--inverse           Control BlinkSticks in inverse mode

--blink             Blink LED (requires --set-color or color set as last
                    argument, and optionally --delay)
--pulse             Pulse LED (requires --set-color or color set as last
                    argument, and optionally --duration).
--morph             Morph to specified color (requires --set-color or
                    color set as last argument, and optionally --duration).
--duration=DURATION Set duration of transition in milliseconds (use with
                    --morph and --pulse).
--delay=DELAY       Set time in milliseconds to light LED for (use with
                    --blink).
--repeats=REPEATS   Number of repetitions (use with --blink and --pulse).

Details of the command line interface are available in the Python Wiki.

Simple use might be the following which sets the BlinkStick colour to blue:

$ blinkstick blue

By default the brightness is at the maximum, 100, but it can be turned down like this:

$ blinkstick --brightness=30 green

So, for example, in a script it is possible to make it pulse alternately red and green for 20 iterations like this:

for i in {1..20}
do
    blinkstick --pulse red
    sleep 0.5
    blinkstick --pulse green
    sleep 0.5
done

You can have more than one BlinkStick plugged in at any time. To address them you need to find their serial numbers:

$ blinkstick --info
Found device:
    Manufacturer:  Agile Innovative Ltd
    Description:   BlinkStick
    Serial:        BS000473-1.0
    Current Color: #002600
    Mode:          -1
    LEDs:          unsupported
    Info Block 1:
    Info Block 2:

Then to refer to a specific BlinkStick use the --serial=SERIAL option:

$ blinkstick --serial=BS000473-1.0 white

There is also a Python programming interface, as mentioned, and more information about this (with example code) can be found on the Python Wiki referred to earlier.

My use of the BlinkStick

My current project using the BlinkStick is quite simple. As an HPR volunteer I wrote a web scraper script to spot when a new show gets submitted and appears on the calendar page. I want to know this so I can run the show notes through the various scripts I am developing.

I run the scraper out of cron where it performs a check every 30 minutes. If there is something for me to check out I make the script generate a sound, write a pop-up message on screen and turn on the BlinkStick choosing the red colour.

I have a 7-port powered hub on my desk, and I leave the BlinkStick connected to this so that if the light comes on it's very obvious.

The script, called cronjob_scrape, is available on GitHub.

BlinkStick Pro

In 2014 I also bought a BlinkStick Pro from Agile Innovative. This device does not have any LEDs itself but can control a wide variety of other LED systems. I have not yet built this device and I don't have any specific projects for it.

I do have an Adafruit Neopixel 24-LED ring which I may use with this, but I would quite like to buy one of these reels of RGB LEDs on a self-adhesive strip and control it with the Pro.

I plan to do another HPR episode on the Pro when I have built it and set it up.