Much cute, such lights!

 

Yesterday (as I write this), Pimoroni, creators of the amazingly cute Bearables, put out the following tweet:

Just like that, all the work I was about to do for the rest of Friday evaporated.

I must admit, I did have some prior knowledge of this hidden capability – as Phil adorned me with a Bearable at CamJam, he informed me that ‘these are some power pins and a few data bus pins, sure you can figure them out’ – but I forgot to do anything about it… until now!

The first step to working out what was what, was to look at the chip. A bit of googling and it was found to be a PIC16F1503 microcontroller. With datasheet in-hand, a spot of multimeter probing between the controller and the pins and I had the pinout: Prog. Vref / SDa / SCl / Gnd / VCC. I highly suspected the Bearables used I2C for the comms, as the same chip is used on all of Pimoroni’s Flotilla line, where I2C is the main communication protocol. Makes sense, right?

After hooking it up to a Pi, and running a good ol’ i2cdetect, my suspicions were proven correct – the Bearable appeared as 0x15! I tried sending it some 1s and 0s down the command line (with, frankly no clue what I was doing – I have yet to delve into the world of raw I2C comms on a Pi) but nothing happened. I also found the rather excellent Raspberry Pi PIC Programmer, but I assumed that a full firmware rewrite wasn’t necessary. I also have absolutely no experience with PIC microcontrollers, and the programmer software didn’t support the chip in hand. Besides, everyone knows that Friday afternoons are not a good time to do important and serious things such as firmware flashing.

So I started looking for other approaches. The Bearables line also includes a range of sensors – perhaps I could fake a sensor and see what that did? After shoving 3.3v and Gnd down the sensor connections without much luck, I tried just shorting out the pins. This worked, kind of: once the badge was in sensor mode, you could sort-of-ish make stuff happen by shorting the lines. But, there seemed to be an erratic time delay between the connection being made and a change being seen, so it wasn’t going to work for a new pattern.

There’s only really one other interface on the badge: the button for changing modes/patterns. I noticed whilst poking around that if you spam it fast enough, it just interrupts the current pattern, instead of changing it to the next one along. To test this theory out, the switch was brutally removed from the badge, and the pads hooked up to an NPN transistor, with the base hooked up to the Pi again. I then wrote some very quick and dirty code (see below) to pulse the line as fast as possible. This had a pretty cool effect – it mostly made some rapidly flashing variants of the current pattern, but when it was on the chasing LEDs pattern you could get it to do almost single LED control. I had a new pattern!

The offending code:

from gpiozero import LED
from time import sleep
l = LED(3) 
x = 0.01
y = 0.002
while True:
l.on()
sleep(x)
l.off()
sleep(y)

I was all chuffed with myself and ready to have a nice, relaxing evening. And I did, for a bit. Until Team Underwood came along with their I2C knowledge and properly formatted code….

And, what’s more, the Underwood method uses the actual intended method – I was quite close to begin with! If only I’d read up on my smbus eh…  Their very proper code is online, which meant there was an opportunity for more hacking!

Over the course of the night (and early next morning) I produced….

Amazing what you can achieve with a little badge! And it’s really easy once someone else has written the code for you (thanks team Underwood!) If you haven’t got one, get one (just for the cuteness factor!) and have a go at programming it.

I quite fancy trying to write some firmware for a little ATTiny microcontroller that can be bodged onto the back of the badge….  maybe in the future.

Categories: hackingwearables

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

engineering

Hacking the K40 Laser Cutter

A while back, Norwich Hackspace (of which I am a member) invested in a second hand K40 Laser Cutter – the sort that are pretty darn cheap (for a laser cutter anyway) on eBay and other Read more…