A.I.M.S - an Arduino Based Automatic IV Infusion Monitoring System
by AdrHiroshi in Circuits > Arduino
926 Views, 4 Favorites, 0 Comments
A.I.M.S - an Arduino Based Automatic IV Infusion Monitoring System
This instructable showcases how an Arduino Nano and a few sensors can be used to create a rudimentary IV infusion monitoring system. In addition to that, we can use the data from the sensors to create an actuator that can automatically adjust the IV infusion dosage.
(Note: The automatic dosage adjuster is mostly a prototype and not medically tested, the adjuster is for educational purposes.)
Supplies
The main components needed to create an automatic IV infusion monitoring system includes the following:
- LM393 Optocoupler Speed Module
- XKC-Y25-NPN non contact fluid sensor
- Arduino Nano (any ATmega328p microcontroller can be used)
- Piezo Buzzer (With On-board oscillator)
- LED (Red.)
The rest of these components were used in the project but are optional, as they are either supporting features such as automatic dosage adjustment or things like 3D printed casings.
- MG996R Servo
- Rotary Switch (6 Position, Dual Pole.)
In terms of materials, we need:
- 3D printing Filament (preferably PETG)
- 3mm Acrylic Sheet (optional, can be supplemented by 3D printing instead)
- 4x M4*15 Screws (heads can be completely up to you)
- Jumper wires
- 1x Blank PCB Board (optional, you can supplement with a breadboard instead.)
- 1x velcro strip
Designing Main Controller Housing
Before we start putting everything together, we need to design a housing for the main controller and components like a rotary switch and ports for wires that lead to the sensors and actuators.
In this design made in fusion, the main controller housing is just a simple box with a rear snap-on clip that is used to attach the housing to an IV stand. Other than that, it has various holes for USB ports and sensor wires.
Afterwards, we can export the .stl file from fusion and slice it on any slicer software, use a slicer compatible with your 3d printer. In this case, the model was sliced using Prusa Slicer and printed on a Prusa MK4. In addition to that, the housing was also printed on an Anycubic Kobra 3 V2.
Additionally, when slicing, try to print the model with the layer lines perpendicular to the IV stand, this ensures that the layer lines are facing the snap-on clip to increase it's strength and eliminate weaknesses from layer lines.
Designing Optocoupler & Drip Chamber Housing
The drip chamber mount is relatively straight forward, the real issue is that depending on the manufacturer the drip chambers can vary in size and features, so it's good to try and design your own housing that fulfills the specifications of your drip chamber. The goal of designing the housing is to place the IR optocoupler sensor in such a way that the droplets coming from the IV fluid blocks or refracts the beam from the receiver, which generates a signal that we can then read using a microcontroller.
Before you design the housing, it's also important that you remove the small black plastic piece on the optocoupler (the black U-shaped piece) to expose the IR LED and IR receiver, this way it is much easier to line up the IR beam path with the IV droplets.
It is recommended to test different heights at which the optocoupler sits inside the housing, since different heights means that the droplet inside the drip chamber takes a different shape, which can alter the performance of the optocoupler sensor in reading accurately.
In this case, the optocoupler picked up the droplets more consistently if it was placed on the bottom half as seen in the photo. However, you might find that placing it higher up gives better performance since the droplet is usually much larger just as it falls down from the IV bag.
Designing the Clamp Body for IV Tubing (optional)
This step is optional if you don't need an automatic dosage adjuster and purely want to monitor IV drip rate. For this step, we need to design a body that can house the IV tubing and a servo that can pinch the IV tube to control the dosage / drip rate. We can call this part the Clamp Body.
The design is simple, just a circular tube with a hole in the middle for the servo, along with the servo horn that is used to pinch the IV tubing.
The acrylic top piece is used to make sure the IV tube doesn't fall out, but it can also be supplemented by a 3d-printed circular piece that covers the Clamp Body, but using an acrylic piece enables us to gauge if the servo is pinching too hard or not pinching hard enough.
Designing Miscellaneous Mounts & Acrylic Pieces
The rest of the hardware that we need to design is just mounts or acrylic pieces for the housings that we just made. Most of these are just mounts with snap-on clips in the back to allow them to be attached to the IV stand easily. As mentioned before, when printing these snap-on clips its important to make sure the layer lines run perpendicular to the IV stand to ensure that we eliminate any weaknesses from layer lines.
additionally, if you don't want to use acrylic, all of these parts can just be 3D printed instead. That being said, using acrylic in some places allows us to add some decorative bits like text and images by using a laser engraver.
All Acrylic pieces were cut using an epilog fusion laser cutter/engraver, but you can usually just find an online service for custom acrylic pieces.
Soldering Hardware and Designing Schematic
Now we finally get into the electronics, since most of our electronics come in the form of modules or already have some form of connector attached to them, all we need to do is create a PCB to attach all the wires to the arduino nano.
In the picture above, you can see the schematic used for this project as well as their flags on which pin they connect to. There's also a picture of the PCB laid out in EasyEDA, but if you wish to use a breadboard you can do so, as using a PCB is just to save space and organize wiring.
After this we can start soldering our wires and connectors, as well as headers to connect our Arduino Nano to the board.
Assembly & Coding
This part should be the easiest. With everything wired up, all we need to do is place everything where it needs to be and upload our code to the Arduino Nano. It is recommended to first attach your connectors to the main housing before running wires out to the sensors.
The XKC sensor only needs to attach to the IV bag / bottle by using some velcro. You should tighten the velcro to ensure that the sensor does not come loose otherwise it might trigger a false "IV empty" reading.
Next, we can start coding and upload the code to the microcontroller. Now before we start, we need to know the basics of how this system works, and we will break down how each section works before implementing everything to a main program.
Optocoupler Drip Rate Measurement
This part discusses how we can actually measure the drip rate of our IV infusion. We can use the IR optocoupler to count how many drops per minute comes out of the IV bag, and the way to do so is simple. All we need to do is count the time between 2 drops of IV fluid, and from this interval we can estimate how many drops we can get in 1 minute, since IV infusion droplets are usually consistent unless there is some form of external pressure acting on the fluid. We can obtain the time between 2 drops of fluid by using the Micros() function in Arduino to capture a timestamp of the first drop before then taking the timestamp of the next drop, then simply subtracting the two to find the interval. Then, we can use this data to print out a DPM (Drops Per Minute) reading in the serial monitor or use it for something else.
Empty IV detection using the XKC-Y25
To detect if the IV fluid has gone dry, we can use the XKC's capacitive fluid sensing to check if the fluid level has dropped below the set amount of volume that we can choose by adjusting the sensor's height relative to the IV bottle / bag. This is why it is important to make sure the XKC sensor is secured tightly with velcro, otherwise it might trigger a false signal. This sensor has two modes, depending on what signal the sensor will send if it detects fluid. In the first mode it will send a HIGH signal if fluid is detected, and the second mode is the opposite where it pulls the output line LOW if it detects a fluid. You can use whichever mode you want.
The capacitive fluid sensing simply works by the difference in dielectric constants between air and fluids. The change in dielectric constant changes capacitance, which also changes voltage. This change can be picked up and interpreted as a fluid level change.
Dosage / Drip Rate Adjustment Rate (optional)
This part onwards is completely optional, if you only want to monitor IV infusions then using the optocoupler and XKC sensor is adequate.
The drip rate is adjusted using a PI controller that can automatically adjust for minor deviations or errors in the DPM reading. To put it simply, a PI controller controls damping and corrects errors, and it is capable of correcting small errors over time. To learn more about it, you can visit this link
Next, we need to actually select the drip rate of our IV infusion, so this is where the rotary switch comes in. It works by setting six pins to HIGH, and whichever pin is currently selected by the rotary switch completes the circuit back to GND. This makes the reading in the selected pin LOW, since there is no potential difference between GND and the selected pin. Using different pins, we can map them to different drip rates.
(Note: If you don't want to use a rotary switch, using an array of regular switches is fine too, but using a rotary switch makes it easier to select drip rates since only one pin is selected at any given moment.)
Full Code
Compiling everything into a single code gives us this:
this code is also available in the main.cpp file listed below.
Uploading to Arduino Nano
Now, with the code written, all we need to do is uploaded to the Microcontroller by using any IDE software. You can use Arduino IDE, but here we used PlatformIO.
And with that, we're basically done. All that's left to do is to attach the IV bag to the spike and start monitoring.
Downloads
Future Improvements and Suggestions
This part is just a few recommendations and some things that I think can be improved. First off, I think using some sort of dosing pump or a peristaltic pump would be a much better and medically viable application for adjusting dosages, since that's what professional infusion pumps use as dosing pumps are much less likely to kink, bend, or deform IV tubing lines. In addition to that, migrating to an ESP32 or the ESP family of microcontrollers would be a good step forward to integrating this device in an IoT environment.
In addition to all this, some minor quality of life improvements can be made, like making a self-adjusting strap for the XKC adaptor, as well as adjusting optocoupler resistor values to make it more or less sensitive to changes in the beam path, or even including multiple optocouplers to improve sensor accuracy.