How 10xrashed/kidneywashingunit works
Project Type and Purpose
• This is an embedded + web full-stack system: an ESP32-based hardware controller that monitors and controls a portable dialysis unit and a glass-morphism web dashboard for real-time visualization and remote control.
Analysis of File Structure
• Top-level source:
• dialysis-controller.cpp → the Arduino/C++ firmware for the ESP32
• dialysis-dashboard.html → the standalone HTML/CSS/JS UI
• Documentation:
• README.md → detailed overview, architecture, wiring
• manual.txt → likely quickstart or hardware notes
• PPTX & CAD files (.pptx, .3mf, .f3d) → hardware design / 3D models
• No dedicated “backend” service: the ESP32 acts as both data source and HTTP server/client.
Main Architectural Components
a. Hardware Controller (ESP32)
• Sensor Inputs: DS18B20 (temp), flow sensor (hall effect), analog pressure, analog conductivity
• Actuators/Safety: two solenoid valves, pump relay, heater relay, status LEDs, buzzer
• On-device UI: 16×2 I2C LCD, emergency-stop button
• Communication: WiFi ↔ HTTP/JSON
b. Web Dashboard
• Browser-based UI (HTML/CSS/JS) using Fetch API to poll or receive updates
• Visualization: circular progress indicators, alert notifications, start/stop controls
c. Optional Future Components (not in code but in README):
• SD-card data logger
• Cloud IoT broker (MQTT)
• User profile backend
Component Interactions and Data Flow
1. Sensors → ESP32 read & convert raw data
2. ESP32 safety logic → control relays, LEDs, buzzer, LCD
3. ESP32 packages JSON payload → sends via HTTPClient or serves via built-in web server
4. Browser UI fetches / polls JSON → updates dashboards & triggers notifications
5. UI commands (start/stop) → HTTP request → ESP32 changes state
Architectural Patterns and Principles
• Single-board microcontroller as edge device + lightweight HTTP/JSON API
• Event-driven sensor loop with interrupt for flow sensor
• Fail-safe design: threshold checks trigger immediate relay shutdown
• Separation of concerns: firmware handles real-time control; dashboard handles visualization