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:


Popular posts from this blog

Tea minus 30

We're fast approaching Christmas time.  And if robots were to make one simple observation about the human species during the Christmas festivities, it's that they watch a lot of TV.  A LOT.  Often, accompanied by an inappropriate amount of greenhouse gas-producing food.  Stuff you don't normally eat during the remainder of the year - for good reason.

And most so-called shows on TV are boring to robots like Rosie.  After all, why watch a minor subspecies of the human race - celebrities - stumble awkwardly around the dance floor, dressed like a faulty, sparking circuit board?  Such branch of entertainment doesn't require robots to engage any of their proud circuitry.  Their processors remain idle.  Memory under-utilised.

But if robots are to be part of people's homes (and blend in), they need to look at least a little interested in some of this irrational nonsense.  Nobody likes a party pooper.  A killjoy.  And this is where a certain subgenre of TV entertainment co…

Beam me up, Rosie!

How do you get from A to B?

You can't, as As and Bs are just letters in the alphabet. But if A is your house, and B is a meerkat village at your favourite safari park, you'd probably use a device equipped with GPS.  Not to be confused with UPS, who will deliver you your chosen meerkat through the post. And why on Earth would Rosie Patrol need one? Precisely, it's because she is on Earth that she needs one. Because our planet is rather big. Big enough to get lost in. And we don't want to lose our friendly plastic boxes on wheels. And maybe, eventually when she's clever enough, she'll go and defeat baddies on her own. And return home afterwards for a well deserved Earl Grey tea.

Besides, why wouldn't we want to add another three letter acronym to Rosie Patrol's repertoire?
All superheroes need:One Raspberry Pi 3, running Raspbian OSComputer from which you are connecting to the Raspberry Pi Probably the most important bit: a GPS receiver thingmy. …

Code: read

Humans are said to have 5 senses in total.  Common, clearly isn't one of them.

But - jokes aside - computers all around us are growing ever more intelligent (so we hear).  They can play chess.  Drive cars.  Some might even do these things at the same time.  Without crashing (quite literally).

Likewise, we've been making steady progress equipping Rosie Patrol with some useful skills.  Skills needed to bring much needed law and order to the world.  She can move.  She can see.  She can sense.  And in our last episode, she began to read.  With a little helping hand from some (considerably) bigger computers at the mothership that is Google.

But can she really read?  You know.  Read out aloud?

True to our style, there is only one way to find out.  It's time to invoke Code: Red Read.  And take the power of reading to the next level (or page).
All superheroes need:One Raspberry Pi 3, running Raspbian OS.  Connected to the Internet. Computer from which you are connecting to the R…