ESP32-Based IV Drip Monitoring System with GPS and Load Cell
View and Edit Project In Cirkit Designer
IV Drip Monitoring System Documentation
Summary
The IV Drip Monitoring System is designed to monitor the weight of IV fluid, control the flow using a servo motor, provide location data via a GPS module, and display information on an I2C LCD. The system alerts when the fluid level is low and displays the GPS location.
Component List
Load Cell - Red/white/black/green
- Description: Measures the weight of the IV fluid.
- Pins: E+, A-, E-, A+
HX711 - Bridge Sensor Interface
- Description: Interface for the load cell to measure weight.
- Pins: E+, E-, A-, A+, B-, B+, GND - GROUND, DATA (OUT), SCK - CLOCK (IN), 3.3/3.5V Supply
Tower Pro SG90 Servo
- Description: Controls the flow of the IV fluid.
- Pins: Signal, +5V, GND
GPS NEO 6M
- Description: Provides GPS location data.
- Pins: VCC, RX, TX, GND
16x2 I2C LCD
- Description: Displays information such as weight and GPS location.
- Pins: GND, VCC, SDA, SCL
ESP32 (30 pin)
- Description: Main microcontroller that interfaces with all components.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
Wiring Details
Load Cell - Red/white/black/green
- E+ connected to E+ of HX711
- A- connected to A- of HX711
- E- connected to E- of HX711
- A+ connected to A+ of HX711
HX711 - Bridge Sensor Interface
- E+ connected to E+ of Load Cell
- A- connected to A- of Load Cell
- E- connected to E- of Load Cell
- A+ connected to A+ of Load Cell
- GND - GROUND connected to GND of ESP32 and Tower Pro SG90 Servo
- DATA (OUT) connected to D5 of ESP32
- SCK - CLOCK (IN) connected to D4 of ESP32
- 3.3/3.5V Supply connected to 3V3 of ESP32
Tower Pro SG90 Servo
- Signal connected to D15 of ESP32
- +5V connected to Vin of ESP32
- GND connected to GND of ESP32 and HX711
GPS NEO 6M
- VCC connected to 3V3 of ESP32
- RX connected to D12 of ESP32
- TX connected to D13 of ESP32
- GND connected to GND of ESP32 and 16x2 I2C LCD
16x2 I2C LCD
- GND connected to GND of ESP32 and GPS NEO 6M
- VCC connected to Vin of ESP32
- SDA connected to D21 of ESP32
- SCL connected to D22 of ESP32
ESP32 (30 pin)
- D12 connected to RX of GPS NEO 6M
- D13 connected to TX of GPS NEO 6M
- GND connected to GND of 16x2 I2C LCD, GPS NEO 6M, Tower Pro SG90 Servo, and HX711
- Vin connected to +5V of Tower Pro SG90 Servo and VCC of 16x2 I2C LCD
- D22 connected to SCL of 16x2 I2C LCD
- D21 connected to SDA of 16x2 I2C LCD
- D5 connected to DATA (OUT) of HX711
- D4 connected to SCK - CLOCK (IN) of HX711
- D15 connected to Signal of Tower Pro SG90 Servo
- 3V3 connected to 3.3/3.5V Supply of HX711 and VCC of GPS NEO 6M
Documented Code
ESP32 (30 pin) Code
/*
* IV Drip Monitoring System
* This code interfaces with a load cell to measure the weight of the IV fluid,
* a servo motor to control the flow, a GPS module to provide location data,
* and an I2C LCD to display information. The system alerts when the fluid
* level is low and displays the GPS location.
*/
#include <HX711.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <TinyGPS++.h>
// Initialize components
HX711 scale;
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo servo;
TinyGPSPlus gps;
// Define constants and pin mappings
const int LOADCELL_DOUT_PIN = 5;
const int LOADCELL_SCK_PIN = 4;
const int SERVO_PIN = 15;
const int GPS_RX_PIN = 13; // ESP32 RX pin for GPS TX
const int GPS_TX_PIN = 12; // ESP32 TX pin for GPS RX
HardwareSerial GPS(1); // Use UART1 for GPS communication
float weight = 0;
void setup() {
// Serial and component setup
Serial.begin(115200);
lcd.begin();
lcd.backlight();
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
servo.attach(SERVO_PIN);
GPS.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
lcd.setCursor(0, 0);
lcd.print("System Ready!");
delay(2000);
lcd.clear();
}
void loop() {
// Read weight from load cell
weight = scale.get_units();
lcd.setCursor(0, 0);
lcd.print("Weight: ");
lcd.print(weight);
lcd.print("g "); // Display weight with unit
if (weight < 50) { // Threshold for low fluid level
lcd.setCursor(0, 1);
lcd.print("Low Fluid! ");
servo.write(0); // Stop clamp
displayGPSLocation(); // Show GPS location
} else {
lcd.setCursor(0, 1);
lcd.print("Flow Normal ");
servo.write(90); // Allow fluid flow
}
delay(1000);
}
void displayGPSLocation() {
while (GPS.available() > 0) {
gps.encode(GPS.read()); // Parse GPS data
if (gps.location.isUpdated()) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Lat: ");
lcd.print(gps.location.lat(), 6); // Display latitude
lcd.setCursor(0, 1);
lcd.print("Lng: ");
lcd.print(gps.location.lng(), 6); // Display longitude
delay(5000); // Pause for readability
lcd.clear();
}
}
}
GPS NEO 6M Code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
16x2 I2C LCD Code
/*
* IV Drip Monitoring System
* This code interfaces with a load cell to measure the weight of the IV fluid,
* a servo motor to control the flow, a GPS module to provide location data,
* and an I2C LCD to display information. The system alerts when the fluid
* level is low and displays the GPS location.
*/
#include <HX711.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <TinyGPS++.h>
// Initialize components
HX711 scale;
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo servo;
TinyGPSPlus gps;
// Define constants and pin mappings
const int LOADCELL_DOUT_PIN = 5;
const int LOADCELL_SCK_PIN = 4;
const int SERVO_PIN = 15;
const int GPS_RX_PIN = 13; // ESP32 RX pin for GPS TX
const int GPS_TX_PIN = 12; // ESP32 TX pin for GPS RX
HardwareSerial GPS(1); // Use UART1 for GPS communication
float weight = 0;
void setup() {
// Serial and component setup