Raspberry Pi Project – A 1960s wallbox interfaced with Sonos

The inspiration for this project came from @nivnov pointing me to http://wallbox.weebly.com/. I had somewhat of a different take on the circuitry and software than it’s author, Steve Devlin. The pulse train of my Wallbox was also different. This is all explained below.

The Wallbox

A wallbox is a device dating from circa 1950s USA. It was placed on tables in diners to increase revenue from Jukeboxes. It contains no music, nor does it have a speaker. It could be considered a remote control for the diner’s main Jukebox.

I opted for a Seeburg Wall-O-Matic 100 Type 3W100. Wallboxes will be heavily mechanical with very basic circuitry. They will function such that a key combination will be output as a train of electrical pulses caused by an arm rotating over a set of electrical contacts.Raspberry Pi Project – A 1960s wallbox interfaced with Sonos

Powering the Wallbox

The wallbox would have, traditionally, been powered from the jukebox. To use it standalone for this project, an AC-AC transformer was required. My Wallbox required 25VAC at a maximum of 3 amps. I used a Torodial transformer, mounted with its mounting washers, in a die-cast aluminium box. It kicks out a lot of heat so the box acts as a decent enough heatsink.

The wall boxes are traditionally unearthed. This seemed like a bad idea so I attached an earth to it via one of the unit’s screws.

Interfacing with the RasPi

Steve’s circuit is floating and I managed to fairly impressively melt a RasPi by inadvertently forcing 25vAC through it via the gnd. In the end, I opted for a circuit that isolated the Pi from the Wallbox. A diagram is below:

For the uninitiated, an Opto-isolator is an LED and a light activated transistor bundled into a single chip – it’s like a relay. In my case a DIP. The left of the circuit connects to the Wallbox’s 25vAC and Signal terminals; the right connects to the RasPi. I also hooked up 4 LEDs to the Pi to provide some kind of debug output in the event of software errors.

Decoding Pulses

As I eluded to above, the key combination is electrically pulsed by a rotating arm. Steve had the good fortune of having an oscilloscope to hand; I sadly didn’t. Rather, I started on the code that would decode the pulses and, initially, used it as a timer. It was clear, after filtering jitter, that the pulse train had a clear time gap in it. In Steve’s case, this gap represented a break between the letters and numbers. In my case, it represented the 20s in a base 20 numbering system.

The pulse train is sequential to represent A1 through to K0. If X represents the number of pulses before the gap and Y represents the number of pulses after the gap, X increments from 1 to 20 whilst Y stays at 1. Y then increments and X resets back to 1. The cycle repeats through to X=20, Y=4 for K0.Raspberry Pi Project – A 1960s wallbox interfaced with Sonos schematic

The maths was thus:

  • Decrement both the pre and post gap counts as 0 is represented by 1 pulse
  • The letter is (2 * post-gap-count) + (1 if pre-gap-count is > 10)
  • If letter was worked out to be > ‘H’, add 1 as the wallbox doesn’t have an I
  • The number is the pre-gap-count modulus 10 (i.e. pre-gap-count % 10)

Handling kernel level interrupts came with some problems of its own. Most notably, having to think sort-of-thread-safe when writing the code. The interrupt can… well… interrupt code processing at any time. If this is part way through a calculation, things get funky. This code is what I came up with.

Interfacing with Sonos

The Sonos “API” is a UPNP bastardization and is, frankly, horrible. PHP being my strongest language, I thought this the best way to tackle it (hence the C code’s interface with an external programme). I forked a pretty crappy Sonos class on GitHub and set about fixing/improving it. I’ve added multicast Sonos device detection and, most importantly for my requirements, Spotify support. The resulting code is on my GitHub account. Also here’s my usage of the class.

 

For more detail: Raspberry Pi Project – A 1960s wallbox interfaced with Sonos


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top