3D Printing Bacteria, It Smells! 🦠

How to Hack Your 3D Printer to Draw With Colorful Bacteria

Uri Shaked
8 min readJul 25, 2019

3D Printers can create static objects, and sometimes even flexible/dynamic objects. But how about printing living cells?

In this article, I am going to share the story of how I programmed my 3D Printer to draw with live E.coli bacteria! But first, let me tell you how I even got these bacteria to begin with:

Meet The Purple E. coli 🧫

It all started when I got an Amino Labs Engineer-it Kit. This $35 kit is a “Hello World” biology experiment, where you take E. coli bacteria and “install” a new gene in their DNA. If you are not familiar with them, E. coli also live inside our guts and help us by producing vitamin K₂ and keeping harmful bacteria away.

Preparing the Petri dishes

The purpose of the experiment is to insert a new DNA sequence into the E. coli genome. This new sequence encodes a gene that produces a purple pigment, thus turning the E. coli purple. This is a multi-step process that takes about 2 days to complete. The main steps of the process are:

  1. We prepare Petri dishes with a gel containing nutrients for the bacteria (that’s called LB Agar gel), and antibiotics (more on that soon).
  2. We take some E. coli bacteria and put it in a small tube together with the DNA molecule that we want to insert (called “plasmid”), mixing the two together.
  3. We do the “Transformation” — that’s the process where some of the bacteria will ingest the DNA plasmid. It involves cooling down the bacteria to 4ºC, giving them a 42ºC heat-shock for two minutes, and then cooling to 4ºC again. We add some nutrients to the tube to help the bacteria recover.
  4. Finally, we pour the content to the tube into a Petri dish, and put it inside an incubator for a day or so (I used a cheap egg incubator I found online).
Ice bath for the bacteria! (after they got a heat-shock)

Antibiotics? 💊

At this point, you are probably asking yourself — why do we need to use antibiotics? After all, we want the bacteria to grow, not to die!

The reason is that most of the bacteria in our tube are not going to get any DNA, so most of the bacteria won’t produce the purple pigment. Thus, we use a simple trick of selection to keep only the transformed bacteria (who ingested our DNA plasmid) alive: we also give them a gene that makes them antibiotics-resistant.

This method ensures that only bacteria who received our DNA plasmid grow on the Petri dish, while all the other bacteria we had in the tube die. Yes, I know, science can be sometimes cruel!

But aren’t we creating a hazard by creating antibiotic resistant bacteria? Actually, the resistance gene is specific for the type of antibiotics that we have inside the medium in our Petri dish, chloramphenicol, and there are already some E. coli strains that are naturally resistant to this antibiotic. In addition, we kill and discard the bacteria when the experiment is done.

Incubating the bacteria

O Tiny Purple Friends, Where Art Thou? 🤔

The initial results of the experiment were quite disappointing. After incubating the bacteria for 24 hours, I could only observe one small dot of bacteria, and it only had a tiny hint of purple tint:

Can you spot my little bacteria colony?

But hey, at least there is something. This small colony probably grew from a single bacterium (E. coli multiply really fast, every 17 minutes or so), meaning that my transformation (inserting the DNA into the bacteria) wasn’t very effective. Who said science is easy?

Anyway, I left home and checked the plate again at night. This time, the colony was much more prominent, as the bacteria had more time to produce the purple pigment:

Bacteria and The City. Pink or Purple?

So technically, the experiment has been a success. But I was not satisfied at all!

Drawing with Bacteria 🎨

I wanted a more visually appealing result, so I took a wooden stick and used it to pick up some of the bacteria from the single colony I got, and then smeared the bacteria over the rest of the plate. I tried to spell the Hebrew word סגול, which means purple, and waited for another 24 hours.

And then… I saw this:

Sky is the limit!

Wow, this was so much better!

And it also led me right into my next project:

3D Printing Bacteria 👩‍🔬

Last year, I designed a small part that would allow me to attach pens and pencils to the printer’s head, and turn my 3D printer into a plotter. I created a workflow that would allow me to take any vector graphics file (SVG file) and draw it on a piece of paper using the printer. You can check out the blog post I wrote about the project: “How to Turn Your 3D Printer into a Plotter in One Hour?

I realized I could use the same setup to machine my 3D printer draw with bacteria. Instead of a paper, I’d mount a Petri dish with LB Agar medium, and will dip the pencil in the purple bacteria colonies just before hitting the “Print” button. I quickly designed some graphics in Inkscape:

I then carefully measured the height of the LB Agar substrate and found the Z offset where the pencil held by the printer would touch just the top of the agar (that was 18.5mm). I used Inkscape’s Gcodetools plugin to generate a GCode file — that is a text file with instructions for the printer. You can find the specifics in my previous blog post.

Finally, I wrote a short python script that would fix some syntax issues with the GCode. More specifically, I changed the movement speed of the printer, the syntax of the comments (line 8–9), and only kept the movement commands (lines 10–12):

I sent the generated GCode file to the printer and did a dry-run (without the actual Petri dish), observing the movements of the printer’s head and making sure everything looked fine. Then, I dipped the tip of the pencil into the purple bacteria culture, loaded the Petri dish onto my printer’s bed, and hit the Print button:

This was fascinating to watch

Again, I had to wait another day for the results. And just like the first time — this wasn’t a complete failure, but far from satisfactory:

My initial results — only 3 small strokes!

It wasn’t very straightforward to me how these 3 short lines actually relate to the original drawing, but after some work, I managed to make the connection, as you can see below:

This is a very interesting result: I only dipped the pencil into the bacteria once, at the start of the process, but for some reason it seems like the bacteria only caught on very specific segments of the drawing. These points are all near the edges of the plate, so perhaps the agar layer was a little taller there and thus caught the bacteria? No idea!

Anyway, I decided to give it another go, but this time:

Dip & Shake Shake Shake 🧪

For the second version of the experiment, I met with two friends, Gita and Gadi, and tried a new process: this time, the printer will pick new bacteria from a solution after drawing each segment of the graphics. We also used a disposable wooden stick in place of a pencil.

Improvised lab: Gadi preparing the printer setup while I am working on the Python scripts 🧬

We started by measuring the Z-offset where the wooden stick would touch the agar, just like I did during my previous attempt, and then Gita prepared a solution with purple bacteria and LB broth (that is bacteria food):

Next, we used a double-sided tape to stick the tiny tube cap with the solution to the 3D Printer bed, and moved the printer’s head with the wooden stick to be just above the tube cap, noting the exact the X and Y position of it:

Calibrating the exact X/Y position of the purple bacteria solution

We then slowly moved the printer’s head down until we found the Z height where the wooden stick would dip into the solution. You can see that we also attached a sheet of paper to the printer’s bed — and we even drew the graphics on it (using a pen and the method outlined in my previous post), so we could accurately place the Petri dish in relation to the graphics.

With everything calibrated, it was time to update the Python script — I updated it to add a new piece of GCode before drawing each segment. This new GCode would move the wooden stick just above the bacteria solution, dip it, and then shake vigorously, so that we had fresh bacteria on the tip of the stick before each line we draw:

PAINT_X, PAINT_Y and PAINT_Z are the coordinates where the wooden stick would dip into the solution, MOVEOVER_Z is a Z coordinate where the wooden stick can safely move above the Petri dish, and SHAKE_RADIUS is how many millimeters to move to each side when shaking. Lines 22–25 take care of the actual shaking motion.

Finally, it was time for some action:

And then, incubate for 24 hours:

This time “printed” 6 different Petri dishes

Finally, after 24 hour long wait, we were excited to see the results:

Our 4th dish turned out great!
Dish #1 wasn’t too bad either!

WOW! This Actually Worked! 😲

As I said before, science is hard. My original experiment has almost failed, leaving me with a single bacteria colony. The results we got so far are very encouraging, and I find it amazing you can achieve this with $200 3D printer, a couple of tubes and wooden sticks, and some software hacks.

We are definitely going to experiment more with the process and try to:

  1. Improve the resolution by using a finer stick
  2. Add new colors and find a way to switch between different colors
  3. Pour the agar more consistently so we don’t have to re-calibrate for each plate

So, what should we print next?

Made with ♥ using engineered bacteria



Uri Shaked

Google Developer Expert for Web Technologies, Maker and Public Speaker