0%
Loading...

Hardware

The two devices we built for MOSAIC — RATIO Pocket and RATIO Bench — and what it takes to rebuild them.

Hardware

Hardware

Overview

The problem we set out to solve

In our project, the gene arm of the mother bacterium can undergo inversion, producing a bacterial suspension containing a mixture of multiple progeny bacteria during proliferation. Efficiently determining the abundance of different bacterial types in the suspension is a key step towards applying our system. Hardware therefore aims to build a low-cost device that can rapidly detect the ratios of different bacteria in solution.

Through communication with the Wet Lab department, we learned that by designing genes on the inversion arm, different progeny bacteria can produce pigments of different colours. So a mixed bacterial suspension with a specific ratio corresponds to a specific colour. If we can establish a mapping between solution colour and bacterial ratio, we can infer the bacterial ratio by measuring the solution colour.

We answered that with two independent devices. RATIO Pocket reads the colour with a smartphone camera; RATIO Bench reads it with a dedicated four-channel colourimeter. Each is described in its own block below.

Assumption: what the colour tells us

The whole colour-to-ratio argument rests on one assumption: the amount of pigment a cell produces is proportional to the number of cells, so that the pigment concentration in the suspension reflects the cell concentration. Under that assumption a mixed suspension at a given ratio maps to one reproducible colour, and measuring the colour is equivalent to measuring the ratio. If pigment production were to vary independently of cell number — for example between strains, growth phases or batches — the mapping would no longer hold.

For the measurements in this work, the chromoprotein-expressing cells were not yet available in the wet lab, so two food-colouring dyes were used as substitutes for the bacterial pigment: Brilliant Blue FCF (Blue No. 1, absorption peak ≈ 630 nm, mainly reducing the R channel) for the blue component, and Tartrazine (Yellow No. 5, absorption peak ≈ 427 nm, mainly reducing the B channel) for the yellow one. The dyes play the same role in the optical path — they absorb selectively and colour the solution — but they are not the same molecules and do not reproduce cell scattering or sedimentation. The calibration reported here should therefore be read as a validation of the measurement principle rather than a finished biological calibration.

Hardware

RATIO Pocket

Introduction: a low-cost ratio detection platform

To realise the initial aim of a low-cost and accurate device, we turned to a common electronic device — the smartphone — hoping to use its camera and sensors for detection. After reviewing the literature, we found an app, phyphox, developed by RWTH Aachen University, Germany, which can turn a smartphone into a portable laboratory for quantitative physics experiments. Its functions meet our experimental needs. So, standing on the shoulders of giants, RATIO Pocket was born.

The phyphox app icon: a white smartphone outline on a dark rounded square
Figure 1-1. phyphox app.

RATIO Pocket consists of a smartphone, the phyphox app, a data processing program we wrote, and a light-blocking housing.

The 3D-printed housing provides an operating platform that allows us to collect sample data with the smartphone. phyphox records and exports the sensor data; our program processes it. These three parts constitute a low-cost, easy-to-replicate, portable measurement platform that correlates the colour of the liquid under test with the substance ratio.

Photograph of the finished RATIO Pocket device, assembled on a bench Second photograph of the finished RATIO Pocket, from the side
Figure 1-2. The finished device.

This page focuses on the smartphone optical detection method. We build on the smartphone — a device everyone owns — and design a detachable, low-cost structure to obtain biological signals.

The housing of RATIO Pocket: Voyager

The overall measurement device is cylindrical and mainly divided into three parts: a liquid chamber for holding the sample, an LED base providing illumination, and an adjustable light aperture. There is also a detachable folding phone holder for laying the smartphone. CAD modelling files and the bill of materials are listed in Materials and files.

The design is centred on light blocking, stability, portability and easy sample replacement, enabling the device to be quickly assembled and reused in a non-specialist laboratory environment.

Loading the 3D model…

0%

Drag to rotate · pinch or Ctrl+scroll to zoom

Figure 1-3. The assembled device, in three dimensions. Drag to turn it, or pull the slider to separate the parts.
Rendered 3D model of the assembled RATIO Pocket: a cylindrical body on a base, with the light tunnel on top
Figure 1-4. Whole device 3D model.

Structure 1: the door of the liquid chamber

We designed an easy-to-open door for the liquid chamber: slide it upward to open, and it can be fixed in place, facilitating one-handed operation and shortening sample replacement time.

The liquid chamber also has a light-blocking structure to reduce light leakage, allowing convenient sample replacement while ensuring no ambient light interference after the door is closed.

Rendered 3D model of the liquid chamber with its door closed Rendered 3D model of the liquid chamber with its door slid open
Figure 1-5. Liquid chamber 3D model.

Structure 2: liquid container

The liquid container is made of 3D-printed side walls and a transparent acrylic plate bonded with hot-melt adhesive. It has good sealing performance while light can pass through the liquid.

We placed the optical path vertically, so that light passes the horizontally placed liquid from below. This approach keeps the light as perpendicular to the liquid surface as possible, reducing errors caused by refraction and reflection of the liquid.

To save space and shorten the optical path, the liquid chamber is relatively narrow, making it difficult to replace the liquid container. To address this problem, we designed a slide rail that allows the liquid container to be pulled out from the side for easy replacement.

Rendered 3D model of the liquid container: a shallow tray with a transparent acrylic base
Figure 1-6. Liquid container 3D model.
Rendered 3D model of the liquid placing set, the holder the container slides into
Figure 1-7. Liquid placing set 3D model.

Structure 3: light source

We use an LED bead as the light source. LED beads are extremely low-cost and readily available, and our tests show that their brightness meets the experimental requirements.

To adjust light source brightness, we designed an adjustable aperture above the light source. Sliding the side slider changes the amount of light passing through the liquid.

The adjustable aperture enables the device to adapt to samples with different colour depths and exposure conditions, avoiding HSV reading distortion caused by overexposure or underexposure.

Rendered 3D model of the adjustable light aperture with the slider closed Rendered 3D model of the adjustable light aperture with the slider open
Figure 1-8. Adjustable aperture 3D model.

Structure 4: phone holder

To properly fix the smartphone used for measurement and data output, we designed a foldable phone holder. It is stable and can securely support the phone; the holder arm length is adjustable, allowing it to support phones of various sizes. When folded, it is compact and easy to carry. With it, we can set up an experimental measurement platform anytime, anywhere.

Rendered 3D model of the phone holder unfolded, showing its adjustable arms
Figure 1-9. Phone holder 3D model.

The photographs below show our actual device, taken during our experiments with it.

Photograph of the 3D-printed RATIO Pocket on a workbench, with a smartphone resting on its folding holder
Figure 1-10. The RATIO Pocket device during an experiment.

Data acquisition: a smartphone running phyphox

After several rounds of experimental results, we chose to use hue and saturation to characterise the colour of the liquid. We use a smartphone running the phyphox app to obtain this information.

A smartphone held above the RATIO Pocket housing, showing the phyphox colour readout on screen
Figure 1-11. A smartphone as a portable data acquisition device.

Raw image data captured by a smartphone camera is a combination of red, green and blue (RGB) channels. However, the RGB colour space is not intuitive for describing colour, because the three channels are strongly correlated and can be greatly affected by illumination intensity.

The HSV colour space, on the other hand, decomposes colour into three mutually independent dimensions: hue, saturation and value, which is closer to the colour perception of the human eye. Hue is measured in degrees — red is 0°, green is 120°, and blue is 240°, covering the full colour wheel; saturation indicates how close a colour is to a spectral colour, ranging from 0.0 to 1.0; value indicates the brightness of the colour. The key advantage of HSV is that it is sensitive to changes in solution concentration but insensitive to illumination intensity, so it reduces interference from fluctuations in the light source.

The colour (HSV colour space) function in phyphox uses the smartphone camera to acquire images in real time. It then aggregates the RGB values of all pixels in a user-defined region and converts them to HSV coordinates.

Screenshot of the phyphox colour interface: a live camera view with a selected region, and numeric hue, saturation and value readouts below it
Figure 1-12. phyphox colour acquisition interface. Hue is in degrees (°); saturation and value are dimensionless, from 0 to 1.

Before recording begins, the phone must be fixed above the device in a fixed position; once recording starts, phyphox continuously outputs the HSV values of that region at a rate of 240 Hz. After the experiment, the data can be exported as a spreadsheet for subsequent analysis.

On the basis of the above, and of several rounds of experimental results, we chose the hue and saturation information acquired by phyphox's HSV colour space function as the raw experimental data for characterising solution colour.

Pigment ratio prediction model

Considering biosafety and data accuracy, we used food colouring to prepare blue and yellow solutions and mixed them in different ratios, to simulate the state in which two bacterial types coexist in different proportions.

With the help of RATIO Pocket, we measured the HSV values of mixed solutions with known blue–yellow ratios, obtaining 63 data points across 19 ratios.

Photograph of RATIO Pocket set up on a bench, with a smartphone mounted on the folding holder above the housing
Figure 1-13. Measuring a mixed solution with RATIO Pocket.

Using these data, we established a mathematical model that calculates the pigment ratio of a mixed solution from its HSV values:

z_{hue} = \frac{Hue - Yellow_{Hue}}{Blue_{Hue} - Yellow_{Hue}}
z_{saturation} = \frac{Saturation - Yellow_{Saturation}}{Blue_{Saturation} - Yellow_{Saturation}}
ratio = \frac{1}{1 + \exp(-(-1.1397 + 1.4533 z_{hue} + 1.8247 z_{saturation}))}

Here Hue is the hue value of the test liquid and Saturation is its saturation value; Yellow_{Hue} and Yellow_{Saturation} are the hue and saturation of the pure yellow solution; Blue_{Hue} and Blue_{Saturation} are the hue and saturation of the pure blue solution.

On the 63 dye-mixture recordings used to fit it, the endpoint-normalised model achieved an in-sample R² of 0.801 and an RMSE of 0.118. This shows that one curve can capture much of the relationship between colour and mixing fraction across the two experimental batches. Evaluating the printed equation at the pure-yellow and pure-blue endpoints, however, gives predicted blue fractions of 0.242 and 0.895 rather than 0 and 1. The remaining endpoint bias gives us a clear target for improving quantitative accuracy.

In practice, therefore, we measure pure-yellow and pure-blue solutions alongside each batch and use their HSV values to normalise the test solution before applying the curve.

The fit itself is documented on our Software page, where the CalcRatio pipeline that produces it is described.

Summary

The RATIO Pocket device is a 3D-printed experimental platform built around a smartphone camera. It uses the phyphox app to acquire solution HSV data and calculates the pigment content ratio in solution from a fitted equation.

The platform is low-cost, easy to assemble and portable, making it suitable for colour ratio detection in resource-limited environments. Future improvements may include optimising sample loading, increasing the volume of data, and evaluating additional optical components to improve detection accuracy further and extend the device to biological experiments.

Materials and fabrication files

The bill of materials below covers everything the device needs apart from the smartphone, which the user supplies.

MaterialAmountPriceSource
LED bead1¥0.38E-commerce platform
3D printing filament (PETG)160.98 g¥4.02E-commerce platform
Transparent acrylic plateOne piece, 2 cm diameter¥2E-commerce platform
Smartphone (any model)1User-provided, not counted in the device costUser-owned device
Total¥6.40Excluding the cost of the smartphone

Table 1-1. Bill of materials for RATIO Pocket.

The housing prints as sixteen parts, in three groups.

Loading the 3D model…

0%

Drag to rotate · pinch or Ctrl+scroll to zoom

Figure 1-14. The assembled device, in three dimensions.

Main body parts

Click to view 3D model

Testing chamber
Blocks the outside light.
Side door
Lets the sample be changed.
Liquid container CAD render
Liquid container
Holds the liquid sample.
Liquid vessel container
Sets the liquid vessel in place.
Liquid container set
Holds the liquid container.
Light set
Places the LED and provides the light.

The parts of the light adjusting hole

Click to view 3D model

Top part of the hole
The top part of the hole.
Bottom part of the hole
The bottom part of the hole.
Adjusting plate
The adjusting plate of the hole.
Light-blocking plate
The light-blocking plate of the hole.

Loading the 3D model…

0%

Drag to rotate · pinch or Ctrl+scroll to zoom

Figure 1-15. The light adjusting hole, on its own.

The parts of the phone holder

Click to view 3D model

Connector part
Connects the holder to the body.
Supporter part 1
One of the five phone-supporter parts.
Supporter part 2
One of the five phone-supporter parts.
Supporter part 3
One of the five phone-supporter parts.
Supporter part 4
One of the five phone-supporter parts.
Supporter part 5
One of the five phone-supporter parts.

Loading the 3D model…

0%

Drag to rotate · pinch or Ctrl+scroll to zoom

Figure 1-16. The phone holder, on its own.

Figure 1-17. RATIO Pocket: Voyager 3D-printed parts.

Hardware

RATIO Bench

Introduction: a low-cost platform based on the TCS34725

We built RATIO Bench, a low-cost, four-channel colourimeter that quantifies the ratio of two chromoprotein-expressing cell populations in a mixed culture[3]. A TCS34725 sensing module with its own white LED sits inside a sealed, light-tight enclosure (RATIO Bench), and the liquid sample is placed in a well above the sensor[1]. Each chromoprotein selectively absorbs a specific wavelength, and the module reads the transmitted light on four channels (red / green / blue / clear). From the absorbance ratio we recover the cell fraction.

RATIO Bench consists of the TCS34725 sensing module, an STM32F103C8 microcontroller, a 0.96" OLED display and a 3D-printed light-blocking shell. It is a low-cost, easy-to-replicate platform that correlates the colour of the liquid under test with the substance ratio.

Design targets, the baseline this hardware is measured against:

SpecificationTargetUnitStatus
Resolution Δx≤ 5% (fraction)In iteration
Calibration R² (rational fit)> 0.95dimensionlessAchieved (0.974)
Signal-to-noise (R-channel drift)< 2%Pending re-test
Measurement time (per sample)< 10sAchieved (~7 s)
Output channels4R / G / B / ClearAchieved
Hardware cost≪ spectrophotometerCNYAchieved

Table 2-1. RATIO Bench design targets, the baseline this hardware is measured against.

Hardware-link and signal-processing flow diagram: a self-illuminating TCS34725 sensor module sits inside the sealed box RATIO Bench and carries a liquid well on top; the chip sends red, green, blue and clear values to the STM32F103C8, which drives the OLED display; the lower panel lists the firmware signal-processing steps
Figure 2-1. Hardware links and signal-processing flow of RATIO Bench.

The housing of RATIO Bench: shell

RATIO Bench: shell is a custom 3D-printed enclosure. Its job is to hold the sensing module in a fixed position and to block ambient light, so that the only light reaching the sensor comes from the module's own LED and has passed through the sample.

Exploded CAD view of the RATIO Bench housing: the cover lifted clear of the body, and the module plate and sample wells visible inside
Figure 2-2. Exploded view of the enclosure, showing how the parts fit together.

Structure 1: sealed enclosure

The shell is printed in opaque matte green and fully encloses the optical path. A light-tight cavity prevents any ambient light from reaching the sensor, which would otherwise add an uncontrolled offset to every reading.

Photograph of the printed parts on a wooden table: the stepped body beside the square module seat, both showing visible print layers
Figure 2-3. The printed body and the module seat.

Structure 2: sensor module seat

The TCS34725 module is held in a fixed seat so that its distance to the sample and its orientation do not change between measurements. Because the reading is normalised against a blank, keeping the geometry constant is what makes successive samples comparable.

Close-up photograph of the red TCS34725 module seated inside its 3D-printed holder, with jumper wires attached to the header pins
Figure 2-4. The TCS34725 module seated in its holder.

Structure 3: sample well

An open well above the sensor holds the liquid sample. The sample sits directly over the sensing area so that the module's own LED illuminates it from below, and the transmitted light is read by the four channels.

CAD view of the housing interior, showing the sample wells and the locating features inside the body
Figure 2-5. CAD view of the housing interior and the sample wells.

Data acquisition: four-channel readout with repeated sampling

Firmware is written in C (STM32Cube HAL). Key choices:

FeatureSettingReason
Integration time700 msMore photons → lower shot noise
Gain4×Avoids saturating the clear channel
SamplingN = 10 independent readingsOutputs mean ± standard deviation
Display0.96" OLED, two pagesPage 1 = mean, page 2 = standard deviation
CommunicationI²C (100 kHz)Sensor on I2C2, OLED on I2C1

Table 2-2. Firmware data-acquisition settings and why each was chosen.

Photograph of the readout in use: the OLED module is held in a gloved hand and shows the four channel values, with the 3D-printed housing beside it
Figure 2-6. Readout in use — the OLED shows the four channel values (R: 3741, G: 3811, B: 3979, C: 11453).

Core firmware — sensor initialisation and the repeated-sampling measurement:

uint8_t TCS_Init(void)
{
    uint8_t id = TCS_ReadReg(REG_ID);
    if(id != 0x44)
        return 1;

    TCS_WriteReg(REG_ATIME, ATIME_700MS);
    TCS_WriteReg(REG_CONTROL, GAIN_4X);
    TCS_WriteReg(REG_ENABLE, EN_PON | EN_AEN);
    HAL_Delay(10);
    return 0;
}
void TCS_Measure(uint8_t n, TCS_Stats_t *stats)
{
    double sum_c = 0, sum_r = 0, sum_g = 0, sum_b = 0;
    double sq_c  = 0, sq_r  = 0, sq_g  = 0, sq_b  = 0;
    double mean_c, mean_r, mean_g, mean_b;
    uint8_t i;

    if(n == 0)
        return;

    for(i = 0; i < n; i++)
    {
        TCS_RGBData_t d;
        HAL_Delay(710);
        TCS_ReadAllRGB(&d);
        sum_c += d.clear;  sq_c += (double)d.clear * d.clear;
        sum_r += d.red;    sq_r += (double)d.red * d.red;
        sum_g += d.green;  sq_g += (double)d.green * d.green;
        sum_b += d.blue;   sq_b += (double)d.blue * d.blue;
    }

    mean_c = sum_c / n;  mean_r = sum_r / n;
    mean_g = sum_g / n;  mean_b = sum_b / n;

    stats->clear_mean = (uint16_t)mean_c;
    stats->red_mean   = (uint16_t)mean_r;
    stats->green_mean = (uint16_t)mean_g;
    stats->blue_mean  = (uint16_t)mean_b;

    stats->clear_std = (uint16_t)sqrt(sq_c/n - mean_c*mean_c);
    stats->red_std   = (uint16_t)sqrt(sq_r/n - mean_r*mean_r);
    stats->green_std = (uint16_t)sqrt(sq_g/n - mean_g*mean_g);
    stats->blue_std  = (uint16_t)sqrt(sq_b/n - mean_b*mean_b);
}
Photograph of the complete measurement setup on a bench: a laptop, the STM32 board, an ST-Link programmer and the OLED display held in a gloved hand, with the 3D-printed holder on the right
Figure 2-7. The complete measurement setup, with the ST-Link programmer attached for flashing.

Firmware and schematics are open-sourced on GitHub — RATIO-Bench-firmware (Keil MDK project: TCS34725 driver, OLED driver, STM32Cube HAL).

Measurement procedure

Photograph of two centrifuge tubes held in gloved hands, one filled with yellow solution and the other with blue solution
Figure 2-8. Preparing the two stock solutions that act as the ratio endpoints — Tartrazine (yellow, left) and Brilliant Blue FCF (blue, right).
  1. Blank calibration — measure the pure medium and record R_0 / G_0 / B_0 / C_0.
  2. Sample measurement — place the sample in the well and read the mean ± standard deviation from the OLED (≈ 7 s).
  3. Compute — A_G = -\log_{10}(G/G_0), A_B = -\log_{10}(B/B_0), and y = A_B / A_G.
  4. Convert — substitute y into the calibration curve to obtain the blue fraction x.

Ratio prediction model

Lambert–Beer law. For monochromatic light through an absorbing medium[2]:

A = -\log_{10}\!\left(\frac{I}{I_0}\right) = \varepsilon \cdot c \cdot L

Here A is absorbance, I_0 the incident intensity, I the transmitted intensity, \varepsilon the molar absorptivity, c the concentration and L the path length.

Absorbance-ratio method. For a blue (A) + yellow (B) mixture the two channel absorbances are

A_B = \left[\varepsilon_{A,B}\,x + \varepsilon_{B,B}\,(1-x)\right] c L, \qquad A_G = \left[\varepsilon_{A,G}\,x + \varepsilon_{B,G}\,(1-x)\right] c L

Taking the ratio cancels c and L, leaving a signal that depends only on the blue fraction x:

y = \frac{A_B}{A_G} = \frac{\varepsilon_{A,B}\,x + \varepsilon_{B,B}\,(1-x)}{\varepsilon_{A,G}\,x + \varepsilon_{B,G}\,(1-x)} = \frac{b + (a-b)x}{1 + (c-1)x}

This is a fractional-linear (rational) function of x, not a straight line. Fitting it to the pre-experiment data gives a = 15.3, b = 4.36, c = 18.2 and R^2 = 0.974 — against R^2 = 0.612 for a linear fit.

Scatter plot of the absorbance ratio A_B/A_G against blue-cell fraction, with a solid rational-fit curve and a dashed linear-fit curve; one red cross marks an outlier
Figure 2-9. Calibration curve for the blue/yellow chromoprotein pair (n = 1 per point). The rational fit (solid, R² = 0.974) matches the theoretical fractional-linear relationship far better than the linear fit (dashed, R² = 0.612).

Summary

RATIO Bench provides a low-cost way to read the colour of a liquid sample and, through the absorbance ratio, to estimate the ratio of the two chromoprotein-expressing populations. The rational model explains the curvature that a linear fit misses (R² = 0.974), so the measurement principle is sound, and the whole device costs roughly ¥78.

The current results still have clear limitations. The pre-experiment used a single measurement per sample (n = 1), so the reported errors rest on five calibration points. The noise floor (13.6 %) is the same order as the signal (2.4 %–15.8 %), so the calibration cannot yet resolve the 5 % and 1 % steps, and the three concentration levels disagree by 57 %.

In future work we will raise the chromoprotein concentration so the absorbance reaches 0.2–0.8, record and normalise by the clear channel, re-test resolution and concentration independence with at least five replicates, and optionally upgrade to a dual-wavelength LED with a 16-bit ADC.

Materials and fabrication files

ItemUnit priceQuantityTotalNotes
STM32F103C8~15 CNY1~15 CNYMCU
TCS34725 module~35 CNY1~35 CNYRGB sensor
0.96" OLED~12 CNY1~12 CNYDisplay
White LED~3 CNY1~3 CNYLight source
Cuvette / tube~5 CNY1~5 CNYSample holder
RATIO Bench: shell~8 CNY1~8 CNY3D-printed enclosure, light-blocking
Total~78 CNYEstimated

Table 2-3. Estimated bill of materials (unit prices are approximate).

The firmware and schematics are in the RATIO-Bench-firmware repository, and the enclosure CAD is available from the team on request.

References

  1. ams-OSRAM. TCS34725 Color Sensor — Datasheet. ams-osram.com (accessed 2026).
  2. Mayerhöfer, T. G., Pahlow, S. & Popp, J. (2020). The Bouguer–Beer–Lambert Law: Shining Light on the Obscure. ChemPhysChem. DOI: 10.1002/cphc.202000464.
  3. Liljeruhm, J., et al. (2018). Engineering a palette of eukaryotic chromoproteins for bacterial synthetic biology. Journal of Biological Engineering. DOI: 10.1186/s13036-018-0100-0.
Back
To Top