Graceless tinkering


Tear it apart. Make it better. Fail!

Proximity sound box

A proximity triggered noise box based on Arduino UNO and VS1053.

Context

Boy, was this project a doozy! It's been a long time since I had some time to tinker, and the rust was showing.

Similar to the lighting controller, I worked on this project with my friend and bandmate Grig.

The project required creating a device that would play a beep, followed by a looping buzz when someone would enter an area. While the requirement was pretty clear the challenge was that we would need to build seven (yeah, you read that right!) such devices. Added challenges were that we would need to build them fast (in about a month), and that they would be installed in places where access to electrical sockets would be cumbersome.

With this in mind, I started to think of using an Arduino together with a VS1053 in favor of a Raspberry Pi, powered by some of-the-shelf powerbank. The prototype was built in a couple of days.

Geeetech provides its own Arduino library (here), but the code looks old and unmaintained, so I tried using the Adafruit code available on github (Adafruit also provides a VS1053 breakout board). The code took a few tries to get working since the pins are differntly labeled, but once we got them sorted out it was smooth sailing.

Component sourcing & first fails

Once the prototype was ready we started to haplessly look for components. It turns out getting some VS1053 breakouts would be a difficult hurdle. On the one hand there were some breakouts available in Romania but the price was ridiculously high (more than 30€), while on the other some really cheap ones ($3 - $5) were being sold on ebay, with no chance of arriving on time.

Luckly for us (or rather unluckly as we found out later), we bought the only seven VS1053 breakouts available in Europe at a cheaper price (around $17) from a seller in the UK!

With the main component on it's way I turned my attention to sourcing the rest of the components. Since we were trying to save a buck we opted for some diy Arduino Uno clones from Robofun (~14€). We also bought the ultrasound proximity sensor from Robofun.

Below is a montage of assembling the Arduino clones. The night I soldered these was by far the most productive time spent on this project (It all went downhill from there).

The last major components, a power bank and the cheapest USB powered speaker, were sourced from an online retail store. We opted for a beefy 20000mAh power bank without doing any power consumption measurements and hoped that it will suffice for a whole day.

All other minor components (resistors, transistors, linear potentiometers, switches, standoffs) as well as the enclosures were aquired from farnell.

Config PCB and software off switch

Since we had no idea where the soundboxes were going to be mounted, it seemed reasonable to have some configuration mechanism. I decided to build a small PCB that would accomodate a small switch, for switching between calibration and normal operation mode and a linear potentiometer for setting a distance threshold for the proximity sensor.

Later the PCB really came in handy in solving another issue we encountered. While testing we found out that most power banks have a undercurrent protection mechanism built in. While it is possible to switch it off in some power banks, the ones we had were impossible to reprogram.

Fortunately the internet came to the rescue! More specifically this article where Paul from DorkpotPDX encounters a similar problem. Paul's elegant solution was to build a two transistor oscillator circuit that periodically draws 230mA from the power bank, effectively resetting the undercurrent protection.

I decided on building a simpler version of the circuit, with a single transistor and a load resistance, and switching it on and off from the microcontroller. The two extra components would easily fit on the existing PCB.

This would turn out to be a brilliant idea, since this gave us the opportunity to implement a software off switch and get rid of any components required for a hardware off switch. The switch works as follows: when an object is placet near the proximity sensor (<4 cm) for more than a second the Arduino stops "pinging" the power bank. After a couple of seconds the power bank simply switches off. Amazing!

Software and hardware woes

Buying the last cheap, available VS1053 breakouts in Europe forced into a pretty tight corner! Rushing the order, I didn't notice that the breakouts didn't have a SD card slot, unlike every other breakout I saw before! This was really putting some serios pressure on us. I began looking at SD card breakouts and started dreading the thought of building another prototype just to test the two breakouts together.

However I had another trick up my sleeve! The sounds were basic enough, so there was a slight chance they would fit in the Adruino's progmem (~20kB!!!). Grig did all the work on this one, fiddled with bit rates, stereo/mono and output formats and managed to get the two sound files down to about 11kB! Spectacular! We used this small python script to convert the mp3 file to an array of constant bytes.

In the meantime, I retargeted the Adafriut VS1053 library from reading of an SD card to reading using read_prog_mem(). Of course I forgot that reading the progmem requires special functions and wasted half a day desperately indirecting const pointers like crazy!

While retargeting the Adafruit library, I also added the option of looping a sound file; however this doesn't seem to work well on all formats.

Another software issue we encountered was due to my rush to order the VS1053 breakouts. The ones that we orderd were "LC technology" branded, and didn't seem to work at all with the Adafruit library. Grig took it upon himself to get them working as I was franticly soldering everything together. As it turns out this is a known issue. This particular board is missing a trace, allowing the chip to boot in MIDI mode. The proposed solution involved soldering a bridge between two pins. However, I really wanted to avoid soldering two .5mm spaced pins so instead we opted for patching the Adafruit library once more as described in the comments of the previous article. It's worth mentioning that I later found out others did the same.

All our modifications to the Adafruit library can be found in this github repository; and below are some pictures of my desperate assembly line.

to be continued...