You connected your 12V micro diaphragm pump to your Arduino, wrote some simple code, but nothing happened. Or worse, your microcontroller reset or even got damaged.
A microcontroller’s GPIO pin cannot directly power a pump motor. You must use an intermediate driver, like a MOSFET or a dedicated motor controller, to handle the pump’s power while the MCU provides only the low-power control signal. This separation is key to a successful and safe design.
As an experienced project manager at BODENFLO, I have worked with numerous OEM customers on micro diaphragm pump selection and system integration projects. Connecting a pump to a microcontroller is a critical step that requires careful consideration of motor types, wiring configurations, and control methods. Incorrect connections can lead to project delays, unstable pump operation, or even hardware damage. This guide provides practical wiring diagrams, code examples, and troubleshooting tips to help you integrate a micro diaphragm pump with STM32, Arduino, ESP32, or other microcontrollers safely and effectively.
What Type of Micro Diaphragm Pump Are You Controlling?
You have a micro pump, but is it a simple two-wire model or one with extra control pins? The type of motor inside dictates the entire control strategy.
Pumps use either brushed DC motors (two wires), brushless DC motors with integrated drivers (multiple control wires), or bare brushless motors needing an external controller. Identifying your pump type is the first step.
Understanding Your Pump’s Motor
The wiring and control logic depend entirely on the motor technology. Let’s look at the three main categories you will encounter.
- Brushed DC Diaphragm Pumps: These are the simplest. They have two wires: power and ground. Reversing the polarity will make the motor run backward, but for a diaphragm pump, you should only operate it in the intended direction. Speed is controlled by varying the voltage, typically using Pulse-Width Modulation (PWM) through a MOSFET.1
- Brushless DC (BLDC) Pumps with Integrated Drivers: These are very common in OEM applications. They have power and ground wires, plus additional control pins like PWM for speed control, an enable pin for on/off, and an FG (Frequency Generator) pin for speed feedback. The complex motor commutation logic is handled by a small circuit board inside the pump.2
- Brushless DC (BLDC) Pumps with External Drivers: These pumps only expose the motor phase wires (U, V, W). They require a separate, more complex three-phase motor driver (an ESC or BLDC controller) to run. You cannot control these directly from a microcontroller’s PWM pin.
| Pump Type | Wiring Complexity | Control Method | Feedback |
|---|---|---|---|
| Brushed DC | Simple (2 wires) | External MOSFET with PWM | None (unless added externally) |
| BLDC (Integrated) | Moderate (3-5 wires) | Direct PWM signal to pump | FG (Tachometer) signal often available |
| BLDC (External) | Complex (3 phase wires) | Requires external 3-phase driver | Depends on the external driver |
What Components Are Needed to Connect a Micro Diaphragm Pump to an MCU?
You know you need the pump and a microcontroller. But what are the essential components that go in between to make the system work safely and reliably?
You need a regulated power supply for the pump, a driver circuit (like a MOSFET for a brushed pump), appropriate connectors, and potentially a logic-level shifter to ensure signal compatibility.
Your Bill of Materials
Before you start wiring, let’s assemble the key parts. You cannot skip these, especially the separate power supply and driver.
- Microcontroller (MCU): The brain of the operation (e.g., Arduino, STM32, ESP32).
- Pump Power Supply: A regulated power supply that matches your pump’s voltage (e.g., 12V or 24V) and can provide enough current, especially during startup. This must be separate from your microcontroller’s USB or 5V supply.
- Motor Driver: For a brushed pump, you’ll need a logic-level N-Channel MOSFET capable of handling the pump’s voltage and current, along with a flyback diode for protection. A brushless pump with an integrated driver does not need this external component.
- Connectors and Wires: Use appropriate gauge wires for the pump’s current draw.
- Optional Components: A logic-level shifter if your MCU and pump use different logic voltages (e.g., 3.3V and 5V), and a pull-up resistor for reading the FG signal.
| Pump Voltage | Recommended Power Supply | Typical MOSFET |
|---|---|---|
| 5V | 5V, 2A+ | IRLZ44N |
| 12V | 12V, 2A+ | IRLZ44N, STP16NF06L |
| 24V | 24V, 2A+ | STP36NF06L, CSD18532KCS |
How Do You Wire a Micro Diaphragm Pump to a Microcontroller?
You have all the components, but connecting them incorrectly could release the magic smoke. What is the safe, standard way to wire a brushed or brushless pump?
For a brushed pump, use a MOSFET to switch the pump’s ground connection. For a brushless pump, connect its control wires directly to the MCU, ensuring a common ground between the pump’s power supply and the MCU.
Circuit Diagrams and Grounding
Let’s look at the two most common scenarios. In both cases, never connect the pump’s main power directly to an MCU pin.
Wiring a Two-Wire Brushed DC Pump
Here, the MOSFET acts as a low-side switch. The MCU’s GPIO pin turns the MOSFET on and off, which in turn connects or disconnects the pump from ground, making it run or stop. A flyback diode across the pump motor is essential to protect the MOSFET from voltage spikes when the motor turns off.
- Pump V+ to Power Supply V+
- Pump V- to MOSFET Drain
- MOSFET Gate to MCU PWM Pin (with a pulldown resistor)
- MOSFET Source to Power Supply Ground (GND)
- MCU GND to Power Supply Ground (GND) – This common ground is critical!
Wiring a Brushless Pump with an Integrated Driver
This is often simpler as the driver is built-in. Check your pump’s specific datasheet for wire colors.
- Pump V+ (Red) to Power Supply V+
- Pump GND (Black) to Power Supply Ground (GND)
- PWM Input (White/Yellow) to MCU PWM Pin
- FG Output (Blue/Green) to MCU Input Pin (with a pull-up resistor)
- MCU GND to Power Supply Ground (GND) – A common ground is still essential!
How Do You Control Micro Diaphragm Pump Speed Using PWM?
You’ve got the pump wired correctly, but how do you actually tell it to run at 50% speed? The answer is Pulse-Width Modulation, or PWM.
PWM works by sending a series of digital pulses to the pump’s driver. The pump’s speed is determined by the "duty cycle," which is the percentage of time the signal is high versus low.
PWM Fundamentals
- What is PWM? Instead of changing the voltage level (which is inefficient), we switch the power on and off very quickly. For a brushed pump, the MOSFET does this. For a brushless pump, its internal driver interprets the PWM signal as a speed command.
- Duty Cycle: A 0% duty cycle means the pump is off. A 100% duty cycle means the pump is at full speed. A 50% duty cycle means it is running at roughly half speed3.
- Frequency: The speed at which the pulses are sent. This is also important. The pump’s datasheet will specify an acceptable PWM frequency range (e.g., 1 kHz to 20 kHz). Using the wrong frequency can result in audible noise or poor control.
- Startup: Be aware that most pumps will not start at very low duty cycles (e.g., below 10-20%). They need a minimum amount of power to overcome inertia and friction. Your code may need to start the pump at a higher duty cycle before reducing the speed.
Can a 3.3V Microcontroller Control a 5V PWM Pump?
Your ESP32 or STM32 board runs on 3.3V, but the pump datasheet says its PWM input is 5V. Will this work, or do you need to do something special?
A 3.3V MCU can often control a 5V PWM input, but you must verify the pump’s logic-level thresholds (VIH). If the 3.3V signal is not high enough to be reliably read as a "high" signal, you will need a logic-level shifter.
Interfacing Different Logic Levels
This is one of the most common pitfalls in embedded design.
- Understanding Logic Thresholds: Every digital input has a minimum voltage that it will accept as a logic HIGH (V_IH) and a maximum voltage it will read as a logic LOW (V_IL). A typical 5V device might have a V_IH of 2.5V or 3.0V. In this case, a 3.3V signal from your MCU would work perfectly. However, if the V_IH is 4.0V, a 3.3V signal will not be high enough, and the pump will not respond correctly. Always check the pump’s electrical specifications in the datasheet.
- When a Level Shifter is Required: If your MCU’s 3.3V output is below the pump’s V_IH, you must use a logic-level shifter. This simple, inexpensive component takes a 3.3V signal and safely boosts it to 5V, ensuring compatibility.
- Arduino vs. STM32 vs. ESP32: Classic Arduino boards like the Uno use 5V logic. Most modern MCUs, including STM32, ESP32, and Raspberry Pi Pico, use 3.3V logic.4 Always know what logic level your specific board uses.
How Do You Read FG Speed Feedback from a Brushless Micro Pump?
Your brushless pump has an extra wire labeled "FG". What is this for, and how can you use it to make your system smarter?
The FG (Frequency Generator) wire outputs a series of electrical pulses as the motor rotates. By counting these pulses with your microcontroller, you can accurately calculate the motor’s RPM, which confirms the pump is running at the commanded speed.
Using Tachometer Feedback
The FG signal, also called a tachometer signal, is powerful for creating a more robust system.
- How it Works: The FG output is typically an "open-collector" or "open-drain" output. This means it can pull the signal low, but it cannot drive it high. You must add an external pull-up resistor (e.g., 4.7kΩ to 10kΩ) connected to your MCU’s logic voltage (e.g., 3.3V).
- Connecting to the MCU: Connect the pump’s FG wire to an interrupt-capable input pin on your MCU. This allows the MCU to count every pulse without having to constantly poll the pin.
- Calculating RPM: The pump’s datasheet will specify how many pulses the FG output produces for each full revolution of the motor (N). You can then use this formula:
RPM = (FG_Frequency_Hz * 60) / N
For example, if your MCU measures an FG frequency of 500 Hz and the datasheet says N = 6 pulses/revolution, the RPM is(500 * 60) / 6 = 5000 RPM. Note: FG measures motor speed, not the actual flow rate of the liquid or gas.
How Do You Control Pump Flow or Pressure with a Microcontroller?
You can command a motor speed, but your application requires a precise flow rate of 500 mL/min or a stable vacuum of -50 kPa. How do you achieve this?
To control flow or pressure, you must create a closed-loop system. This involves adding a sensor (flow or pressure) and writing code that continuously measures the output and adjusts the pump’s PWM speed to match a target setpoint.
Disclaimer: These are simplified examples. Always adapt the pin numbers, PWM frequency, and logic to your specific hardware and the pump’s datasheet.
Example 1: On/Off Control of a Brushed DC Pump with Arduino
// For a brushed pump controlled by a MOSFET
const int pumpPin = 9; // Use a PWM-capable pin on the Arduino
void setup() {
pinMode(pumpPin, OUTPUT);
}
void loop() {
// Turn the pump on for 5 seconds
digitalWrite(pumpPin, HIGH);
delay(5000);
// Turn the pump off for 5 seconds
digitalWrite(pumpPin, LOW);
delay(5000);
}
### Example 2: PWM Speed Control for a Brushless Pump (Arduino)
```cpp
// For a brushless pump with an integrated driver
const int pwmPin = 9; // Use a PWM-capable pin
void setup() {
pinMode(pwmPin, OUTPUT);
}
void loop() {
// Run pump at 50% duty cycle (128 out of 255)
analogWrite(pwmPin, 128);
delay(5000);
// Run pump at 100% duty cycle (255 out of 255)
analogWrite(pwmPin, 255);
delay(5000);
}
What Are the Most Common Pump Control Problems and Solutions?
Your pump isn’t working as expected. Before you assume the hardware is broken, you can solve most issues by checking a few common areas like wiring, power, and signal compatibility.
Most pump control issues are related to incorrect wiring, an insufficient power supply, or a mismatch between the MCU’s control signal and the pump’s requirements. A methodical approach can solve 99% of these problems.
Here is a table of common problems and their solutions.
| Problem | Possible Cause | Solution |
|---|---|---|
| Pump does not start | No common ground; insufficient power supply current; pump wired backward. | Connect MCU and PSU grounds; use a power supply rated for the pump’s startup current. |
| Pump runs at full speed | PWM input is floating or not recognized; incorrect PWM frequency. | Check PWM wiring; ensure PWM signal meets datasheet specs for frequency and voltage. |
| Pump stalls at low speed | Duty cycle is below the minimum startup threshold. | Start the pump at a higher duty cycle (>25%) before slowing it down. |
| MCU resets when pump starts | Power supply voltage is sagging; electrical noise on the power lines. | Use a separate, robust power supply for the pump; add bypass capacitors. |
| No FG signal | Missing pull-up resistor; incorrect MCU pin configuration (not set as input). | Add a 4.7kΩ-10kΩ pull-up resistor to the FG line; configure pin as an input. |
| Flow is unstable | PWM signal is noisy; open-loop control with changing pressure conditions. | Check for clean wiring; implement closed-loop control with a sensor for stable flow. |
How Do You Select a Micro Diaphragm Pump for Microcontroller Integration?
You’re starting a new project and want to choose the right pump from the very beginning to avoid integration headaches later on. What specifications are most important to check?
Look for a pump with clear documentation that specifies the motor type, PWM input requirements (voltage, frequency), and whether it provides FG feedback. This will save you countless hours of guesswork and troubleshooting.
Having this information ready when you contact a supplier will help you get the best recommendation quickly.
RFQ Checklist for Embedded Developers:
- Performance: What are your target flow and pressure/vacuum requirements?
- Voltage: What is your system’s main power supply voltage (e.g., 12V or 24V)?
- Motor Type: Do you prefer a simple brushed pump or a brushless model with integrated controls?
- Control: Do you need simple on/off or variable speed control via PWM?
- Feedback: Do you need FG speed feedback to monitor pump operation?
- Microcontroller: What MCU are you using, and what is its logic level (3.3V or 5V)?
- Documentation: Is a clear datasheet with electrical specifications and wiring diagrams available?
What Are the Most Common Questions About Pump and MCU Integration?
You’ve read the guide, but a few specific questions remain about power, compatibility, and signals. Getting these small details wrong can lead to last-minute redesigns or damaged components.
To avoid common pitfalls, remember: never power a pump from an MCU, always use a common ground, verify signal voltage compatibility, and understand that PWM commands speed while FG reports it.
Let’s address the most common questions directly with clear, concise answers to ensure your project’s success.
1. Can Arduino power a 12V diaphragm pump directly?
No. An Arduino’s pins can only provide a tiny amount of current at 5V, which is not enough to run a 12V motor and will damage the board. You must use a separate 12V power supply and a MOSFET or motor driver circuit.
2. Can an ESP32 control a 24V micro diaphragm pump?
Yes. The ESP32 (which uses 3.3V logic) can send a control signal to the pump’s driver, while a separate 24V power supply provides the actual power to the pump. Just be sure to create a common ground and check if a logic-level shifter is needed.
3. Can a 3.3V PWM signal control a 5V pump input?
Often, yes, but you must check the datasheet. If the pump’s "High-Level Input Voltage" (V_IH) is below 3.3V, it will work. If V_IH is higher than 3.3V, you will need a logic-level shifter to boost the signal.
4. Do I need a motor driver for a brushless diaphragm pump?
It depends. If the pump has an "integrated driver" (with PWM/FG wires), you do not need an external one. If the pump only has three motor phase wires (U, V, W), then you do need an external three-phase BLDC motor driver.
Conclusion
Successfully connecting a micro diaphragm pump to a microcontroller hinges on separating power from control. By using a suitable power supply for the pump and the correct driver interface for the MCU’s signals, you can build a reliable system. Always start with the pump’s datasheet and verify the wiring, PWM requirements, and signal compatibility before integration.
Need a Micro Diaphragm Pump for Your Microcontroller-Based System?
BODENFLO provides micro diaphragm pumps with customizable flow rates, pressure and vacuum performance, and control options for OEM applications. Whether you’re developing a system using STM32, Arduino, ESP32, or another microcontroller, our team can help you evaluate suitable pump models and electrical interface requirements.
Contact BODENFLO at info@bodenpump.com to discuss your application, technical specifications, and OEM requirements.
-
"Weeks 9-10: DC Motor Controller", http://fab.cba.mit.edu/classes/863.14/people/andrew_mao/week9/. A technical review of brushed DC motor control confirms that speed can be regulated by adjusting the supply voltage, commonly using PWM techniques implemented with MOSFETs. Evidence role: mechanism; source type: education. Supports: Speed is controlled by varying the voltage, typically using Pulse-Width Modulation (PWM) through a MOSFET.. Scope note: The source may discuss general DC motors rather than specifically diaphragm pumps, but the control principle is the same. ↩
-
"Brushless DC electric motor", https://en.wikipedia.org/wiki/Brushless_DC_electric_motor. Technical documentation on BLDC pumps with integrated drivers explains that motor commutation and control logic are managed by an internal circuit board, simplifying external wiring and control. Evidence role: mechanism; source type: education. Supports: The complex motor commutation logic is handled by a small circuit board inside the pump.. Scope note: The source may describe integrated BLDC drivers in general, not specific to all pump models. ↩
-
"Pulse-width modulation", https://en.wikipedia.org/wiki/Pulse-width_modulation. Standard references on pulse-width modulation (PWM) indicate that, for many DC motors, the average voltage applied is proportional to the duty cycle, resulting in an approximate linear relationship between duty cycle and speed, though actual speed may vary due to load and motor characteristics. Evidence role: mechanism; source type: education. Supports: A 50% duty cycle means it is running at roughly half speed.. Scope note: The relationship is approximate and may not be exactly linear for all motors or under all conditions. ↩
-
"Using the ESP32-S3 ULP Coprocessor with the Arduino IDE", https://neurotechhub.wustl.edu/using-the-esp32-s3-ulp-coprocessor-with-the-arduino-ide/. Datasheets and official documentation for STM32, ESP32, and Raspberry Pi Pico confirm that these microcontrollers typically operate at 3.3V logic levels, supporting the claim that most modern MCUs use 3.3V logic. Some variants may support additional voltage levels. Evidence role: definition; source type: education. Supports: Most modern MCUs, including STM32, ESP32, and Raspberry Pi Pico, use 3.3V logic.. Scope note: Some MCU variants may support other voltage levels; this support applies to the most common models. ↩