Skip to the content
4 layers94 × 78 mmUfluidics, the printed circuit board in 3D

Firmware for an Elegoo Mega 2560 R3 driving five NEMA17 syringe pumps on a microfluidic device.

Size
94 × 78 mm
Copper layers
4
Thickness
1.65 mm
Parts
86
Nets
84
Pads
343
Tracks, vias
651, 46
Pours
3
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
31 Jul 2026
Updated
14 Sep 2026

Overview

Ufluidics is an open-source printed circuit board by pyshrekek, from the pyshrekek/ufluidics repository on GitHub. It is a 4-layer board of 94 × 78 mm with 86 parts on 84 nets, routed with 651 tracks and 46 vias.

It is built around the ESP32-S3-WROOM-1-N8, LM2675M-5.0 and AP7361C-33E, with the SS34, BZV55C15 and SMBJ26A among its other parts. Its parts include 20 connectors, 17 capacitors, 12 resistors, 7 diodes and 3 ICs. It belongs with the ESP32 boards of this library.

Main components

7

README

README.md

ufluidics

Firmware for an Elegoo Mega 2560 R3 driving five NEMA17 syringe pumps on a microfluidic device.

Two input pumps push a fixed total flow into the chip at a fixed ratio to each other. Three output pumps withdraw exactly that same total, split three ways. Two potentiometers set the output split live, and a maintained switch arms and disarms the system.

Mass balance holds by construction, not by tuning. No pump is ever commanded directly: one total flow constant drives both inputs (by a fixed ratio) and all three outputs (by fractions that sum to 1.0). There is one source of truth for flow in the entire program.

Dependency

AccelStepper by Mike McCauley. Arduino IDE: Tools > Manage Libraries, search "AccelStepper", install.

Used in constant-speed mode only. runSpeed() is polled for all five pumps on every loop pass and no acceleration ramp is configured, because steady volumetric flow is the whole point and a ramp would corrupt the mass balance every time a pot moved.

Repository layout

text
ufluidics/
  README.md          this file - the Mega firmware: wiring, calibration, verification
  HARDWARE.md        PCB spec for the ESP32-S3 revision

  arduino/ufluidics/ Mega 2560 firmware (Arduino IDE)
    ufluidics.ino
    config.h

  firmware/          ESP32-S3 firmware (PlatformIO) - see firmware/README.md
    platformio.ini
    include/config.h
    src/{flow,motion,main}
    data/            LittleFS web assets

  hardware/          KiCad project
    ufluidics.kicad_{pro,sch,pcb}

Two builds coexist deliberately: the Mega rig stays working while the ESP32 board is developed. src/flow.cpp in the ESP32 build is the AVR flow math ported without modification - see firmware/README.md.

arduino/ufluidics/ must keep that directory name. The Arduino IDE requires a sketch folder named exactly after its .ino. The repository root can be named anything.

The three KiCad files must also keep a shared basename - that is a KiCad requirement, not a convention. Rename all three together or none.

Configuration at a glance

At 1/16 microstepping with a 2 mm lead screw and a 14.5 mm syringe bore:

QuantityValue
steps/mm1600
uL/mm165.13
steps/uL9.69
uL per step0.103
Full 10 mL stroke60.6 mm, 96 893 steps

Input flow is fixed in firmware, not pot-controlled:

PumpFlowShare of totalStep rate
IN170 uL/min6.25%11.3 steps/s
IN21050 uL/min93.75%169.6 steps/s
Total1120 uL/min (1.12 mL/min)--
OUT3 at a 100% split (worst case)1120 uL/min-180.9 steps/s

The two pots only set how that fixed total is divided between the three outputs.

Flow is smooth: the 0.103 uL step quantum is delivered 11 to 181 times a second, so pulsatility is not a concern. Peak rate is 181 steps/s against the 2000 steps/s ceiling - an 11x margin, and the shortest step interval is 5.5 ms. That is comfortably inside where a polled step generator is accurate, so AccelStepper's loop-latency behaviour is not a practical concern at these rates.

Barrel capacity is the binding constraint - read this

The mechanics are comfortable at these rates; the syringes are what limit a run. Every barrel is currently 10 mL, and the 15:1 input ratio means they do not last remotely the same time:

PumpFlow10 mL barrel lasts
IN170 uL/min143 min
IN21050 uL/min9.5 min
OUT3 at a 100% split1120 uL/min8.9 min

IN2 is the limiting pump. A 10 mL barrel gives it under a 10 minute run.

For both inputs to exhaust together, barrel volumes want the same 15:1 proportion as the flows - 10 mL on IN1 against 150 mL on IN2 would both run 143 minutes. A 60 mL syringe on IN2 gives 57 minutes, which is usually the practical sweet spot. Nothing in firmware can extend this; it is a straight volume-over-rate limit.

The output side needs the same thought. The three outputs collectively receive the full 1120 uL/min, so whichever fills first ends the run - and OUT3 can be handed up to 100% of it.

Mixing barrel sizes needs a small firmware change. SYRINGE_ID_MM and SYRINGE_VOLUME_UL are global today, one geometry shared by all five pumps, which is also what the end-of-travel check uses. Making them per-pump arrays in the shape of STEP_PIN[] and DIR_SIGN[] is roughly a 20 line change across both files.

Note on resolution

The A4988 microstep table tops out at 1/16 (MS1/MS2/MS3 all high); 1/32 is not reachable on that chip.

The 2 mm lead screw compensates for that. Dropping from 8 mm to 2 mm pitch quadruples resolution at the same microstepping: each step displaces 0.103 uL instead of 0.41 uL. That is finer than a DRV8825 at 1/32 would have given on the old 8 mm screw, so the driver is not the limiting factor.

Set MICROSTEPS and LEADSCREW_PITCH_MM in config.h to match the hardware and every derived value follows automatically.

Wiring

Pins are freely reassignable in config.h; nothing depends on a particular port.

SignalPinNotes
STEP 1-5D22, D23, D24, D25, D26STEP_PIN[]
DIR 1-5D30, D31, D32, D33, D34DIR_PIN[]
ENABLED28Shared across all five drivers, active LOW
RUN switchD2Maintained/latching, closed to GND. Internal pullup
Pot AA0Sets OUT1's share
Pot BA1Sets OUT2's share
Status LEDD13Off = idle, solid = running, blinking = fault

The RUN switch needs no pulldown or external pullup - INPUT_PULLUP handles it, and an open switch reads HIGH (idle).

Pots wire as dividers: outer legs to 5 V and GND, wiper to the analog pin.

Pump index order is IN1, IN2, OUT1, OUT2, OUT3. OUT1 and OUT2 are pot-controlled; OUT3 absorbs the remainder, so it is the largest stream at typical settings.

Power

  • Set each driver's Vref before connecting any motor. For an A4988 with 0.1 ohm sense resistors, Vref = Imax * 8 * Rsense; a 1.5 A NEMA17 wants roughly 1.2 V. Getting this wrong at 24 V destroys drivers and cooks motors.
  • 24 V goes to driver VMOT only. The Mega runs from USB or its own barrel jack.
  • Grounds must be common between the 24 V supply and the Mega.
  • Put a 100 uF electrolytic across VMOT/GND at each driver, close to the pins.
  • Never hot-plug a stepper into a powered driver. It kills the output stage.
  • Confirm the MS jumpers match MICROSTEPS. A mismatch scales every flow rate by 2x to 16x with no error indication anywhere.

Operation

Load input syringes full and output syringes empty before arming. The firmware tracks travel by counting steps from this assumed starting state; it has no way to sense actual plunger position.

The RUN control is a maintained (latching) switch, so its position is the request - the firmware follows the level rather than toggling on an edge.

  • Close the switch to arm. The LED goes solid and the drivers energise.
  • Open it to disarm.
  • Turn any pot at any time. Total flow and the split update live without stopping flow.
  • If any syringe reaches the end of its stroke, the system halts itself, disables the drivers, blinks the LED, and prints which pump hit the limit. Open the switch to acknowledge - that resets the volume accounting and returns to idle, so it must not happen without an actual syringe reload.

The system will not arm on power-up from an already-closed switch. The switch has to be seen open at least once first (g_armInhibit). Without that, restoring power to a rig left switched on would start pumping with nobody present and with syringe positions assumed rather than known. The banner prints [arm] RUN switch open, ready to arm once the interlock clears.

Serial telemetry runs at 115200 baud, one line per second:

text
state   OUT1/OUT2/OUT3 split   then per pump: uL/min (syringe uL)
RUN     50.0/30.0/20.0%   IN1 100.0(9987) IN2 1000.0(9871) OUT1 550.0(129) OUT2 330.0(77) OUT3 220.0(51)

The column header re-emits every 20 rows (TELEMETRY_HEADER_ROWS), so opening the serial monitor after boot still tells you what the numbers are - no reset needed. Inputs report volume remaining in the barrel, outputs report volume accumulated.

The boot banner prints uL per step, both fixed input flows with their step rates, the input ratio, total flow, and the fastest pump's rate. Those are the numbers that tell you whether the mechanics suit the configured flow.

Details worth knowing

Telemetry is non-blocking. Serial.print() blocks once the 64-byte UART buffer fills, and anything that blocks stops runSpeed() from being polled. AccelStepper timestamps each step as it happens rather than against a fixed schedule (its own source comments "does not account for costs in step()"), so a stalled loop turns directly into lost volume that is never made up. Status lines are therefore staged in a buffer and drained only as fast as the UART has room. A slow terminal throttles telemetry instead of corrupting flow.

Both speed limits are enforced at compile time. AccelStepper::setSpeed() silently clamps against setMaxSpeed(), so a too-fast configuration would quietly under-deliver with no visible symptom. static_asserts in config.h check the fastest possible pump (MAX_PUMP_SPS, OUT3 at a 100% split) and the slowest (MIN_IN1_SPS, always IN1) against the configured flow. A wide input ratio squeezes both ends of that window at once, which is why the checks are paired: raising IN2_TO_IN1_RATIO pushes IN2 toward the ceiling and IN1 toward the floor simultaneously.

The pot span has margins at both ends, and they are required. POT_DEADBAND only lets the applied value move once the reading shifts by more than 8 counts. At the ends of travel there is nothing beyond to push it those last counts, so it strands short of the rail and 0%/100% become unreachable - the symptom is OUT3 bottoming out around 10.6% instead of 10.0% and topping out at 99.5% instead of 100%. Real pots compound it, since track end resistance often stops the wiper reading a true 0 or 1023. POT_RAW_MIN/POT_RAW_MAX discard the outer counts of the sweep so both rails are always reachable, and a static_assert enforces that the margin clears the deadband.

There is a minimum speed, and it is a correctness limit. setSpeed() computes _stepInterval = 1000000.0 / speed into an unsigned long. At 1 uL/min a pot near the bottom of its travel can command about 7.1e-5 steps/s, which works out to an interval of 1.4e10 us against a uint32 ceiling of 4.29e9. It wraps, and the pump then runs roughly 3x faster than commanded rather than slower. applySpeeds() therefore floors anything below MIN_SPEED_SPS to a true stop. Verified against the library source, not assumed.

Tuning

Everything of interest is in config.h:

c
#define IN1_FLOW_UL_MIN       70.0f   // fixed; IN1 takes 1/16 of total
#define IN2_TO_IN1_RATIO      15.0f   // -> IN2 1050, total 1120 uL/min
#define OUT_POT_MAX_FRAC   0.45f   // per-pot ceiling; OUT3 floor is 1 - 2x this
#define SYRINGE_ID_MM      14.5f   // MEASURE THIS
#define MICROSTEPS         16      // must match the driver jumpers
#define LEADSCREW_PITCH_MM 2.0f    // must match the actual screw
#define POT_RAW_MIN        16      // pot end margins; must exceed POT_DEADBAND
#define POT_RAW_MAX        1007

If a pump runs backwards, flip its entry in DIR_SIGN[]. Do not rewire.

Verification

  1. Compile. Arduino IDE with the board set to Arduino Mega 2560, or arduino-cli compile --fqbn arduino:avr:mega .
  2. Bench test with no motors and no 24 V. USB power only. Open the serial monitor, confirm the arm interlock reports the switch open, close the switch, sweep both pots. The three output percentages must always sum to 100.0. Both pots at minimum must give OUT3 exactly 100.0%, both at maximum exactly 10.0%. If the endpoints come up short (10.6%, 99.5%), the pot end margins are too small - raise POT_RAW_MIN and lower POT_RAW_MAX.
  3. Watch the STEP pins on D22-D26 before any liquid is involved. At 1 uL/min this is not a scope measurement - it is one pulse every 12.4 s on each input pump, so an LED on the pin or a logic analyzer in single-shot is the practical tool. Count the interval against the boot banner. This is the only way to catch a microstepping jumper mismatch or a wrong LEADSCREW_PITCH_MM, which are otherwise completely invisible.
  4. Dry motor run with motors off the lead screws and 24 V on. The two input motors turn one way, the three outputs the other. Expect visibly discrete steps, not rotation - that is the flow rate, not a fault. 4b. Sanity-check the timing before trusting a long run. Not needed at these rates - the pumps step 16 to 291 times a second, so behaviour is observable in real time. Debugging a system that steps twice a minute is otherwise very slow going.
  5. Gravimetric calibration. This is the test that validates the whole chain. Run one input pump alone for a timed 60 s into a tared weigh boat and compare mass in mg against expected uL. A consistent percentage error means SYRINGE_ID_MM is wrong; correct it and the error disappears from all five pumps at once, because everything derives from that one constant.
  6. Fault check. Temporarily set SYRINGE_VOLUME_UL to 200, run, and confirm the system halts and blinks on schedule.

Parts

86
QtyValueFootprintReferences
10Conn_01x08Connector_PinSocket_2.54mm:PinSocket_1x08_P2.54mm_VerticalJ1, J2, J4, J5, J7, J8, J10, J11, J13, J14
6Conn_01x02Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_VerticalJ_ENDSTOP_IN1, J_ENDSTOP_IN2, J_ENDSTOP_OUT1, J_ENDSTOP_OUT2, J_ENDSTOP_OUT3, J_RUN_SWITCH1
5100 uF, 50V electrolyticCapacitor_THT:C_Radial_D8.0mm_H11.5mm_P3.50mmC10, C11, C12, C13, C14
5100nFPCM_JLCPCB:C_0402C2, C4, Cinx1, Cinx2, Cinx3
5Conn_01x04Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ3, J6, J9, J12, J15
410kΩPCM_JLCPCB:R_0603R1, R2, R3, R7
31uFPCM_JLCPCB:C_0805C1, C6, C8
34.7uFPCM_JLCPCB:C_1206Cin1, Cin2, Cin3
3Conn_01x02Connector_JST:JST_PH_B2B-PH-K_1x02_P2.00mm_VerticalJ_LED_FAULT1, J_LED_PWR1, J_LED_RUN1
3Conn_01x03Connector_JST:JST_XH_B3B-XH-A_1x03_P2.50mm_VerticalJ_DEBUG_UART1, J16, J17
21kΩPCM_JLCPCB:R_0603R5, R10
24.7kΩPCM_JLCPCB:R_0603R8, R9
247uFCapacitor_SMD:C_1210_3225MetricC21, C22
25.1kΩPCM_JLCPCB:R_0603R11, R14
2SS34PCM_JLCPCB:D_SMAD2, D6
2Tactile Button, 160gfPCM_JLCPCB:SW_TS-1088-AR02016S1, S2
1100kΩPCM_JLCPCB:R_0603R13
110nFPCM_JLCPCB:C_0805Cb1
12 A, 5x20 mmFuse:Fuseholder_Cylinder-5x20mm_Stelvio-Kontek_PTF78_Horizontal_OpenF1
12.2kΩPCM_JLCPCB:R_0603R6
122uFPCM_JLCPCB:C_0805C3
1470 uF 35VCapacitor_THT:C_Radial_D10.0mm_H16.0mm_P5.00mmC5
168uHInductor_SMD:L_SXN_SMDRI127L1
1AP7361C-33EPackage_TO_SOT_SMD:SOT-223-3_TabPin2U3
1BZV55C15Diode_SMD:D_MiniMELFD7
1Conn_01x02Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ21
1Conn_01x03Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ18
1Conn_01x04Connector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_VerticalJ19
1Conn_01x09Connector_JST:JST_XH_B9B-XH-A_1x09_P2.50mm_VerticalJ20
1Connector, USB-TYPE-C-16PPCM_JLCPCB:TYPE-C-SMD_HX-TYPE-C-16PINJ22
1ESP32-S3-WROOM-1RF_Module:ESP32-S3-WROOM-1U1
1GreenPCM_JLCPCB:D_0805D1
1LM2675M-5Package_SO:SOIC-8_3.9x4.9mm_P1.27mmU5
1LOGODownloads:letsgoookicadG***
1RedPCM_JLCPCB:D_0603D3
1SMBJ26APCM_JLCPCB:D_SMBD8
1SUD50P06-15Package_TO_SOT_SMD:TO-252-2Q1
1Screw_Terminal_01x02TerminalBlock_4Ucon:TerminalBlock_4Ucon_1x02_P3.50mm_HorizontalJ_POWER_IN1
1YellowPCM_JLCPCB:D_0603D5

The 82 most common of 86 parts.

Similar boards

  • 4 layers56.5 × 45 mmPower board, the printed circuit board in 3D

    Power board

    alex-dnd/power_board

    Универсальная четырёхслойная плата питания от 6S на LMR33630: выходы 5 В и 7 В до 3 А. KiCad 10.

    51 parts
  • 4 layers68.6 × 53.3 mmDc shield, the printed circuit board in 3D

    Dc shield

    eurovibes/dc_shield

    IFX9201 based Arduino Uno R3 motor shield

    53 parts
  • 4 layers65 × 56 mmCanary hat, the printed circuit board in 3D

    Canary hat

    danbrunski/canary

    Four 25 F cells in series for CANary-PWR's LTC3350 hold-up, on a lead (design record: docs/CANary-PWR-Spec.md §P4). The board has no active parts: four cells, an NTC, two Kelvin net ties and a Micro-Fit 2 × 5 header.

    66 parts
  • 4 layers60 × 60 mm数控buck, the printed circuit board in 3D

    数控buck

    JasonClock/CNC_Buck

    78 parts1
  • 4 layers42.4 × 66.1 mmNB IoT PCB rev 1 1, the printed circuit board in 3D

    NB IoT PCB rev 1 1

    JurCag/NB_IoT_app

    Project utilizes NB-IoT technology to transmit sensory data to the cloud, while simultaneously enabling local communication through BLE mesh.

    58 parts3
  • 2 layers95 × 46 mmLEDDs, the printed circuit board in 3D

    LEDDs

    VasilKalchev/LEDDs

    PCB and enclosure design of a trailing edge light bulbs dimmer

    91 parts2MIT
  • 2 layers146.6 × 112.5 mmBody Control Module, the printed circuit board in 3D

    Body Control Module

    Mustafa614/Body-Control-Module-Mini

    This Module are controlling wipers,baclights,door statues and comminicates with another ecu's via can bus

    74 parts
  • 2 layers46.2 × 61.4 mmMotorDriverCarrier, the printed circuit board in 3D

    MotorDriverCarrier

    DVA490-474-Project-Course/SSL-Hardware-Development

    Contains all hardware related material. (No software).

    37 partsMIT

Questions

How big is the Ufluidics PCB?

It measures 94 × 78 mm and has 4 copper layers, 1.65 mm thick.

What parts does the Ufluidics use?

86 parts, built around the ESP32-S3-WROOM-1-N8, LM2675M-5.0, AP7361C-33E and SS34. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Ufluidics KiCad files?

From the pyshrekek/ufluidics repository on GitHub, at the commit this page was made from: the board is hardware/ufluidics.kicad_pcb and its schematic hardware/endstops.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Ufluidics design in my own project?

Its repository states no licence, so its author keeps all rights: ask pyshrekek before reusing the design.