Skip to main content


Ah yes.  We promised ourselves much needed downtime after a number of fairly hectic detours recently.

There's been a whole lotta Rosie recently.  We went in a bit hard with the sensors, servos and 3D printing. And the workshop is looking a tad thuderstruck as a result. What we could do with - now - is a soothing little distraction. A rest bite.  One that adds some long overdue razzmatazz to this highway to hell splendour of a journey.

After all, which roboticist doesn't love lights that flash meaninglessly? In inexplicable colours. At arbitrary intervals.  For no reason whatsoever. Great! Sounds like our kind of R&R.

Besides, the blog is still celebrating its 1 year anniversary.  As such, it's a perfect excuse to roll out this lighting rig to this rock 'n' roll party.

You don't want to be the tool without the tooling:

  • A Raspberry Pi 3, running Raspbian OS
  • Say 'EL-lo to your EL wire (no, that didn't quite work).  It should come with an inverter.  Because you'll need the AC to your DC.
  • Dust off the relay that's been stored away in a drawer somewhere, if you want to control this thing programmatically (of course you do).  A 4-channel relay will allow you to control a quartet of glitzy EL wires simultaneously.

Chequered history:

Building Rosie 2.0 - naturally - assumes that there is a Rosie 1.0.  For that reason, casting your eyes over the organised chaos that was Rosie and Rosie Patrol is highly recommended.

And then, there's also been the first few episodes of Rosie 2.0:
  2. Crawly creepy
  3. 2 crawly 2 creepy
  4. Balancing the books
  5. Shaken not steered

Bit by byte:

  • Take the EL wire(s) out of the packaging.  Toggle the switch on the EL wire inverter(s). Have a silent rave.  Get bored quite quickly.
  • Connect the relay to the Pi via its GPIO pins.  You've already done this a few times before.
  • ...Then connect the relay to the inverter(s) after doing (just) a little bit of hacking.  You're now ready to:
  • Write some Python code to control the inverters

You ain't seen nothing yet:

Reader: meet Electroluminescent Wire.  Electroluminescent Wire: meet Reader.  Except one of these names is ridiculously difficult to pronounce.  Which is probably why most people prefer to call it by its unfairly shortened name.  Let's try that again.  Reader: meet EL Wire.

EL Wire is... guess what... first and foremost: a wire.  Except it's got "EL" in front of it.  Which must mean it's special.  Probably because it's coated in phosphor, which as you might already know, is famous for being able to glow.  Which is why the material is often found in screens, lights and other random "glow in the dark" paraphernalia.  EL wire glows when an Alternating Current (AC) is applied through it.  What? We can control the glowy-ness of this thing electronically?  Now we're talking.

But hang on a second.  AC?  Everything we've been doing so far has been using DC.  About applying a current in one direction (from high to low voltage).  How do we play with current that alternate in direction?

And that's why you don't normally just get the EL wire in the little box; it comes with an ugly Power Inverter attached to it (used to convert DC from the batteries or other DC power sources to AC that can make the wire glow).  Incidentally the inverter unit normally has a toggle switch too - to allow you to cycle through various settings.

Do we want to mess around with a luminescent wire attached directly to our Pi?  Probably not.  It might explode like T.N.T. And that's why we'll use a relay to keep the two circuits as separate as possible.  We'll use the Pi instead to control the relay, which will perform the same function as an unsophisticated human brainlessly toggling the switch of the inverter.

Hmm. It sounds strangely like we might just know what we're doing in this post.  Let's see if this is actually the case. Let there be rock (and more importantly, some flashing El wire)!


Although EL wires are perfectly safe to use (and some even use them in their clothing), due to their use of AC, esteemed residents of the Web have reported that exposed terminals can cause a small electrical shock.  Always ensure that wiring and contact points are well insulated.

Moreover, use a sensible, low voltage power source (avoid high voltage) for your setup.  Couple of AA batteries appear to be the general preference.  Always read the instructions and warning signs that come with your purchase!

And when we - later on - open up the inverter unit to banish the switch and connect up our very own cables for the relay... well... Don't if you are not at all sure of what it is that you're doing.  Misplaced wiring - a live wire - could have some unintended consequences.

By the way.  Here's a legitimate question.  Why on Earth would we be talking about EL wire on a blog about building robots.  Simple.  Because - sometimes - additional sparkle, more lights, simply make technology look more advanced (than it actually is).  Good enough reason?  Tough.  You're stuck with us talking about how to make an untidy bundle of wire glow prettily for the remainder of this post.


After EL wires arrive through the post, and you untangle them badly, all at the same time, while being distracted by a TV documentary about why humans can't multitask, they look like this.  Here's a set of four wires in different colours.  Each attached to an ugly inverter unit.  Everything. In a mess.

We need to talk about the inverter.  In most cases (like here) they'll house the power supply (such as AA batteries), have a switch to let you toggle settings (flash frequency being the most common), and most importantly, contain the inverter that converts DC of the power supply to AC that lights the wire.  There might even be a little LED to show you what it is that it's doing. More lights the merrier.

Press the switch a few times when we're back in black, and you'll see that the entire display works just fine out of the box.

The switch on our inverter unit allows us to cycle through various settings.  With each push, the light can be continuously on, flash slowly, or rapidly.  Not very exciting so far, we realise.

But we did say we were going to control this thing programmatically.  Using Python.  Let's whip out our relay, attach it to the Pi, so we can simulate the switch presses using... [cue the power ballad guitar riff]... the power of code.

Relay PinPi GPIO PinDescription
GroundAny 0V Ground (e.g. 6, 9, 14, 20, 25, 30, 34, 39) 0V (Ground)
VccAny 5V (e.g. 2, 4)Used to power the relay
Vin8 (BCM 14)Used to operate the relay
CommonN/A (Inverter)For closing and opening the circuit like a switch.  Connect to one end of where the circuit needs to be closed.
Normally OpenN/A (Inverter)For closing and opening the circuit like a switch.  Connect to the other end of where the circuit needs to be closed.

Nice and simple so far.  5V and 0V (Ground) connections to power the relay, and a GPIO pin to send switching signals.

But wait.  What do we connect the relay to? Where's the jack?  This will indeed require a bit of hackery.  Exactly like we did before with our head torches.  You'll have to find a way to "inject" the relay into the circuitry of the inverter unit to emulate the effects of a mechanical switch.

Once we opened our unit, the two points of interest became pretty clear.  Why?  Because it were the only two locations where the legs of the switch were soldered in place.  We un-soldered these switch legs, and soldered in two cables in its place.  Make absolutely sure you are doing this on the DC side of the circuit board.  Don't go anywhere near the AC.

Using Dupont cables, the two wire ends can simply be plugged into the Normally Open (NO) contacts of the relay.  Sequential close and reopening of the relay will simulate the press of the now departed switch.  Reseal the unit, and we should be ready to go.

As for Python, you won't need anything remotely sophisticated to control the relay.  We created a class ELWireInverter, which can be instantiated with the GPIO pin of the relay channel (14 in our case).  Then the simple set_state() method allows us to momentarily close, then re-open the circuit via the GPIO pin.  There's a bit of logic here using our INVERTER_STATES tuple to (attempt to) track which state the EL wire should be in depending on the number of signals sent to the relay so far.  Of course, there is no feedback back from the inverter unit.  So the state in Python is just a guess that will go out of sync if events happen outside of Python (such as someone removing battery, or closing the switch manually).

Here's the final code we ended up with:

And here's how we test it.  Launch IPython and run through this at your own leisure.


Not many steps here.  Import the rosie_el_wire module, instantiate an EL wire object (called el1), and run its set_state() method.  If you feed the method the desired inverter state, you should hear the relay click the required number of times.

import rosie_el_wire
el1 = rosie_el_wire.ELWireInverter(14)

Note that if we try and set the state to a value which doesn't correspond to one of our known states (defined in our tuple upfront), we've coded the method so that it throws a ValueError exception.  If this snippet is part of a larger program, you would handle this exception in a way that makes sense to your program.

We should also see that the states wrap around.  That is, once it reaches the final state listed in the tuple, it'll reset itself to 0.  Just like how the inverter unit behaves.

Here's a video of how the red EL wire looks as we cycle through the settings using Python:

That's about it, since we're running this manually and we really can't be bothered to touch too much. Not very exciting, eh?  Of course, you could beautify this, using maybe APIs based on Flask, or a HTML web page with buttons to control the light.  More than likely, flashing the EL wire is an outcome of a whole bunch of code that precedes it.  Like a warning to indicate that a rare species of badger has been spotted in your garden.

Still, it's been nice to tackle a somewhat relaxed, soothing mini-project for a change in-between our more chaotic robotics escapades. Nope. We didn't really learn anything new here (other than that some wires can light up impressively when AC is applied to it). But sometimes, it's just great to have the downtime. And de-stress, and watch, tangled wires randomly glow in the dark. Ahh. Hells bells. We think we just heard another PLA filament arrive through the post. Load up the STLs. Normal service will resume shortly.

Go and see the doc:

There are some interesting facts about EL wire on the Adafruit website here:



LoRa-Wan Kenobi

In the regurgitated words of Michael BublĂ©: It's a new dawn .  It's a new day .  It's a new Star Wars film .  For me .  And I'm (George Lucas, and I'm) feeling good .  Unfortunately for Canadian Mike, the Grammy that year was won by the novelty disco classic with the famous refrain: We love IoT, even in Planet Tatooine * . *Not true. Clearly, the Star Wars producers didn't sincerely mean the last Jedi the previous time around.  Return of the Jedi, released during the decade that spearheaded cultural renaissance 2.0 with the mullet and hair-metal , was less economic with the truth.  Either way, we're going to take inspiration from the impressive longevity of the money-spinning space-opera and reboot our franchise with some Jedi mind tricks.  Except this particular flick doesn't require an ever-growing cast of unrecognisable characters, unless ASCII or UTF counts.  In place of an ensemble gathering of Hollywood stars and starlets, we will b

Battle of BLEtain

The trolling . The doxing . An army of perplexing emojis. And endless links to the same - supposedly funny - viral video of a cat confusing a reflection from a dangling key for a golden hamster, while taking part in the mice bucket challenge. Has social media really been this immense force for good? Has it actually contributed significantly to the continued enlightenment of the human (or feline) race? In order to answer these poignant existential questions about the role of prominent platforms such as Critter, StinkedIn and Binterest, employing exceptional scientific rigour equal to that demonstrated by Theranos , we're going to set up a ground-breaking experiment using the Bluetooth Low Energy feature of MicroPython v1.12, and two ESP32 development boards with inexplicable hatred for one another.  And let them hurl quintessentially British expressions (others call them abuse) at each other like two Wiltshire residents who have had their internet access curbed by the co

Hard grapht

You would all be forgiven for assuming that bar , pie and queue line are favourite pastimes of the British .  Yet, in fact – yes, we did learn this back in GCSE maths – they are also mechanisms through which meaningless, mundane data of suspect origin can be given a Gok Wan -grade makeover, with the prime objective of padding out biblical 187-page PowerPoint presentations and 871-page Word reports (*other Microsoft productivity tools are available).  In other words, documents that nobody has the intention of ever reading.  But it becomes apparent over the years; this is perhaps the one skill which serves you well for a lifetime in certain careers.  In sales.  Consultancy.  Politics.  Or any other profession in which the only known entry requirement is the ability to chat loudly over a whizzy graph of dubious quality and value, preferably while frantically waving your arms around. Nevertheless, we are acutely conscious of the fact that we have spent an inordinate amount