Community project

iot enabled medical device

Photo of iot enabled medical device

TheDum -E

Last updated November 2, 2026

This project demonstrates a water-only bench rig for an IoT-enabled peristaltic pump system built around an ESP32 microcontroller. The setup integrates motor control via a DRV8833 driver, real-time monitoring with an HX710B pressure sensor and TCRT5000 line tracker, and safety features including a hardware-only STOP button override and audible alarm. Builders will receive a complete wiring diagram, parts list, step-by-step assembly instructions, and firmware code that handles PWM pump speed control, sensor integration, and emergency shutdown logic.

This bench demonstration is designed for supervised testing and development only—not for medical or human use. The guide walks through motor regulator configuration, power rail setup, sensor wiring at 3.3 V logic levels, and a powered checkout procedure to verify the motor path and control logic before operation.

Wiring diagram

Loading diagram…

Gather all the parts

QtyComponent
1

3 V peristaltic micro-pump

The existing small pump moves water in this supervised bench test.

1

TCRT5000 IR Line Tracking Sensor Module

LM393 reflective IR module; operate at 3.3 V

Single-channel infrared reflective sensor module built around the Vishay TCRT5000 IR emitter/phototransistor pair. An onboard LM393 comparator with a sensitivity trim-pot drives a thresholded digital output (DO) for line-detection or obstacle-avoidance, while a separate analog pin (AO) exposes the raw reflected-IR reading. Runs on 3.3V-5V, senses reflective surfaces roughly 1-25mm away, and is the standard low-cost sensor on line-following and obstacle-avoiding robot kits. Sold as a generic 4-pin (VCC/GND/DO/AO) breakout under many brand names (HiLetgo, ACEIRMC, OSOYOO, etc.) rather than by a single official manufacturer.

1

Push Button

red momentary, normally open

Momentary push button switch

1

5 V active buzzer

5 V active

A self-oscillating buzzer that sounds when its transistor switch is turned on during a fault.

1

LED

red, 5 mm

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

220 Ω

Through-hole resistor (current-limiting in series with an LED)

1

USB-C 5V Adapter

5 V, 2 A minimum

USB-C wall adapter delivering regulated 5 V to the board's USB or VBUS rail. Default wired power source for desktop / stationary projects.

1

NPN Transistor (2N2222 / BC547)

2N2222 or BC547; verify lead order

General-purpose NPN bipolar junction transistor (BJT) in TO-92 package. Used as a low-side switch to drive loads (e.g. buzzers) whose current exceeds ESP32 GPIO source capability (~12 mA). A ~1 kΩ base resistor is placed between the ESP32 GPIO and the transistor base. The collector connects to the load negative terminal (buzzer –), and the emitter connects to GND. When the GPIO goes HIGH (3.3 V), the transistor saturates and switches the load on. Compatible with both 2N2222/2N2222A and BC547/BC547B variants. Add a flyback diode (e.g. 1N4148) across inductive load terminals.

1

Resistor

1 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

C1 DRV8833 motor-rail decoupling capacitor

0.1 µF ceramic

A small capacitor placed beside the driver to steady its 3.0 V motor supply during switching.

1

C2 motor bulk capacitor

100 µF, 10 V or higher

The existing capacitor reduces electrical noise when the pump starts and stops.

1

1N5819 Schottky diode

1N5819, 1 A 40 V Schottky

A striped-end diode wired across the buzzer to absorb the voltage spike when the buzzer switches off.

1

HX710B 0–40 kPa digital air-pressure sensor module

0–40 kPa, 24-bit digital

A hose-connected digital module that measures pressure in the pump tubing.

1

10 kΩ linear potentiometer

10 kΩ linear

A three-leg adjustment knob that tells the ESP32 the maximum pump speed without carrying pump power.

1

SSD1306 OLED

0.96 inch 128x64 OLED display with I2C interface

1

24v Buck Converter

adjust to 3.0 V before connecting the pump

LM2596-based adjustable step-down buck converter module. Commonly used to regulate a higher battery rail, such as a 2S 18650 pack, down to 5V for Arduino logic. It is a regulator, not a charger or battery protection board.

1

DRV8833 Dual DC Motor Driver

screw-terminal module with an accessible nSLEEP/EN pin

Dual H-bridge DC/stepper motor driver IC or carrier module. VM motor supply range is 2.7V-10.8V; logic inputs support 1.8V, 3.3V, and 5V controllers. TI rates the PWP/RTY package options at 1.5A RMS and 2A peak per H-bridge at VM=5V and 25C; carrier-board current depends on board layout and cooling. Controlled with AIN1/AIN2 and BIN1/BIN2 inputs, which may be driven as digital or PWM signals. nSLEEP must be high for the bare IC, while some carrier boards pull it high by default. nFAULT is an open-drain fault output.

Assemble it in 9 steps

1. Keep this as a supervised water-only bench rig

Arrange the ESP32, modules, and tubing on a dry bench. Send water only into a measuring cup; never connect this prototype to a person or any human-use tubing.

  • This is not a medical device or a certified safety system.

2. Set the motor regulator before joining the pump

With the pump disconnected, connect the USB adapter 5 V output to motor_regulator VIN+ (power) and its GND to VIN− (ground). Turn the regulator adjustment until a meter reads exactly 3.0 V between VOUT+ and VOUT−. Do not connect the pump until this reading is correct.

  • A regulator set above 3.0 V can damage the 3 V pump.
  • Do not set the voltage by guesswork; measure it first.

3. Make the shared ground and motor-power rail

Connect ESP32 GND, motor_regulator VOUT−, DRV8833 GND, sensors, screen, button, LED, and buzzer-transistor emitter to the same ground rail (ground). Connect motor_regulator VOUT+ to DRV8833 VM (3.0 V motor power). Put both the 100 µF capacitor and 0.1 µF capacitor between VM and GND beside the driver: each capacitor’s negative side goes to GND.

  • Never connect the DRV8833 VM pin or the 3 V pump to 5 V.
  • The 100 µF capacitor striped lead goes to GND; reversed polarity can damage it.

4. Wire the DRV8833 and pump

Use a DRV8833 screw-terminal module that exposes nSLEEP or EN. Connect AIN1 to GPIO27 (speed signal), AIN2 to GPIO26 (direction signal), BIN1 and BIN2 to GND (unused channel held off), AOUT1 to pump MOTOR+ (motor power), and AOUT2 to pump MOTOR− (motor power). Leave BOUT1 and BOUT2 unconnected. GPIO25 is no longer used by the motor driver.

  • Do not connect the pump directly to an ESP32 pin.
  • Do not buy a DRV8833 module that hides nSLEEP or EN; the physical Stop button must disable this pin.

5. Wire the STOP-only hardware override

Connect one normally-open button leg to GND (ground). Join its other leg to GPIO33 and the DRV8833 nSLEEP/EN terminal (stop signal). Connect the 10 kΩ resistor from this same junction to ESP32 3V3 (pull-up power). Pressing the button pulls nSLEEP low and disables the driver in hardware; it never starts a run.

  • A permanently low nSLEEP/EN line prevents all motor motion.

6. Wire the sensors and display at 3.3 V

Connect drop sensor VCC to 3V3 (power), GND to GND (ground), and DO to GPIO32 (drop signal). Connect pressure sensor VCC to 3V3 (power), GND to GND (ground), DOUT to GPIO13 (data), and SCK to GPIO14 (clock). Connect OLED VCC to 3V3 (power), GND to GND (ground), SDA to GPIO21 (data), and SCL to GPIO22 (clock).

  • Do not feed 5 V into GPIO32; the drop-sensor output must stay at ESP32-safe 3.3 V.
  • Keep water out of the pressure port.

7. Wire the alarm outputs

Connect GPIO4 through the 220 Ω resistor to the LED long leg (alarm signal) and its short leg to GND. Connect GPIO23 through the 1 kΩ resistor to the verified transistor base (signal), emitter to GND, collector to buzzer negative, and buzzer positive to 5 V. Put the 1N5819 striped end at 5 V and its unstriped end at the collector/buzzer-negative junction.

  • Check the actual transistor package pinout; 2N2222 and BC547 lead order is not interchangeable.

8. Wire the speed-limit knob

Connect one outer potentiometer leg to 3V3 (power), the other outer leg to GND (ground), and the centre wiper to GPIO34 (speed-limit signal). This knob changes only the controller speed limit and must not carry pump current.

  • Never put the potentiometer in series with the pump supply.

9. Perform the first powered check

With the tube in water and the outlet aimed into a cup, confirm that the motor regulator still measures 3.0 V between VM and GND. Then plug in the ESP32 over USB. Press the physical STOP button while the demo is running; it must immediately disable the driver. Use the local page only after this physical check.

  • If the regulator voltage sags or the adapter shuts down when the pump starts, stop testing; the pump startup and stall current remains unverified.

Review all connections

1. Connections between "driver" and "ESP32"

FunctiondriverESP32
groundGND → common groundGND
pwmAIN1 → pump speed commandGPIO 27
pwmAIN2 → pump direction controlGPIO 26
groundBIN1 → unused channel held lowGND
groundBIN2 → unused channel held lowGND
digitalnSLEEP → Push Button SIGNALEXT
dataAOUT1 → 3 V peristaltic micro-pump MOTOR+EXT
dataAOUT2 → 3 V peristaltic micro-pump MOTOR-EXT
dataBOUT1 → Unused B-channel output terminal; leave unconnectedEXT
dataBOUT2 → Unused B-channel output terminal; leave unconnectedEXT

2. Connections between "stop_button" and "ESP32"

Functionstop_buttonESP32
groundGND → Stop button groundGND
digitalSIGNAL → Stop-state inputGPIO 33

3. Connections between "r2_stop_pullup" and "ESP32"

Functionr2_stop_pullupESP32
powerP1 → pull-up supply3V3
digitalP2 → Push Button SIGNALEXT

4. Connections between "c1_logic" and "ESP32"

Functionc1_logicESP32
powerPOSITIVE → DRV8833 Dual DC Motor Driver VMEXT
groundNEGATIVE → common groundGND

5. Connections between "c2_motor" and "ESP32"

Functionc2_motorESP32
powerPOSITIVE → DRV8833 Dual DC Motor Driver VMEXT
groundNEGATIVE → common groundGND

6. Connections between "motor_regulator" and "ESP32"

Functionmotor_regulatorESP32
powerVIN+ → 5 V adapter input5V
groundVIN- → shared input returnGND
powerVOUT+ → DRV8833 Dual DC Motor Driver VMEXT
groundVOUT- → shared motor returnGND

7. Connections between "power_supply" and "ESP32"

Functionpower_supplyESP32
power+5V → 24v Buck Converter VIN+EXT
groundGND → 24v Buck Converter VIN-EXT

8. Connections between "ir_drop_sensor" and "ESP32"

Functionir_drop_sensorESP32
powerVCC3V3
groundGNDGND
digitalDOGPIO 32

9. Connections between "pressure_sensor_hx710b" and "ESP32"

Functionpressure_sensor_hx710bESP32
powerVCC3V3
groundGNDGND
digitalDOUTGPIO 13
digitalSCKGPIO 14

10. Connections between "speed_pot" and "ESP32"

Functionspeed_potESP32
powerVCC3V3
adcWIPERGPIO 34
groundGNDGND

11. Connections between "oled_display" and "ESP32"

Functionoled_displayESP32
powerVCC3V3
groundGNDGND
i2cSDAGPIO 21
i2cSCLGPIO 22

12. Connections between "r3_led" and "ESP32"

Functionr3_ledESP32
digitalP1GPIO 4
digitalP2 → LED ANODEEXT

13. Connections between "alarm_led" and "ESP32"

Functionalarm_ledESP32
groundGNDGND

14. Connections between "buzzer" and "ESP32"

FunctionbuzzerESP32
powerVCC5V
groundGND → NPN Transistor (2N2222 / BC547) COLLECTOREXT

15. Connections between "q1_buzzer" and "ESP32"

Functionq1_buzzerESP32
groundEMITTERGND

16. Connections between "r6_buzzer_base" and "ESP32"

Functionr6_buzzer_baseESP32
digitalP1GPIO 23
digitalP2 → NPN Transistor (2N2222 / BC547) BASEEXT

17. Connections between "d1_buzzer" and "ESP32"

Functiond1_buzzerESP32
powerAnode → NPN Transistor (2N2222 / BC547) COLLECTOREXT
powerCathode5V

Deploy the firmware

/*
  Water-only bench pump demo.
  Not for medical or human use.

  The pump starts at a fixed moderate speed after boot.
  The physical red STOP button only stops the pump; it never starts it.
  Restart the ESP32 to run the demo again after pressing STOP.
*/
#include <Arduino.h>

// DRV8833 channel A has no separate PWM enable pin.
// GPIO27 drives AIN1 with PWM; GPIO26 holds AIN2 LOW for forward drive.
constexpr int AIN2_PIN = 26;
constexpr int PUMP_PWM_PIN = 27;
constexpr int STOP_PIN = 33;

constexpr uint32_t PWM_FREQ_HZ = 18000;
constexpr uint8_t PWM_BITS = 8;
// Full duty is used only to prove the motor power path in this bench demo.
constexpr uint8_t DEMO_PWM = 255;

bool stopped = false;

bool stopPressed() {
  // The button has the existing external 10 kΩ pull-up, so LOW means pressed.
  return digitalRead(STOP_PIN) == LOW;
}

void stopPump() {
  ledcWrite(PUMP_PWM_PIN, 0);
  digitalWrite(AIN2_PIN, LOW);
  stopped = true;
}

void setup() {
  pinMode(AIN2_PIN, OUTPUT);
  pinMode(STOP_PIN, INPUT);
  ledcAttach(PUMP_PWM_PIN, PWM_FREQ_HZ, PWM_BITS);

  stopPump();

  // Do not start if the physical STOP button is already held down.
  if (!stopPressed()) {
    digitalWrite(AIN2_PIN, LOW);
    ledcWrite(PUMP_PWM_PIN, DEMO_PWM);
    stopped = false;
  }
}

void loop() {
  // Once stopped, it remains stopped until the ESP32 is restarted.
  if (!stopped && stopPressed()) {
    stopPump();
  }
  delay(10);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik