## Main

Over the past two decades, major epidemics (SARS, Zika, MERS and Ebola) and pandemics (H1N1 and COVID-19) have emerged with increasingly alarming regularity1,2,3. Although currently the world is grappling with the COVID-19 pandemic, the occurrence of the next wave of infectious disease outbreaks in the coming years is deemed inevitable, given the rise in population, urbanization and global travel and/or trade. In that regard, large-scale population screening is the primary safeguard to contain epidemics, prevent pandemics and mitigate their human and economic costs on their onset4,5,6.

Accordingly, increasing our viral diagnostic and surveillance testing capacity globally is fundamental to our epidemic and pandemic preparedness7,8,9. Among the test options, nucleic acid amplification tests (NAATs) are advantageous over the antigen-based and antibody-based counterparts, owing to their superior sensitivity, specificity and ability for rapid deployment without the need to generate specific diagnostic antibodies10,11. To perform NAATs at large scale and frequency, accessible automated testing platforms are required that can be deployed in decentralized settings to analyse samples with high throughput, fast turnaround time and minimal capital cost and/or reagent use12,13,14. In particular, the strategic pooling of samples15,16,17,18, when most patients are expected to be negative, can lead to a marked reduction in resource utilization amid pandemic-induced supply chain disruptions (outweighing the marginal risk of dilution-induced false negatives19,20). Accordingly, flexible testing workflows dictated by adaptive pooling algorithms—such as viral prevalence-based algorithms—that are intended to maximize the screening efficiency are needed (Fig. 1a,b).

However, current automated NAAT-based testing platforms are unable to perform the integrated liquid handling, analysis and automated feedback processes that are necessary to achieve these flexible workflows21,22,23. In addition, they use bulky, expensive and reagent-wasteful robotic liquid handlers and bioinstruments, with heavy installations and maintenance needs, and thus, they are restricted to centralized laboratory settings24,25,26,27,28,29.

To enable adaptive pooled testing, here we created an automated NAAT-based testing platform, which performs programmable liquid handling and bioanalytical operations within flexible workflows and in a parallel manner. Instead of resource-intensive and functionally limited robotic liquid handlers, we used a swarm of individually addressable millimetre-sized magnets as mobile robotic agents (‘ferrobots’) that can manipulate magnetic nanoparticle-spiked droplets (‘ferro-droplets’) with high precision and robustness. The seamless integration of fluidware, hardware and software allowed for programming and streamlining the droplet-based operations, and delivering versatile automated NAAT-centred workflows within a compact platform (for example, here we implemented reverse transcription loop-mediated isothermal amplification (RT-LAMP)). To maximize the screening efficiency, we formulated a prevalence-based adaptive testing algorithm (Fig. 1b and Supplementary Note 1). This algorithm particularly determines the optimal testing mode and guides the operational workflow in accordance with a square matrix pooling scheme (Fig. 1c,d), without entailing overly burdensome sample handling procedures. Adopting this approach over the fixed individual testing approach (universally pursued) allows for substantial savings over a wide viral prevalence range.

Figure 1e–g illustrates a representative ferrobotic testing platform, which consists of two modules (entirely constructed by low-cost components): (1) a disposable oil-filled microfluidic chip with passive and active actuation interfaces that hosts input samples and ferrofluid or assay reagents, and (2) a printed circuit board (PCB), featuring 2D arrayed coils (‘navigation floor’), which can be independently activated to electromagnetically direct individual ferrobots.

We realized the miniaturized bioanalytical operations and workflows within the framework of ferrobotics, because it simultaneously offers high degrees of robustness, diversity, programmability and scalability for low-volume sample handling. Within this framework, we developed and characterized a suite of operations, including droplet transportation, aliquoting, merging, mixing and heating, which are key to the on-chip implementation of NAAT-based assays (Fig. 2 and Extended Data Fig. 1).

By programming the underlying PCB-based coils, we electromagnetically directed the ferrobots to carry ferro-droplets within different oil environments, in which rapid droplet transportation with a maximum velocity range of 5–50 mm s−1 was achieved (Fig. 2a and Extended Data Fig. 1b). We found that Novec (oil)–PicoSurf (surfactant) yielded the maximum ferro-droplet speed (owing to its low viscosity; Supplementary Note 2, Supplementary Table 5 and Supplementary Fig. 6), as well as being compatible with the RT-LAMP assay.

Figure 2b illustrates the precise and tuneable ferrobotic sample aliquoting capability in the optimized Novec oil environment. In our context, aliquoting is a critical step for precise sample metering and creating sub-samples for multiplexing and multiround pooling analysis. Aliquoting is achieved by directing a ferrobot carrying a ferro-droplet along a corrugated structural feature, which in turn causes the dispensing of a smaller ferro-droplet (as an aliquot). By adjusting the corrugation opening and/or the channel height, the volume of the aliquot could be tuned over two orders of magnitude (for example, here 100 nl to 10 μl; Extended Data Figs. 1c,d and 2a).

To realize droplet merging, we utilized the principle of electrocoalescence. In our context, droplet merging is useful for adding reagents to the input samples and combining multiple input samples for pooling. As shown in Fig. 2c, by transporting the droplets to an electrode pair and applying a relatively low voltage (approximately 0.3–1.5 V, depending on the surrounding oil–surfactant composition; Supplementary Note 3 and Supplementary Fig. 7), droplet merging in less than a few seconds can be achieved.

We found that robust and repeatable ferrobotic droplet actuation can be achieved for droplets spanning different ionic strengths and chemical compositions relevant for biological and chemical assays (Extended Data Fig. 3). A total of more than 8 million actuation events were performed over more than 24 h (only limited by the observation time), showing repeatable behaviour over the time period. This behaviour differs from common digital microfluidics approaches such as electrowetting on dielectric, which undergo surface degradation-related issues30,31,32. Further illustrating that other ferrobotic operations are robust, we performed cyclic aliquoting, merging and intermediate transportation of a parent droplet over 800 cycles with less than 1% variation in the corresponding size of the parent droplet post-aliquoting and post-merging (Fig. 2d).

To realize mixing, which is particularly important for homogenizing the droplet contents post-merging, the ferrobot can be oscillated to induce chaotic fluid motion within the merged droplet by alternatively activating the neighbouring coils. As shown in Fig. 2e, the droplet homogenization rate increases with oscillation frequency and, in particular, a nearly full-mixed state can be reached in approximately 15 s by oscillating the ferrobot at 5 Hz.

We used on-board resistive heaters for nucleic acid amplification and sample preparation (for example, lysis). The local temperature can be controlled by adjusting the direct current flowing through the resistive heater, in accordance with the operational needs (Fig. 2f and Extended Data Fig. 4a–c).

We implemented a colorimetric RT-LAMP assay that is based on thermal lysis or inactivation21 and isothermal amplification (both achievable with on-board resistive heaters). This assay provides a high degree of test accessibility, outweighing the marginal compromise in test accuracy19,20. Figure 2g illustrates the RT-LAMP reactions, which involve reverse transcription of the viral RNA, amplification of the product DNA and generation of hydrogen ions, which are colorimetrically detected. By analysing the reaction product (DNA) via gel electrophoresis (Fig. 2h and Supplementary Fig. 1), we verified the assay function in converting and amplifying a SARS-CoV-2-positive control RNA sample. Colorimetric detection is based on the generated hydrogen ions, causing a colour change of an incorporated pH indicator (phenol red) from red-orange to yellow (optimization experiment results are shown in Extended Data Fig. 5a–c). The colour change allows for the binary interpretation of the test, above or below a threshold as positive or negative, respectively. This colour change can be tracked visually (Fig. 2i) by the naked eye, or electronically by integrating an optical sensor (Fig. 2j and Extended Data Fig. 4b,d), without the absorbance of the ferrofluid affecting the readout interpretations. Accordingly, the same limit of detection of 25 cp μl−1 of the adopted assay33 can be achieved in the ferro-droplet format (1 μl; reagent volume of 19 μl; similar to the original assay protocol), which suggests that the magnetic nanoparticles do not interfere with the amplification chemistry or colorimetric readout accuracy (Extended Data Fig. 5d). The assay was also successfully performed by using microfluidic structures of reduced height (approximately 150 μm) to aliquot a tenfold-smaller ferro-droplet volume (100 nl; reagent volume of 1.9 μl; Extended Data Fig. 5e), which is below the volume that can be accurately pipetted using robotic liquid handlers, but useful for minimizing reagent use. Our characterization results also verified the reliability of the assay in the presence of temperature variations of a few degrees Celsius (Supplementary Fig. 2a) and in the presence of biological interferents (Supplementary Fig. 3).

The programmability of our program (Supplementary Fig. 4) allows for its ease of adaptation to streamline the ferrobotic actuation and bioanalytical operations, and deliver versatile RT-LAMP-based testing workflows in an entirely automated manner and with high fidelity.

Illustrating this point in the context of individual sample testing, we customized a disposable microfluidic module to host the input sample, associated reagents and dedicated aliquoting or merging components (Fig. 3a and Extended Data Fig. 4b)—then, augmented it with a PCB module, containing the navigation coils, resistive heater elements and colorimetric sensing circuitry. By programming the PCB at the software level, we installed a ferrobotic instruction set to seamlessly execute the assay. The instruction set charts the navigation plan of a dedicated ferrobot and details the electrode excitation conditions for merging and heating, while accounting for a 5-min heat lysis and a 30-min RT-LAMP reaction period (Fig. 3b).

In this testing workflow, the active ferrobotic operations take place over a period of 1.75 min (Fig. 3c and Supplementary Video 1). A ferro-droplet is first magnetically transported to, then merged and mixed with, an introduced sample droplet to make the sample amenable for ferrobotic manipulation. The next steps in the sequence are aliquoting the ferro-sample, disposing the ferro-sample residue and delivering the aliquot (1 μl) to the reaction chamber (containing the assay reagents). Upon delivery to the reaction chamber, the RT-LAMP process initiates, and after 30 min, the assay readout is colorimetrically quantified, rendering the test result in a sample-to-answer manner. A similar workflow was implemented using microfluidic chips with reduced height to achieve smaller ferro-droplets (approximately 100 nl) for analysis with reduced reagents (Extended Data Fig. 2b).

We assessed the accuracy of our platform with real-world samples by testing 100 clinical samples with the ferrobotic RT-LAMP chip and comparing the on-chip readouts with the corresponding readouts obtained from the standard PCR with reverse transcription (RT–PCR) and RT-LAMP assays (summarized in Fig. 3d and detailed in Supplementary Table 6). The collected samples were based on nasopharyngeal swabs from patients infected or uninfected with SARS-CoV-2. The viral on-chip detection threshold (710 a.u.) was derived from receiver operating characteristic analysis (aliquoted sample volume of 1 μl).

For all 100 samples, the ferrobotically produced results were in agreement with the manually performed (off-chip) RT-LAMP assay results (100% concordance), illustrating the high fidelity of the ferrobotic automation. Comparison of the ferrobotically produced RT-LAMP-based results with the corresponding results obtained from the RT–PCR assay (gold standard) resulted in a test sensitivity of 98% and specificity of 100% (Fig. 3e), in which the discrepancy in the rare test result can be attributed to the inherent differences of the amplification approaches used33. We further validated that the clinical samples with aliquoted volumes of 1 μl and 100 nl can be accurately analysed in a reproducible manner across replicates (Extended Data Fig. 6).

We next demonstrated multiplexed viral testing by utilizing the adaptability of our platform (Extended Data Fig. 7, Supplementary Video 2 and Supplementary Note 4). This testing mode is diagnostically useful for differentiating between the emergent outbreak virus (for example, SARS-CoV-2) and endemic viruses (for example, the seasonal viruses such as influenza A–H1N1) that often result in similar clinical symptoms34,35,36,37.

By utilizing the scalability of the platform, we can increase the testing throughput. The extensibility of the mobile robotic scheme used to a multi-agent mobile (swarm) robotic scheme, together with the expandability of the navigation floor or microfluidic architecture, inherently render our platform scalable. One approach to increasing the throughput is to simply extend our individual testing platform into an array format (Extended Data Fig. 4a,e). With this implementation, a large number of input samples can be analysed in parallel and asynchronously as they arrive—without involving accumulation wait time (unlike the case for current high-throughput methods that rely on batch processing38). A less trivial yet more efficient high-throughput testing approach involves applying our platform to the problem of adaptive pooled testing.

To determine the appropriate number of input samples and guide the pooled testing workflow, we utilized our prevalence-based adaptive testing algorithm that can be implemented following a square matrix pooling scheme. Following this approach, testing efficiency can be substantially improved in moderate-to-low viral prevalence ranges (specifically, by appropriately performing 32 or 42 matrix pooling, determined algorithmically; Supplementary Note 1).

Figure 4a provides an overview of the algorithm-guided square matrix pooling scheme, particularly for the case of 42 pooling, which involves a group of 16 samples arranged in a 4 × 4 matrix (Sij; i,j represent the row and column indices, respectively). In this scheme, all of the samples are first pooled together and the resultant sample aggregate is analysed by a single assay ‘A’. If the assay readout is negative, all of the original input samples will be deemed negative. Otherwise, a second round of testing will be followed. In this round, the samples will be pooled along rows and columns, leading to a total of eight sample aggregates. The row-pooled and column-pooled sample aggregates will be correspondingly analysed by dedicated ‘Ri’ and ‘Cj’ assays. The intersectional analysis of the Ri and Cj assay readouts allows for determining the infected sample (or samples) (Fig. 1d and Supplementary Fig. 5). In the relatively low probable cases (for example, 2.5%, assuming a viral prevalence of 2%) in which the paired row–column projections are not one-to-one mapped to specific arrangements of multiple positive samples, only those samples that are deemed suspicious (that is, those located at the intersection of positive row–column projections) will be individually tested.

To implement the square matrix pooled testing workflow, we expanded the microfluidic chip layout for pooled testing. Extended Data Figure 8a,b illustrates the corresponding layouts of the 32 and 42 microfluidic chips. The expanded layouts especially include arrays of sample aliquoting interfaces and reaction chambers (containing SARS-CoV-2 RT-LAMP assay solutions), orthogonal corridors for intrachip sample aliquot transport and extended merging interfaces. To direct the swarm ferrobotic operations in accordance with the devised pooling scheme, we utilized a PCB module with increased navigation coils (that is, an expanded navigation floor) and programmed the PCB module to install an updated multiferrobot-based and pooling algorithm-driven instruction set.

Figure 4b and Supplementary Video 3 illustrate the sequence of the operations performed by a swarm of nine ferrobots to deliver a representative 42 pooled testing workflow. The demonstrated sequence involves: (1) making three aliquots of each input sample with the aid of four ferrobots; (2) all-sample pooling to facilitate the first round of testing (performed in two steps; combining the aliquots on the same row using four ferrobots in parallel, followed by combining the resultant aggregates using a single ferrobot); and (3) row–column pooling to facilitate the second round of testing (each performed by a set of four ferrobots). To combine the intended aliquots in each of the pooling steps, the aliquots were ferrobotically collected, merged, mixed and then dispensed as a droplet with a metered volume (1 μl). The overview of the navigation plan and the detailed timeline of the task sequence executed by each ferrobot (in coordination with the other ferrobots) are shown in Extended Data Fig. 8c–f.

Before applying the scaled platform for pooled testing of clinical samples, we evaluated the dilutive effect of sample pooling on the assay detection capability (using positive nasal swab samples). The results indicated the capability of the assay in correctly identifying positive samples with a relatively low viral load, even at dilutions as high as 16 times (Extended Data Fig. 9).

We examined the pooled testing capability of the scaled platform by analysing a collection of 50 clinical samples (pre-characterized via RT–PCR). These samples were grouped in two arrangements of 9 and 16 samples and tested with the corresponding 32 and 42 chips in a way to allow for evaluating the pooling, detection and interpretation capabilities of the platform in the first and second rounds of testing. Specifically, for each group size or chip, we tested the scenarios that involved the absence or the presence of an infected sample. Figure 4c–f illustrates the corresponding on-chip optical characterization results (with assay reagent volumes of 19 µl to analyse aliquoted samples with volumes of 1 µl). Following the aforementioned testing scheme, by comparing the corresponding assay responses (all-pooled (A) or row–column-pooled (Ri/Cj)) with respect to their detection threshold, we determined the status of each sample. We performed similar pooled testing studies using smaller aliquoted samples (100 nl, with assay reagent volumes of 1.9 µl), demonstrating the ability to reduce reagents further (Extended Data Fig. 10). For all tested scenarios and across all samples, the ferrobotically produced and/or interpreted results were in line with those obtained by RT–PCR.

The demonstrated pooled-testing application, and scale of microfluidic liquid handling operations, is unprecedented. Supplementary Table 1 provides a detailed account of the number of droplet actuation and ferrobotic operations that were reliably carried out to achieve pooled testing. This was achieved by harnessing the competitive advantages of the ferrobotic technology that overcomes performance limits (in terms of reliability, scalability, reagent use and portability, among others) and cost barriers of alternative microfluidics approaches (Supplementary Note 5).

Depending on the situational needs, the ferrobotic testing platform can be adapted—with minimal reconfiguration—to automate other NAAT-based assays (for example, RT–PCR) as well as other pooling schemes (for example, Dorfman39). The ferrobotic testing platform can be constructed with low-cost consumables (Supplementary Table 2) and instrumentation (Supplementary Table 3) using widely available materials and circuit components and following existing scalable manufacturing solutions—together enabling mass production for rapid large-scale deployment. As summarized in Supplementary Table 4, we estimate that translating this platform for population-level screening can ultimately lead to approximately three orders of magnitude of increase in marginal gain in testing capacity from the instrumentation investment standpoint, and a 60–300-fold reduction in reagent costs at moderate-to-low viral prevalence (approximately 8% to 0.8%) and tenfold reduction at high viral prevalence. Accordingly, utilizing its high level of accessibility, adaptability and automation, the presented technology can be deployed as a democratized, distributed and decentralized solution to expand our testing capacity for pandemic preparedness. Beyond viral testing, the presented swarm ferrobotic technology can be adapted and scaled to efficiently streamline and massively parallelize various other laboratory-based bioanalytical operations within a miniaturized footprint (Supplementary Note 6). Thus, this technology can serve as a powerful tool for a wide range of biomedical and biotechnological applications such as diagnostics, omics, drug development and chemical and/or biomaterial synthesis.

## Methods

### Materials and reagents for ferrobotic platform and viral testing

The ferrofluid used in this work is ferumoxytol, a US Food and Drug Administration-approved intravenous iron preparation (AMAG Pharmaceuticals). Rare earth permanent magnets (D101 and DH2H2, with corresponding thickness of 0.8 mm and 5 mm, and diameter of 2.54 mm and 5 mm) were purchased from K&J Magnetics for device construction and characterization. The microfluidic module was constructed from double-sided tape (3M, 300LSE) and transparent polyethylene terephthalate (PET) film layers (M.G. Chemicals). The microfluidic devices were filled with Novec 7500 Engineered oil (3M) containing 0–0.1% surfactant (PicoSurf 1; Sphere Fluidics), unless stated otherwise. Other oils including mineral oil (Sigma-Aldrich), FC-40 and corresponding surfactant (1H,1H,2H,2H-perfluoro-1-decanol; Sigma-Aldrich) were also used for velocity characterization. Single-stranded RNA fragments of SARS-CoV-2 (108 copies per microlitre) were purchased from Sigma-Aldrich. Living Escherichia coli K-12 strain (3 × 105 colony-forming units (c.f.u.) μl−1) in liquid nutrient broth was purchased from Carolina Biological Supply. A SARS-CoV-2 Rapid Colorimetric RT-LAMP Assay Kit was purchased from New England Biolabs and stored at −20 °C. The viral transport media were purchased from BD. The UCLA Clinical Microbiology Laboratory performed RT–PCR using the following assay: TaqMan COVID-19 RT–PCR Assay (Thermo Fisher Scientific).

### Electromagnetic navigation floor circuit design

To manipulate ferrobots across 2D space, an electromagnetic (EM) navigation floor on PCB comprised active coil elements in a 2D-array format. Each element had a three-turn coil with a size of 1.5 mm × 1.5 mm traced onto the three layers of the PCB, with a 0.1-mm gap separated from adjacent elements. Each coil element can be activated by a direct current (DC) of 0.2 A, generating a localized magnetic force that attracts the ferrobot (Supplementary Fig. 8). Programmable current source integrated circuits (ICs) LT3092 (Linear Technology) were used to power the actuated coils (3 V, 0.6 W for each actuated coil). Programmable switch ICs MAX14662 (Maxim Integrated) were used to selectively activate the EM coils and components.

To enable scalable asynchronous parallel testing of 32 samples, the individual testing navigation floor comprised an array of 4 × 8 testing units. Each testing unit included two 20-Ohm resistive heaters, an array of 14 EM coils and an optical sensing module containing a white-light LED (20 mA) and an ambient light sensor (3.3 V) with a 560-nm peak absorbance (BH1721, ROHM Semiconductor). The optical components were operated with stable supply conditions, minimizing signal drift.

Each EM coil element was individually addressed by the output of a switch IC. The matrix-format navigation floor was designed for general ferrobotic operations and testing applications, comprising an active matrix array of EM coil elements, which was specifically selected when switch ICs activate corresponding rows and columns in the navigation floor (Extended Data Fig. 4f). Switch ICs were controlled via serial peripheral interface by an Arduino Nano, which in turn communicated with a computer through serial communication. Target coordinates preprogrammed or sent from the user interface were translated to serial peripheral interface commands by the Arduino and then transmitted to switch ICs for addressable activation of the EM coils. The EM navigation floor can be functionalized with benchtop instruments (laptop and power supplies) or as a self-sufficient battery-operable handheld unit (Supplementary Fig. 9 and Supplementary Video 4).

### Microfluidic device fabrication

The microfluidic chips were fabricated by assembling layers of double-sided tape and transparent PET film sheets. In particular, one and six layers of double-sided tape were used to construct microfluidic chips with corresponding heights of approximately 150 μm and 900 μm. Patterns were laser cut into the double-sided tape and PET to make microchannels (VLS 2.30, Universal Laser System). The double-sided tapes and PET sheets were then thoroughly cleaned by immersing them in an acetone ultrasonic bath for 5 min, followed by repeating this cleaning process with isopropyl alcohol and deionized water. To completely dry the cleaned microfluidic layers, the devices were baked at 65 °C for 4 h. To make the surface of the microchannels hydrophobic, the inner surface of double-sided tape and PET sheets were exposed by a shadow mask and treated with NeverWet base-coat spray (Rust-Oleum), followed by resting for 30 min. The devices were then again treated with NeverWet top-coat spray, followed by incubation at room temperature for 12 h. The droplet merging electrodes were patterned on PET sheets by photolithography using positive photoresist (AZ5214E, MicroChemicals), followed by the evaporation of 20 nm of Cr and 100 nm of Au and a lifting-off step in acetone. The fabricated microfluidic devices were preloaded with oils containing various concentrations of surfactants and reagents for experiments.

### Maximum transportation velocity characterization within different oil environments

Microfluidic devices with 50 × 30 × 0.7-mm inner chambers were fabricated and assembled. A ferrobot was placed on top of the navigation floor and below the microfluidic device. Microfluidic chambers filled with different oils including mineral oil, FC-40 (with or without 5% Perfluoro) or Novec 7500 (with or without 0.01% PicoSurf) were used for velocity characterization. After the ferrofluid droplets (2 μl) were loaded in the microfluidic chambers, these droplets moved along with the ferrobot, which was sequentially guided by the EM coils actuation in an array from left to right. The velocity of the ferrobot was controlled by adjusting the time interval between activating two adjacent coils. If the ferrofluid droplet followed the ferrobot to the end successfully, then the velocity of the magnet would increase by shortening the actuation time interval (by 1 ms) in the next round until the droplet failed to follow the magnet.

### Droplet aliquoting characterization setup and procedure

To validate the aliquoting operation in the optimized oil environment, microfluidic devices (with heights of approximately 150 μm or 900 μm) containing various corrugated wall structures were designed. Devices with different opening widths (0.2, 0.4, 0.8, 1.2 and 1.6 mm) at the corrugated wall were fabricated, assembled and tested. After a parent ferrofluid droplet was loaded in each device (2 μl and 10 μl for devices with channel heights of 150 μm and 900 μm, respectively), it was transported by the ferrobot along the same-sized repeated corrugated structures to aliquot smaller ferro-droplets. The aliquoted droplets were imaged to measure the droplet size.

### Merging characterization setup and procedure

A microfluidic device for merging and mixing was fabricated and assembled, with patterned electrocoalescence electrodes (1-mm width, spaced 2 mm apart, thicknesses of 20 nm of Cr and 100 nm of Au) on PET substrate. To characterize merging, after two 5 μl ferrofluid droplets were loaded in each microfluidic device filled by Novec 7500 with different PicoSurf surfactant concentrations (0.01%, 0.05%, 0.1%, 0.5% and 1%), the two droplets were manipulated by the ferrobot to the vicinity of the actuation electrode. A gradually increased (increments of 0.1 V) DC voltage was applied between the two electrodes until the droplets merged.

### Mixing characterization setup and procedure

To characterize active mixing, the device was loaded with one 5-μl coloured ferrofluid droplet and one 5-μl transparent water droplet. After merging, the underlying ferrobot was directed to induce chaotic fluid motion within the merged droplet with different frequencies (0.2, 1, 3 and 5 Hz). A video recording was taken for the mixing process, and the droplet homogenization rate was calculated through image processing. To quantify mixing efficiency, the video frames were imported into MATLAB, and the pixel data (in greyscale) at the droplet region were extracted. A mixing index is defined as:

$${\rm{Mixing}}\;{\rm{index}}=1-\sqrt{\frac{1}{N-1}\mathop{\sum }\limits_{i=1}^{N}\frac{{\left({c}_{i}-{c}_{{\rm{ave}}}\right)}^{2}}{{c}_{{\rm{ave}}}^{2}}}$$

where N, ci and cave are the total number of pixels, the greyscale values at pixel i and the average greyscale values over N pixels, respectively.

### Characterization of long-term cyclic ferrobotic operations

A microfluidic device that contains two chambers and a connection channel in between was fabricated and assembled. The connection channel contains a corrugated wall structure and a pair of merging electrodes deposited on the PET substrate. After a 7.0-µl ferro-droplet was loaded into the microfluidic chamber, the ferrobot manipulated the ferro-droplet periodically: dispense the droplet into mother and daughter droplets when transporting from the right chamber to the left chamber, and merge the mother droplet with the dispensed droplet when transporting from the left chamber to right chamber. These actions were repeatedly performed for more than 800 cycles. Images were taken during the whole process, and the dynamic variation of the droplet size was measured through image analysis. To demonstrate the extreme reliability of the ferrobotic droplet actuation across different ionic strength and chemical conditions, 10 droplets with differing compositions (H2O, PBS, 0.1 M and 1 M HCl, 0.1 M and 1 M KCl, 0.1 M and 1 M NaCl, and 0.1 M and 1 M NaOH) were actuated by designated ferrobots over more than 70,000 cycles (12 commuted pixels per cycle per ferrobot) and 24 h. The actuation events and commuted pixels are tracked by monitoring the current through the designated impedance sensing gold electrode pairs (with the aid of CH Instrument 660E; applied voltage of 1 V).

### Programmable heating characterization setup and procedure

To implement programmable heating, a microfluidic device was placed on the PCB that contained resistive heaters. The heated region in the chip was placed right above the location of the resistive heater. Copper cubic blocks (3 mm in length, 0.8 mm in width and 2 mm in height) were placed between the PCB surface and the microfluidic chip for heat transduction. To characterize the heating function, different current was applied through the resistive heater (0–0.14 A), inducing a temperature increase by Joule heating. The temperature was then measured by a thermocouple. By programming the current through the resistive heater, the local temperature could be set in relation to the surrounding temperature (Supplementary Fig. 2b,c). If increased precision control of local temperature is desired, a temperature sensor can be integrated to form an internal real-time closed-loop temperature control mechanism.

### Off-chip RT-LAMP characterization

To detect RNA, RT-LAMP assays were conducted at room temperature. As the standard protocol described by NEB, every 25-μl RT-LAMP assay included 12.5 μl WarmStart Colorimetric RT-LAMP 2X master mix, 2.5 μl guanidine hydrochloride, 2.5 μl target RNA primer mix, 5.5 μl nuclease-free water and 2 μl input sample. To characterize the RT-LAMP assay for SARS-CoV-2 detection, single-stranded RNA fragments of SARS-CoV-2 diluted to various concentrations (0, 25, 100 and 1,000 copies per microlitre) were mixed with the assay as input sample, then the RT-LAMP assays were incubated at 65 °C for 30 min. After incubation, the assays were further analysed by Nanodrop One (Thermo Fisher Scientific) and gel electrophoresis. Plate reader Cytation 5 (BioTek) was also used to record the assay absorbance (at 560 nm) during incubation (at 65 °C) using a 384-well plate.

### RT-LAMP characterization within the ferrobotic chip

To characterize the RT-LAMP assay performance within the ferrobotic chip, a 20-μl RT-LAMP assay containing ferrofluid was prepared for the on-chip reaction. The compositions of the assay were: 10 μl WarmStart Colorimetric RT-LAMP 2X master mix, 2 μl guanidine hydrochloride, 2 μl target RNA primer mix, 5 μl nuclease-free water and 1 μl input sample. The input sample contained single-stranded RNA fragments of SARS-CoV-2 in various concentrations (0, 25, 100 and 1,000 copies per microlitre) and 13% of ferumoxytol. The RT-LAMP assays were loaded in the testing microfluidic device and incubated at 65 °C for 30 min. The incubation process of the assay was recorded by video. After the RT-LAMP reaction, the colour was quantitatively measured by the optical sensing module. A similar procedure was performed with a 2-μl RT-LAMP assay and using microfluidic devices with reduced height (approximately 150 μm), when characterizing the response of the assay to 100 nl input samples.

### Standard RT–PCR test for clinical samples

The TaqPath COVID-19 RT–PCR assay targets the SARS-CoV-2 genes encoding S, N and ORF1ab. Extraction was performed on the automated KingFisher Flex Purification System. RT–PCR was performed on the Applied Biosystems 7500 Real-Time PCR Instrument. Detection of two or more targets was considered positive. All testing was performed on nasopharyngeal swabs collected from symptomatic patients. The Ct values were extracted from each instrument and represent a midpoint between the target genes.

### Off-chip RT-LAMP detection for clinical samples

All clinical samples were obtained following approval from the University of California, Los Angeles, Institutional Review Board (IRB#21-000982). Clinical samples were collected using a nasal swab, stored in the viral transport media at −80 °C, and added into PBS buffer (20% viral transport media + 80% PBS buffer) with inactivation reagent (including 6 mM NaOH for adjusting pH, 2.5 mM TCEP-HCl and 1 mM EDTA). For the off-chip RT-LAMP test, the samples were placed in a heat block set to 95 °C for 5 min to be inactivated. RT-LAMP assays were prepared following the off-chip protocol and incubated at 65 °C for 30 min. Optical images were taken after the incubation.

### Ferrobotic individual clinical sample testing

To perform ferrobotic SARS-CoV-2 individual tests on clinical samples, microfluidic devices containing a sample input chamber, a ferrofluid chamber, an assay chamber, two pairs of merging electrodes (patterned at the sample input chamber and the assay chamber) and a dispensing structure were fabricated and assembled. Each microfluidic chip was preloaded with a ferrofluid droplet (50% ferumoxytol) in the ferrofluid chamber and the RT-LAMP assay solution in the assay chamber (reagent volumes of 1.9 μl and 19 μl for analysis of 100 nl and 1 μl aliquoted samples, respectively). For clinical sample analysis, the starting sample was pipetted into the microfluidic chip at the sample input chamber (via the designated sample inlet). Specifically, 0.52 μl and 5.2 μl of starting samples were correspondingly used for subsequent aliquoting or analysis of 100-nl and 1-μl droplets. Then, heat inactivation and lysis were performed on the PCB for 5 min by powering a 20-Ohm resistive heater with 0.14 A DC current. Thereafter, a ferrobot performed the sample processing steps of transportation, merging, mixing, aliquoting, disposal and delivery to the assay. Then, the on-chip RT-LAMP reaction (at 65 °C) continued for 30 min. The assay readout was measured by the optical sensing module.

### Ferrobotic multiplexed testing

For multiplexed detection of SARS-CoV-2, influenza A–H1N1 and rActin RNA, a microfluidic device with a sample input chamber, a ferrofluid chamber, an assay chamber array, two pairs of merging electrodes (patterned at the sample input chamber and across the assay chamber array) and a dispenser array was fabricated and assembled. Each microfluidic chip was preloaded with a ferrofluid droplet in the ferrofluid chamber and three 19-μl RT-LAMP reaction solutions, containing primers for SARS-CoV-2, influenza A–H1N1 (Thermo Fisher Scientific) and internal control (NEB), respectively, in the assay chamber array. When performing a validation test, a blank sample or negative nasal swab sample either with or without target (spiked with SARS-CoV-2 and/or an influenza A–H1N1-positive control) was loaded into the microfluidic chip at the sample input chamber. Inactivation or lysis was then performed on the PCB for 5 min by powering a 20-Ohm resistive heater with a 0.14 A DC current. Thereafter, a ferrobot performed the sample processing steps of transportation, merging, mixing, aliquoting, disposal and delivery to the assays. Each RT-LAMP assay solution ended up receiving a 1 μl ferro-sample. Then, the on-chip RT-LAMP reaction (at 65 °C) continued for 30 min. The readout for each assay was measured by the optical sensing module.

### Ferrobotic pooled clinical sample testing

For pooled tests of clinical samples, microfluidic devices with a matrix array of sample input chambers, dispensers, two arrays of assay chambers and five pairs of merging electrodes (patterned across the assay well arrays and mixing regions) were fabricated and assembled. The assay chambers were preloaded with RT-LAMP assay solutions (reagent volumes of 1.9 μl and 19 μl for 100 nl and 1 μl aliquoted samples, respectively). A number of 3.5-μl heat-inactivated starting ferro-samples were loaded into the input chambers (9 for 32 and 16 for 42 pooling testing). Thereafter, ferrobots performed the sample processing steps of several rounds of aliquoting, transportation, merging, mixing and delivery to the corresponding assay chambers. The navigation planning of the ferrobots accounted for the maintenance of an inter-ferrobot distance of 10 mm to avoid inter-ferrobot magnetic interference. The on-chip RT-LAMP reaction took place for 30 min (at 65 °C). The assay readout was measured by the optical sensing module.

### RT-LAMP validation in a diluted clinical sample

Five nasal swab samples (originally obtained from donors infected with COVID-19, pre-characterized via RT–PCR) with various Ct values (11, 15.7, 21.16, 24.97 and 28.95) were diluted in PBS with different dilution rates (4, 9, 16 and 25). Then, all of the diluted and undiluted samples were tested by both standard off-chip RT-LAMP and on-chip RT-LAMP testing. The reaction products of standard off-chip RT-LAMP were visually recorded in tubes. The reaction products of on-chip individual RT-LAMP were visually recorded in the microfluidic chips, then quantitatively measured by the optical sensing module.

### Reporting summary

Further information on research design is available in the Nature Research Reporting Summary linked to this article.