Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based IV Drip Monitoring System with GPS and Load Cell

View and Edit Project In Cirkit DesignerImage of ESP32-Based IV Drip Monitoring System with GPS and Load Cell

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

  1. Load Cell - Red/white/black/green

    • Description: Measures the weight of the IV fluid.
    • Pins: E+, A-, E-, A+
  2. 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
  3. Tower Pro SG90 Servo

    • Description: Controls the flow of the IV fluid.
    • Pins: Signal, +5V, GND
  4. GPS NEO 6M

    • Description: Provides GPS location data.
    • Pins: VCC, RX, TX, GND
  5. 16x2 I2C LCD

    • Description: Displays information such as weight and GPS location.
    • Pins: GND, VCC, SDA, SCL
  6. 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

HX711 - Bridge Sensor Interface

Tower Pro SG90 Servo

GPS NEO 6M

16x2 I2C LCD

ESP32 (30 pin)

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