Review: Pimoroni/Cyntech Pibrella

There is no shortage of clip-on boards designed for the Raspberry Pi, almost all designed to make the tiny computer’s GPIO pins more accessible in order to ease the connection of devices to it, particularly ones that operate at voltages that are not Pi friendly.

For instance, I have a PiFace Digital which provides screw-lock wire attachments, switches, LED indicators and relays. It’s downside, perhaps, is that it doesn’t provide the Pi’s GPIO with better connectivity so much as use the GPIO to deliver its own different set of inputs and outputs. So projects for raw Pis need a little extra thought before they’re implemented on a PiFace.

Pibrella

Electronics kit: Pimoroni/Cyntech Pibtrella

Yet this ‘embrace and extend’ approach is the one Pimoroni and Cyntech have taken with the Pibrella, one of the latest Raspberry Pi add-on boards. If the PiFace Digital is the BBC Micro Model B of the Pi add-on world – big, expensive, feature-packed but possible function overkill for most users – then the Pibrella is the Sinclair ZX81: cute, cheap, cheerful but rather more rudimentary.

What we have is a small, purple board with a buzzer, three LEDs bulbs – a traffic light set comprising one each of red, green and yellow – a button and eight IO ports with female connectors. Four of the ports are inputs, the rest outputs; all are connected to on-board surface-mound LEDs.

Compare that to the eight LEDs, two relays, four switches, eight digital inputs, eight open-collector outputs and seven jumper blocks of the PiFace Digital. The PiFace looks like a serious bit of electronics; the Pibrella looks like a toy.

Pibrella

Pibrella provides four inputs, four outputs, three LED bulbs, a switch and a ‘buzzer’

But it’s not entirely unsophisticated. For example, Pibrella has an I²C bus header, though it’s currently pin-less and not readily usable. The board also has a micro USB port for driving connected devices that need more power than the Pi can provide but which, handily, will also drive the Pi the board is connected to, through the GPIO.

All of the Pibrella’s useable components are made accessible through a new Python library – just as PiFace’s are, incidentally – which neatly abstracts away all the Raspberry Pi GPIO stuff which you might otherwise need. This makes it very easy to target specific parts of the Pibrella, clearly and unambiguously.

The IO pins are all clearly labelled A through H, and this is how you address them in code, with no need to worry about pin numbering – pin location or chip GPIO assignments, all of which are different on the Pi itself – or which version of the Pi you have.

Pibrella

The Pibrella’s micro-USB port can power the Pi – or drive high-power connected devices

The buzzer comes with a couple of pre-defined tones, set in the library, though they didn’t sound very different from each other – or appealing – to me. It reminds me of the crude noise make that came with the electronics kit I got for Christmas 1981. A true tone generator it ain’t.

Just as the Pibrella library incorporates pre-defined noises, it also includes some set light patterns, including fades and blinks, which can be applied to each of the LEDs, so there’s some ‘my first project’ fun to be had here.

The four inputs and four outputs all feature both positive and negative terminals, effectively giving each one its own GND terminal. Like PiFace’s outputs, Pibrella’s outputs have activity LEDs to tell you when something is happening, but so do the inputs.

Pibrella

Attention to detail: the Pibrella has a pad to sit the add-on on the Pi’s capacitor

Watching out for, and responding to, occurrences has a deeper meaning with the Pibrella. What particularly appealed to me, as a programmer, is that the Pibrella introduces users to event-based programming techniques: the notion that code simply responds to external actions. This is, of course, how apps for modern operating systems are programmed: they do little or nothing until the user interacts with the UI, or data comes in from the network, say. But it’s not a common approach with embedded devices, such as Arduino.

The Pibrella introduces this, in a small, ‘ease you out of the shallows’ way, through a number of its library functions. These take the name of a function which will be called when a certain event takes place – if it ever does.

So rather than poll a pin to see if the Pibrella’s red button has been pressed, there’s a function, pibrella.button.pressed(), that waits until the button is pressed and, if it is, calls another function – a ‘callback’, in the jargon – you’ve defined and passed to pressed().

Pibrella

Serious and not-so-serious: PiFace Digital (left) and Pibrella

Likewise, the changed() function, available to any of the board’s eight IO pins, once registered with a callback function, will wait for the nominated pin to change its state and then call the named function.

To be fair, a lot of the event monitoring functionality comes from the regulation RPi.GPIO module for which the Pibrella library is a much more newbie-friendly wrapper. But top marks to Pimoroni for putting event-driven programming on the agenda in such a non-scary way. Understanding how this technique works is a big step toward being able to program desktop and mobile operating systems effectively.

Verdict

The £10 Pibrella is a nice little Pi add-on for young kids and it’s a fine basis for programming lessons where a teacher wants children to write code that makes things happen in the real world rather than on screen.

Older novices may find it appealing too, for the same reasons, but I suspect that once they’ve worked their way through the sample programs – which won’t take long – they’ll put the Pibrella aside and start working on more complicated projects with resistors, wires, motors and stuff.

Pibrella

That’s not to say such projects can’t be connected to a Pibrella, but that new Pi users growing in confidence are going to want to interact with their machines more directly and, not to put too fine a point on it, want to work with kit that looks a little less like the result of a kid’s electronics kit toy.

The Pibrella isn’t a toy – at least not entirely – but in hardware terms it’s a step to more interesting things not a destination in its own right. Just make sure you take advantage of its entry into the world of event-driven programming on the way.

Pibrella is available now from Pimoroni and Cyntech

How to build your own Apple iBeacon… with a Raspberry Pi

US department store Macy’s recently said it is implementing iPhone-based tracking tech the better to encourage browsing punters to buy. Of course, Macy has chosen to pitch this as an Apple technology – figuring, presumably, iPhone owners are more receptive to inducements delivered through technology and have more cash to splash than Android fans.

But the fact is, the system Apple calls iBeacon simply makes use of features already part of the Bluetooth Low Energy (LE) spec.

A Pi's UART pins, connected

Can this operate as an Apple iBeacon? Yes it can

This got me thinking: how difficult would it be to build a similar system of my own? Not very hard at all, it turns out. Choose the right kit and it can be quite cheap too. I created my beacon using a £30 Raspberry Pi and a £12 Bluetooth 4.0 USB dongle.

Continue reading

How to program the Pebble smartwatch: Part 3

Update Pebble has released version 2 of its OS and this invalidates much of what follows, which was written for an earlier version of the OS.

As it stands, the app I created in Part 2 appears in the Pebble’s menu simply as a name, Ball, which is entered into the boilerplate PBL_APP_INFO created by the SDK’s create_pebble_project.py script. This also sets the app’s unique UUID, which you’ll see at the top of the file. You can also modify this to set the app’s version number and to add your name as author.

But what’s really needed is a menu icon, and you can add one by editing the resource_map.json created for you in the /resources/src folder within the project folder.

Continue reading

How to program the Pebble smartwatch: Part 2

Update Pebble has released version 2 of its OS and this invalidates much of what follows, which was written for an earlier version of the OS.

In Part 1 we got our basic Pebble app up and running, but it doesn’t do very much. Let’s add some user interaction.

To respond to button presses, Pebble OS now uses a system akin to its event handling mechanism, the better to help the coder give the user more ways to control the three-button watch. The new approach lets you directly accommodate single clicks short and long, double-clicks, and press-and-hold events, rather than simply waiting for a push on a specific button and then trying to anticipate the user’s intentions.

The Pebble SDK, then, defines a ClickConfigProvider entity which is essentially an array of function calls for specific buttons and the various ways each of them can be used. This list of calls is attached to the host window. First, we need to add the line

    window_set_click_config_provider(&window, (ClickConfigProvider)config_provider);

to the handle_init() initialisation function, and we need to run it after the app’s Window – reached using the pointer variable window – has been pushed onto the OS’s Window stack, or it will be ignored. The above line tells the window where to get its array of button configurations from, which it does by calling a second function, the config_provider passed in the first call.

Continue reading

How to program the Pebble smartwatch: Part 1

Update Pebble has released version 2 of its OS and this invalidates much of what follows, which was written for an earlier version of the OS.

Pebble didn’t invent the smartwatch, but it has done more than most to bring this new product category to the attention of the world, largely thanks to its hugely successful and well-reported Kickstarter funding campaign.

Pebble’s smartwatch – also called Pebble – remains one of the few of its kind that go beyond duplicating a host phone’s notifications and messages on its own screen. Pebble will do all that of course, but much more interesting is the SDK Pebble provides to allow C programmers to create clever new watch faces and, better still, native apps to run on the smartwatch’s 144 x 168 black-and-white screen.

Pebble

Your app will appear below the Pebble’s Settings icon

Continue reading