I spent yesterday in Liverpool at Howduino - billed as a “one day event about connecting the internet to the real world, breathing life into inanimate objects and creating new ways to interact with things”, it took place at FACT (somewhere that’s worthy of a blog post in itself).
Imagine a room full of geeks, artists and hackers who’d been let loose with soldering irons and toys, and then throw in the capabilities of Arduino boards. The end results ranged from painting with bristlebots through to circuit-bent Furbies.
I took my panda along, together with a box of analogue meters. Ebay is a fantastic source of that kind of retro kit, and I’ve picked up several moving-needle meters from the late 50s for less than a tenner each. The main plan, though, was to fit an old aircraft fuel-flow meter into the panda so he could display trends and changes in an easier-to-visualise way than the LEDs.
The meter itself is just a basic voltmeter with a dial calibrated from 0 to 800 lbs per hour - presumably it came out of some kind of jet, although I’m not sure how big an engine that would imply. There’s an XLR-style bayonet connection on the back, but I drilled two holes into the back of the case and soldered flyleads onto the internal terminals to make things easier. Then the panda got hacked open, and the meter was hot-glued into the wound.
Actually getting it to work was a bit of a challenge, however. The first problem is that the meter is incredibly sensitive - full-scale deflection takes less than 0.5 volts. The Arduino’s analogue outputs range from 0 to 5V, so I had to connect the Arduino output to a voltage divider (having first tried to figure out the right resistor values with a rotary potentiometer.) The PWM output from the Arduino runs from 0 (off) to 1023 (full on) with the duty cycle ranging roughly linearly between the two, so it’s just a case of adjusting the deflection to full-scale at 1023, and the rest falls into place.
The biggest problem, though, was with the Arduino itself. I’ve got a Ethernet shield which fits on top of the main board, and had that linked to an old ADSL router with a 4-port hub. Getting to the outside world took longer than I could be bothered with tinkering, so I ended up running a server locally on my Mac with MAMP to give the Arduino something to talk to.
Getting it talking needs the Ethernet library, and that’s buggy. It would connect fine the first time, but then crashed immediately you tried to establish a second connection. Adrian McEwan (who organised the whole thing) pointed me in the direction of a patched version, but I didn’t R the FM closely enough and only installed the library file. You actually have to remove the (old) compiled version as well - once I’d figured that out, the code started to function as it was supposed to.
The Arduino sketch establishes a connection to a server and grabs an XML file using the Ethernet methods. That then gets parsed using the unfeasibly low-tech string library and finally converts the XML value into a PWM value which controls the duty cycle of the analogue output. Because of the inertia of the needle, the pulses are smoothed out and the display reads steady.
The XML file could come from virtually anywhere - Pachube for example - but I’ve got a few Ruby scripts running on one of my servers that does some manipulation before creating the final values as XML. The challenge now is going to be the data source - and ideally something with a range from 0 to 800, and units of pounds per hour. Any suggestions?