An accurate DNA strand model

Any genetics lab or DIY biohacker needs to be able to visualize DNA and RNA, and a common technique for doing so is agarose gel electrophoresis. The sample is loaded into wells along one edge of the gel, and then a voltage gradient is applied to the gel, attracting DNA and RNA to the anode due to their negative charge. Smaller DNA and RNA fragments migrate through the gel more quickly, resulting in fragments being separated by size.

A dye in the gel binds to the DNA or RNA and fluoresces under ultraviolet light, so we use a UV transilluminator for visualization after the gel is done running. Typically a DNA “ladder” is added to one or more wells, giving a consistent set of bands that the researcher can use for estimating the fragment size of the samples. It’s also possible to slice out sections of the gel to isolate and purify particular DNA fragments.

Our lab has a UV transilluminator, but for taking gel photos we had been reliant on using imagers in other labs. It’s slightly inconvenient (and slightly hazardous) to have to walk around the building carrying an ethidium bromide gel, plus if you don’t have a key to the other lab you are dependent on their schedule, and I hate to impose. I’d been thinking of trying to make an imager using a Raspberry Pi, so when the imager at one of our go-to labs broke down, I finally did it. I don’t know much about optics so I did a bit of research online and found people who had done similar things.

The whole thing cost our lab about $150. A couple caveats: 1) It doesn’t zoom or focus. I am OK with this since the camera is positioned such that it can get a decent picture of any gel. If I need a publication-quality image, I’ll consider other options. 2) I just used a styrofoam box rather than buying or constructing something fancier. We already have the UV transilluminator in a separate room with UV face shields available. If you want to have this setup out in the open in your lab, you might need a box that will completely contain the light from the transilluminator.


If you’re new to Raspberry Pi, visit this tutorial for step-by-step setup instructions.

Once the Pi and camera are set up, take some test pictures of a printed sheet of paper by typing:

raspistill -o ~/Desktop/test.jpg
to see how far away you will want the camera to be from your gel (i.e., make sure you have the right size styrofoam box). Maybe get someone to lend you a second pair of hands, holding the reading glasses in front of the camera while you snap some pictures. The part of the camera board where the cable goes in corresponds to the bottom of the resulting photos, although you can always rotate photos later.

Project Steps


Flip the styrofoam box upside down. In the center, trace around the camera filter. Then draw a smaller circle within for the “aperture”.

Cut the aperture hole straight through the box. Widen the aperture as much as you can while still leaving a rim to hold the filter.

Carve out a shallow circle to seat the filter — you may even want it to fan out in a cone shape underneath.

Pop a lens out of the reading glasses and place it atop the filter.

Alternatively, you could position the pair of glasses so the center of one lens is right in the center of the filter, then trace around the glasses. Carve out a shallow trench that the glasses will sit in — they’ll need to be immediately next to the Pi camera.


Attach the camera to the Pi with its cable.

Unfold a couple of large paper clips, bend them in half, and thread them through the holes in the camera board. Then press the paper clips into the box to position the camera right above the lens.

Use duct or packing tape to secure the filter, lens, and Pi, making sure not to cover any port you need.

I took a few test pictures here to make sure I was happy with it, and also widened the aperture a bit more at this point. Then I taped aluminum foil over the assembly to block out ambient light.

Below is my final setup on top of the transilluminator.


You’re ready to take pictures of actual gels! By default, raspistill shows a preview for a couple of seconds before taking the picture, in which time I can shift the box a little bit in order to line it up right.

Just like a regular computer, you can stick a USB flash drive into the Raspberry Pi to retrieve your image files.