Inspiration

Counterfeit pharmaceuticals pose a serious health and safety risk, while conventional verification methods often depend on expensive, fixed laboratory equipment such as High-Performance Liquid Chromatography (HPLC). These systems are not designed for rapid, portable verification at the point of care.

VeriScan was developed to explore a different approach: a portable, low-cost, non-destructive instrument that can analyze the optical reflectance fingerprint of a pharmaceutical sample and provide an authenticity classification within seconds. The goal was to bring a combination of multispectral sensing, embedded systems, wireless connectivity, and machine learning into a compact field-deployable platform.

How I Built It

VeriScan combines controlled physical optics, embedded sensing, wireless communication, backend processing, and machine learning into one end-to-end system.

The V2 hardware uses a custom 5 mm matte-black PVC sunboard enclosure designed around a controlled 45°/0° optical geometry. Angled LED mounting structures establish the illumination geometry, while internal baffling reduces direct LED-to-sensor light paths and unwanted reflections. A fixed sample tray is used to improve the repeatability of pharmaceutical sample placement.

An Adafruit AS7343 18-channel multispectral optical sensor captures the sample's spectral response, while an ESP32 DevKit V1 controls the optical acquisition and transmits the measurement through Bluetooth Low Energy (BLE).

A Flutter/Dart Android application acts as the wireless gateway. It receives and parses the BLE spectral payload and sends the structured measurement to a Python FastAPI backend through the /api/v1/predict endpoint. The backend sanitizes the configured saturated channels, retains the resulting 15-channel feature vector, applies L2 normalization, and performs inference using a trained Scikit-Learn Random Forest classifier.

This creates a complete pipeline from physical pharmaceutical sample → optical measurement → BLE → mobile gateway → API preprocessing → machine-learning classification.

Challenges I Ran Into

One of the biggest challenges was discovering that strong machine-learning accuracy in a controlled prototype environment did not necessarily represent reliable physical measurement.

The initial cardboard-based prototype suffered from ambient-light leakage, internal reflections, uncontrolled optical geometry, and small variations in sample placement. These effects introduced sensor drift and caused the model to learn environmental characteristics rather than only the pharmaceutical spectral signature.

We addressed this by redesigning the physical measurement environment instead of attempting to solve the entire problem through software. The V2 prototype uses a matte-black sunboard optical chamber, controlled LED geometry, a sensor baffle, and a fixed sample tray. We also introduced a startup reference scan of the empty black chamber and planned a more diverse dataset containing thermal, positional, and baseline variation.

This experience demonstrated that reliable machine learning on physical hardware depends heavily on controlling and understanding the measurement system itself.

Accomplishments That I'm Proud Of

We progressed VeriScan from an early hackathon prototype toward a structured TRL-4 laboratory prototype architecture, with the hardware, optical environment, software pipeline, and machine-learning workflow documented as interconnected engineering components.

The system now has a defined end-to-end architecture:

Controlled optical chamber → AS7343 multispectral sensing → ESP32 edge acquisition → BLE gateway → Flutter Android application → FastAPI preprocessing → Random Forest inference.

We also identified and addressed the major physical causes of the original prototype's overfitting, including ambient light, reflective surfaces, uncontrolled illumination geometry, and sample-placement variation.

The resulting architecture is designed to produce a reproducible, non-destructive pharmaceutical classification workflow with a target end-to-end response time of under five seconds.

What I Learned

VeriScan taught us that building an AI system for physical-world sensing is fundamentally different from working with a purely software-based dataset.

We gained practical experience in optical measurement, sensor integration, embedded firmware, BLE communication, mechanical enclosure design, data preprocessing, and machine learning.

The most important lesson was the relationship between hardware and data quality. Sensor drift, thermal variation, illumination changes, ambient light, and millimetre-scale sample movement can become machine-learning problems if they are not controlled or represented in the dataset.

We therefore learned to treat the physical measurement environment, calibration procedure, dataset design, and ML model as one integrated system rather than as independent components.

What's Next for VeriScan

The next stage is to expand laboratory data collection using the V2 optical chamber and build a substantially more representative dataset across authentic, counterfeit, and Null/Unknown classes.

We plan to characterize repeatability, controlled sample-placement variation, thermal effects, baseline stability, and optical-channel saturation before finalizing the expanded model. The ML pipeline will be evaluated using 5-fold cross-validation and an independent held-out test set to assess generalization beyond the development dataset.

Beyond the current backend-based Random Forest inference architecture, a future direction is to investigate offline TinyML inference on the ESP32, subject to the computational and memory constraints of the selected hardware.

Longer term, the project aims to expand field testing, refine the hardware and software architecture, and progress toward pilot-scale deployment and further TRL development.

Share this project:

Updates

Submission history