SensoPack v2.0 is an AI-powered smart packaging system for fresh perishable food (such as L. vannamei shrimp). It combines a biodegradable bioactive film, a colorimetric pH indicator (Anthocyanin), and live sensor data (Ammonia, Temperature, Humidity) to predict food freshness in real time.
This project is structured for a distributed cloud architecture where a mobile phone acts as the scanner, the laptop acts as a sensor bridge, and a Vercel serverless backend runs the ML model.
- Mobile Frontend (Vercel): A static HTML/JS web app accessed via a mobile phone. It uses the phone camera to scan a QR code for metadata (batch ID, packaging time) and the color of the bioactive film (for pH).
- Laptop Bridge: A Python script (
arduino_bridge.py) running on the computer connected to the Arduino via USB (COM12). It continuously reads sensor data (AHT20 Temp/Humidity and MQ-137 Ammonia) and pushes it to Firebase Realtime Database. - Cloud Backend (Vercel Serverless API): A Python FastAPI application running on Vercel. When the mobile app requests a prediction, the backend fetches the latest sensor data from Firebase, runs it through a Random Forest Classifier (
shrimp_spoilage_model.joblib), and returns the freshness score.
SensoPack_ML/
├── api/
│ ├── index.py # Vercel Serverless Backend (FastAPI)
│ └── requirements.txt # Python dependencies for Vercel
├── webapp/ # Static Frontend Files (HTML, JS, CSS)
│ ├── index.html
│ ├── app.js
│ ├── style.css
│ └── qr-generator.html
├── arduino_bridge.py # Laptop script to bridge Arduino to Firebase
├── shrimp_spoilage_model.joblib # Pre-trained Random Forest ML Model
├── PJSketch/ # Production Arduino Sketch (MQ-137 + AHT20)
├── PJSketch_Simulator/ # Simulator Arduino Sketch (No sensors needed)
└── Sensor_Test/ # Hardware testing Arduino Sketch
- Create a Firebase project at console.firebase.google.com.
- Enable the Realtime Database and start it in "Test Mode".
- Note your Database URL (e.g.,
https://your-project.firebaseio.com/). - Go to Project Settings -> Service Accounts, and click Generate New Private Key. Save the JSON file as
serviceAccountKey.jsonin the root of this project (do not commit it to Git!).
- Initialize a Git repository, commit your code, and push to GitHub.
- Go to Vercel and import your GitHub repository.
- In Vercel's Environment Variables, add:
FIREBASE_URL: Your Realtime Database URL.FIREBASE_CREDENTIALS: The raw JSON string of yourserviceAccountKey.json.
- Deploy! Vercel will automatically serve
/webappas static files and/api/index.pyas the Python backend.
- Ensure your Arduino is connected to
COM12and flashed withPJSketch.ino. - Install dependencies:
pip install pyserial firebase-admin - Make sure
serviceAccountKey.jsonis in the folder. - Run:
python arduino_bridge.py
- Start
arduino_bridge.pyon your laptop. - Generate and print a QR code using
/webapp/qr-generator.html. - Open the Vercel app URL on your mobile phone.
- Tap Scan Package, align the QR code and biofilm within the frame.
- The phone grabs the visual data, queries the Vercel backend, which grabs the live sensor data from Firebase, and displays the prediction on your phone!