Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ PRISM Public

PRISM (pH & Rehydration Intensity Sensor Module) is an innovative health monitoring system that analyzes color and pH levels of urine to provide real-time health insights. The system uses the TCS34725 color sensor and pH sensors connected to Arduino, with a Node.js backend for data processing and a Next.js frontend for visualization.

Notifications You must be signed in to change notification settings

Cybiii/PRISM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PRISM - pH & Rehydration Intensity Sensor Module

Overview

PRISM (pH & Rehydration Intensity Sensor Module) is an innovative health monitoring system that analyzes color and pH levels of urine to provide real-time health insights. The system uses the TCS34725 color sensor and pH sensors connected to Arduino, with a Node.js backend for data processing and a Next.js frontend for visualization.

PRISM.mp4

Contributors:

Key Health Indicators

  • pH Levels: Monitor acidity/alkalinity (normal range: 4.5-8.5)
  • Color Analysis: 10-point health scale (1=excellent, 10=critical)
  • Hydration Status: Real-time dehydration detection
  • Health Alerts: Automatic notifications for concerning readings

Features

Core Functionality

  • Real-time Monitoring: Continuous sensor data collection
  • Machine Learning: K-means clustering for color classification
  • pH Averaging: 10-second rolling buffer for stable readings
  • Health Scoring: 1-10 scale based on color analysis
  • Alert System: Automatic health concern notifications

Web Platform

  • Live Dashboard: Real-time data visualization
  • Historical Analysis: Trend tracking and analytics
  • WebSocket Updates: Instant data streaming
  • Responsive Design: Mobile and desktop compatible
  • Health Recommendations: Personalized advice based on readings

Technical Features

  • TCS34725 Integration: 16-bit color sensor support
  • Serial Communication: Arduino to backend data flow
  • SQLite Database: Persistent data storage
  • REST API: Comprehensive data access endpoints
  • TypeScript: Type-safe development
  • Docker Ready: Containerized deployment

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚    Hardware     β”‚    β”‚    Backend      β”‚    β”‚    Frontend     β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚  Arduino Uno    β”‚    β”‚  Node.js API    β”‚    β”‚   Next.js Web   β”‚
β”‚  TCS34725       │───▢│  TypeScript     │───▢│   React App     β”‚
β”‚  pH Sensor      β”‚    β”‚  SQLite DB      β”‚    β”‚   Tailwind CSS  β”‚
β”‚                 β”‚    β”‚  WebSocket      β”‚    β”‚   Real-time UI  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       ↓                       ↓                       ↓
   Serial USB              Port 3001               Port 3000

Data Flow

  1. Arduino reads TCS34725 color sensor and pH sensor
  2. Serial Communication sends data to backend via USB
  3. Backend Processing averages pH, classifies color, stores data
  4. Machine Learning analyzes color using K-means clustering
  5. WebSocket Streaming pushes real-time updates to frontend
  6. Dashboard Display shows live health metrics and trends

Quick Start

Prerequisites

  • Node.js 18+ and npm/pnpm
  • Arduino IDE for hardware programming
  • TCS34725 Color Sensor and pH sensor (optional for development)

1. Clone Repository

git clone https://github.com/your-username/PUMA.git
cd PUMA

2. πŸš€ Development Mode (Recommended)

# Install all dependencies
npm run install-all

# Start both backend and frontend simultaneously
npm run dev

This starts both servers with auto-recompilation:

3. Manual Setup (Alternative)

Backend Setup:

cd backend
npm install
npm run build
npm run dev    # Development with mock data

Frontend Setup:

cd ../frontend
npm install
npm run dev  # Development server

4. Hardware Setup (Optional)

See TCS34725 Setup Guide for complete hardware integration.

Project Structure

PUMA/
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ .gitignore                   # Git ignore rules
β”œβ”€β”€ backend/                     # Node.js/TypeScript Backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ SerialService.ts       # Arduino communication
β”‚   β”‚   β”‚   β”œβ”€β”€ ColorClassificationService.ts  # ML color analysis
β”‚   β”‚   β”‚   β”œβ”€β”€ DataProcessingService.ts       # pH averaging & alerts
β”‚   β”‚   β”‚   └── DatabaseService.ts             # SQLite operations
β”‚   β”‚   β”œβ”€β”€ routes/              # REST API endpoints
β”‚   β”‚   β”œβ”€β”€ config/              # TCS34725 configuration
β”‚   β”‚   β”œβ”€β”€ types/               # TypeScript definitions
β”‚   β”‚   └── utils/               # Logging and utilities
β”‚   β”œβ”€β”€ README.md                # Backend documentation
β”‚   β”œβ”€β”€ TCS34725_SETUP.md        # Hardware setup guide
β”‚   └── package.json
β”œβ”€β”€ frontend/                    # Next.js React Frontend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ dashboard/           # Health monitoring dashboard
β”‚   β”‚   β”œβ”€β”€ ui/                  # Reusable components
β”‚   β”‚   └── layout.tsx
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   └── package.json
└── hardware/                    # Arduino code (future)
    └── arduino_sensors/

Hardware Requirements

Required Components

Component Purpose Specification
Arduino Uno/Nano Microcontroller USB connection required
TCS34725 RGB Sensor Color measurement I2C, 3.3V power
pH Sensor Acidity measurement Analog output
Jumper Wires Connections Male-to-male
USB Cable Data transmission Arduino to computer

Wiring Diagram

TCS34725    Arduino    pH Sensor
--------    -------    ---------
VCC   β†’     3.3V       VCC β†’ 5V
GND   β†’     GND        GND β†’ GND
SDA   β†’     A4         OUT β†’ A0
SCL   β†’     A5

Important: TCS34725 requires 3.3V power, NOT 5V!

Installation

Development Setup

  1. Install Dependencies

    # Backend
    cd backend && npm install
    
    # Frontend
    cd ../frontend && npm install
  2. Environment Configuration

    # Backend environment
    cp backend/.env.example backend/.env
  3. Database Initialization

    cd backend
    npm run build
    # Database auto-initializes on first run

Production Deployment

  1. Build Applications

    # Backend
    cd backend && npm run build
    
    # Frontend
    cd ../frontend && npm run build
  2. Start Services

    # Backend (production)
    cd backend && npm start
    
    # Frontend (production)
    cd ../frontend && npm start

Usage

Development Mode (Mock Data)

Perfect for testing without hardware:

# Terminal 1: Backend with mock TCS34725 data
cd backend
npm run dev

# Terminal 2: Frontend development server
cd frontend
npm run dev

Visit http://localhost:3000 to see the dashboard with simulated health data.

Production Mode (Real Hardware)

With Arduino connected:

# Configure Arduino COM port
# Edit backend/.env:
ARDUINO_PORT=COM3                # Windows
# ARDUINO_PORT=/dev/ttyUSB0      # Linux
ARDUINO_AUTO_DETECT=true

# Start backend
cd backend && npm start

# Start frontend
cd frontend && npm start

Using the Dashboard

  1. Real-time Monitoring: View live pH and color readings
  2. Health Trends: Analyze historical data patterns
  3. Alert System: Receive notifications for health concerns
  4. Recommendations: Get personalized hydration advice

API Documentation

Health & Status

GET /health                    # System health check
GET /api/status               # Detailed system status

Data Retrieval

GET /api/readings/latest      # Most recent reading
GET /api/readings             # Paginated readings (?limit=100&offset=0)
GET /api/readings/range       # Date range query (?start=2024-01-01&end=2024-01-02)

Analytics

GET /api/analytics            # Weekly analytics (?days=7)
GET /api/ph/buffer           # Current pH buffer statistics
GET /api/clusters            # Color classification clusters

Health Recommendations

GET /api/recommendations/:score    # Health advice for score (1-10)

Testing & Administration

POST /api/simulate            # Simulate reading (development)
POST /api/clusters/retrain    # Retrain ML clusters

WebSocket Events

Client β†’ Server:

  • requestLatestData - Request latest reading

Server β†’ Client:

  • newReading - New processed reading with recommendations

  • healthAlert - Health concern notifications

  • clustersUpdated - Updated ML clusters

  • Normal Range: 4.5-8.5

  • Acidic: < 4.5 (may indicate UTI, ketosis)

  • Alkaline: > 8.5 (may indicate infection)

About

PRISM (pH & Rehydration Intensity Sensor Module) is an innovative health monitoring system that analyzes color and pH levels of urine to provide real-time health insights. The system uses the TCS34725 color sensor and pH sensors connected to Arduino, with a Node.js backend for data processing and a Next.js frontend for visualization.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •