High-speed liquid photography with Raspberry Pi

Sun 29 June 2014

Here's another round of bouncing liquids! These are all high-speed images of liquid being propelled off a speaker blasting sound. A picture of the setup is below. Three components are involved: 1) open camera shutter; 2) start playing sound; and 3) fire the flash. (Step 4 would be close the shutter again.) Coordinating all these events could be done manually, but it's easier with some brains to fix all the timing. In my case, I used a Raspberry Pi.

This is an update of an earlier post, but with better results. The improvements from last time included using a larger speaker, which allowed use of thicker whipping cream instead of milk, so these produced fewer droplets and more "columns". I also went with a hard-wired flash connection, since the cheapo wireless trigger which usually works pretty well, seemed to produce double-flashes about half the time.

Camera setup for splashing photography Setup

The electronics Electronics


My camera has a remote shutter jack, so I connected it to one of the GPIO pins on the Raspberry Pi through an optocoupler. With other cameras without a remote input, the shutter could be activated using a USB connection and gPhoto. I set the camera on full manual mode, with a shutter speed of about 1 second, long enough for the events to unfold...


The flash is also connected to a GPIO pin through optocouplers. CAUTION: If you do this, make sure your flash is low voltage at the hotshoe pins, or that you use an optocoupler that can handle the high voltage of some flashes! I got the inexpensive Yonguno 460ii just for projects like this one, and it only switches 3.3V, so it's ok. This is a nice flash to use for high-speed since the power (and flash duration) can be manually adjusted down to about 1/20,000 of a second. A hotshoe adapter or PC cable is needed to plug in to the flash.


Almost any old speaker will do. I found a rectangular speaker about 2" wide and 4" long that must have been ripped out of some unknown piece of equipment. Probably shouldn't use your nice living room speaker set for this, as it will get messy! I stretched a black balloon over the speaker (it stayed in place nicely on this rectangular shape without too much duct tape). And since this is just a speaker, it's not powered, so I needed a simple amplifier. I used an LM386 amplifier circuit (we don't really care about sound quality here), which can supply about 1W of power. That seems to be plenty to do the job. Oh, and unlike the photo above, put everything on a drop cloth to protect the nice table! There's a splash radius of about 18 inches...

The Brains

The Raspberry Pi forms the brains of the operation. It's job is to start the camera, play the sound, and fire the flash, all with the correct timing. A little python script can do that easily. Shut off the lights, pour a little liquid of your choice onto the balloon-covered speaker, and run the python code! It took some experimenting with the timings between events and with the camera exposure and flash settings to get a good image. The type of sound can be changed to maximize the speaker's impact (an 80Hz sine wave seemed best for me). Also different liquids produce different results, whipping cream was about the right consistency, balanced between being too thick to do much, and so runny that it just produced droplets.

The results

Here's my favorite images. You never know what's going to come out.