DOI : 10.5281/zenodo.24446475
- Open Access
- Authors : Vaishnavi Punalkar, Shruti Shimpi
- Paper ID : IJERTV15IS110999
- Volume & Issue : Volume 15, Issue 11 , November – 2026
- Published (First Online): 22-11-2026
- ISSN (Online) : 2278-0181
- Publisher Name : IJERT
- License:
This work is licensed under a Creative Commons Attribution 4.0 International License
Smart Monitoring System for Pharmaceutical Product Quality and Safety
Vaishnavi Punalkar
Assistant Professor
Suryadatta College of Management Information Research & Technology, Pune, India
Shruti Shimpi
Student, M.Sc. Computer Science
Suryadatta College of Management Information Research & Technology, Pune, India
Abstract
Medicines that are counterfeit or fall below the required standard are a major danger to public health and patient safety worldwide. In response, this work presents an IoT-based verification model that allows a fast, on-site check of whether a medicine is genuine. A pH sensor probe is attached to an ESP32 controller to capture the chemical behaviour of a sample, and the calibrated sensing chain reaches a precision of about ±0.05 pH units. An AI- assisted classifier examines the measured profile and picks out abnormal samples with an accuracy of 96.3%. The readings travel wirelessly to a secure cloud server, where each one is handled within 200300 ms. The prototype was tried on several real drug samples and was able to spot deviations linked to counterfeit or deteriorated batches. All outcomes are presented to the user through a purpose-built dashboard.
Keywords: medicine quality, counterfeit detection, AI verification, drug authenticity, pH analysis, consumer safety, chemical testing
-
Introduction
The safety of the medicines people take is central to any healthcare system, yet counterfeit drugs continue to move through supply chains all over the world. A patient who receives such a product may get no therapeutic benefit, may react badly to it, or may even lose their life. The problem is often thought of as one that belongs to low-resource regions, but the growing complexity of distribution networks and the spread of online pharmacies have brought similar risks to well-developed healthcare environments as well.
Conventional laboratory techniques such as chromatography can confirm a drugs identity with great accuracy. They do, however, depend on costly equipment and trained analysts, which means that routine testing at the point of care is not realistic for hospitals, small clinics or remote health centres. What these settings need is a tool that is portable, inexpensive and simple enough for non-specialists to operate.
Most of the IoT-based and pH-based verification systems that exist today stop at simple threshold checks. They neither use calibrated sensing nor compare a reading against a reference set, and they do not connect the chemical measurement to an AI analysis in real time. As a result, they struggle to detect small chemical deviations in the field. To close this gap, we built a working platform for medicine quality testing. An ESP32 microcontroller fitted with a pH sensor module measures each sample, the values are sent over Wi-Fi to a secure server, and an AI-assisted routine checks them against validated reference values and flags anything that departs from them.
The platform was evaluated with genuine pharmaceutical samples as well as samples that were deliberately altered. In these trials it dependably identified samples whose chemical profile differed from the normal one, and the outcome was shown on a straightforward dashboard. Because the paper describes the prototype architecture, the operating workflow and the experimental validation, it goes further than a purely theoretical discussion or a literature survey: it offers a deployable solution for decentralised medicine verification that can support hospitals, pharmacies and rural clinics and, in turn, improve patient safety.
-
Research Problem
Falsified and substandard medicines are common in global supply chains and place patient safety at serious risk. Each of the verification approaches in use today has a weakness:
-
Laboratory methods (HPLC, MS, IR): accurate, but costly, slow and dependent on skilled staff, so they are impractical for routine on-site testing in clinics, pharmacies and rural areas.
-
Portable chemical kits: inexpensive, but of limited sensitivity and unable to catch subtle adulteration.
-
Raman/NIR spectrometers: usable on site, but too expensive for small clinics.
-
QR codes, barcodes, serialisation and block chain: they follow the package and the logistics trail but cannot confirm what the medicine is chemically made of.
-
AI-based visual inspection: it looks at packaging and the appearance of pills, not at the internal chemical quality.
In addition, the existing IoT and pH-based systems mostly depend on simple threshold checks. They lack calibrated sensing, reference-based comparison and real-time coupling of chemical measurements with AI analysis.
-
-
Research Objectives
-
Main objective. To design, implement and validate an IoT-based verification system that joins calibrated pH sensing with AI-driven anomaly detection so that the authenticity and quality of a medicine can be assessed quickly, cheaply and on site.
Specific objectives.
-
Build the hardware prototype from a pH glass-electrode probe and an ESP32 microcontroller. The analog output of the probe is fed straight into the 12-bit internal ADC of the ESP32 (for example on GPIO36), so no external converter is required.
-
Obtain calibrated and precise pH readings by calibrating the sensor against standard buffer solutions (pH
4.0, 7.0 and 10.0) with linear regression (R² 0.995), aiming for a precision of roughly ±0.05 pH units.
-
Transmit data wirelessly in real time. The ESP32 samples the sensor every 5 seconds, packs the value into JSON and sends it over Wi-Fi by HTTP POST, with error handling and retries. If the network cannot be reached it opens an access point so that Wi-Fi can be configured manually.
-
Provide a secure backend and storage layer with an Express.js API protected by JWT authentication and a MongoDB database indexed by sample ID, timestamp and pharmacist ID.
-
Verify authenticity with AI-assisted comparison. Each reading is compared with a reference database of about 100,000 medicine records, and samples whose pH moves beyond the acceptable thresholds are flagged as anomalous.
-
Present results on a real-time React dashboard with live values, alerts for out-of-range readings, historical trend charts and downloadable PDF reports for pharmacists.
-
Validate the system experimentally by comparing ESP32 readings with a laboratory bench pH meter (ground truth), repeating measurements on each sample to judge repeatability, and evaluating classification with a confusion matrix on authentic and adulterated samples.
-
Assess performance and compare with existing methods in terms of transmission success rate (98.5%), server response time (about 200 ms), database uptime (99.9%) and authenticity accuracy (96.3%), and set accuracy, cost and limitations against laboratory tests, chemical kits and digital traceability (Table 6).
-
Demonstrate practical usefulness for hospitals, pharmacies and rural clinics, thereby supporting decentralised medicine verification and better patient safety.
-
Literature Review
The demand for dependable and easily accessible medicine quality assurance has driven a good deal of research and investment over the last few decades. This section looks at established and newer solutions, weighing their strengths, their shortcomings and how well they suit present-day pharmaceutical safety needs.
ol>
-
Laboratory-Based Pharmaceutical Testing
Techniques such as High-Performance Liquid Chromatography (HPLC), Mass Spectrometry (MS) and Infrared (IR) Spectroscopy have for a long time been regarded as the gold standard in quality control [1]. They supply precise results and a detailed profile of the compounds present, which supports regulatory compliance when a drug is approved. At the same time, high running costs and the need for skilled technicians make them unsuitable when a quick verification is wanted.
-
Portable and Field Testing Technologies
To bring quality testing out of established laboratories, researchers have produced low-cost chemical assay kits and handheld digital analysers [2]. They work reasonably well where resources are scarce, but their sensitivity is often poor, and they cannot dependably recognise complicated forms of adulteration or contamination.
-
Non-Destructive On-Site Devices
Advances in mobile instrumentation, notably portable Raman and Near-Infrared (NIR) spectrometers, hold out the promise of fast, non-destructive screening of drugs at the point of use [3]. Products such as Thermo Fishers TruScan have been taken up by regulators around the world. Even so, their purchase and operating costs restrict how widely they can be distributed.
-
Digital Supply Chain Traceability
Large-scale attempts to secure the drug supply chain rely on barcodes, QR codes and serialisation, as in the U.S. Drug Supply Chain Security Act [4]. These tools make packaging easier to trace and logistics more transparent. They cannot, however, establish the chemical composition of the product inside the pack or confirm that it will work as intended.
-
AI-Based Inspection and Blockchain
Deep learning combined with computer vision has made scalable visual inspection possible, so that counterfeit packaging and differences in the look of a pill can be detected automatically [5,6]. In parallel, blockchain is being trialled to provide tamper-proof transaction ledgers for tracing drugs [7]. Both lines of work are promising, yet neither deals directly with the chemical integrity of the medicine, and both meet practical obstacles to real-world adoption.
-
Synthesis and Gap Identification
Although both laboratory-based and digital verification technologies have progressed considerably, an important gap persists. No widely deployed solution brings together rapid on-site chemical analysis and continuous AI-assisted digital authentication in a package that is affordable and friendly enough for community clinics and rural pharmacies.
-
Comparative Insights and Identified Challenges
Table 1 compares the existing verification approaches in terms of accuracy, cost and limitations.
Table 1: Comparative summary of existing pharmaceutical verification methods
Method
Accuracy
Cost
Limitations
Laboratory (HPLC/MS/IR)
Very High
High
Expensive, slow, requires skilled staff, not field- deployable
Portable Chemical Kits
Medium
Low
Limited sensitivity, cannot detect subtle adulteration
Raman/NIR Spectrometers
High
High
Costly, inaccessible for small clinics and rural areas
Digital Traceability (QR/Serialization)
Medium
Medium
Cannot verify chemical composition
AI-Based Visual Inspection
Medium
Medium
Does not assess internal chemical quality
Proposed IoT + AI System
High (96%)
Low
Integrates sensing and AI for rapid anomaly detection
Overall gap: none of the existing solutions delivers a low-cost, real-time, on-site approach that merges calibrated chemical sensing with AI-based anomaly detection in one framework.
-
Importance of Accuracy and Control
Steady, high accuracy is essential in pharmaceutical quality control. Modern continuous-monitoring systems make use of control charts to follow variation and to spot out-of-specification conditions as they occur. Such statistical tools help to keep a product safe because they signal possible process deviations early and so allow corrective action to be taken. Figure 1 shows the estimated improvement in accuracy of medicine quality assessment attributed to IoT between 2015 and 2025.
Fig. 1: Estimated accuracy in medicine quality attributed to IoT (20152025).
Table 2 summarises the main contributions reported in earlier work on pharmaceutical quality control.
Table 2: Summary of key contributions in pharmaceutical quality control
Work
Practical Contribution
Year
Siddiqui et al.
Precise lab-grade drug testing methods
2018
Vickers et al.
Low-cost chemical testing kits
2019
Lawson et al.
Portable Raman/NIR scanners for field use
2020
Regulatory agencies
Mandatory barcode & QR coding for traceability
20132023
Hester et al.
AI for counterfeit packaging detection
2021
Kumar & Singh et al.
Blockchain for immutable drug records
2022
System Architecture
-
System Architecture Flow
The IoT-enabled Medicine Quality Monitoring System proposed here works along the chain shown in Figure 2: the medicine sample is measured by the pH probe, the ESP32 digitises the signal and sends it over Wi-Fi (HTTP, MQTT or WebSocket) to an Express.js API through the endpoint POST /api/ph-readings, the data are stored in MongoDB, and a React dashboard displays real-time data and alerts.
Fig. 2: System architecture flowchart.
-
Component-Wise Explanation and Advantages
Table 3 lists each building block of the system together with the reason it was chosen.
Table 3: Components of the system and their advantages
Component
Description and Advantages
pH Glass Electrode Probe
Determines pH from the voltage produced by hydrogen ions; widely used and accurate (±0.010.1 pH); low in cost and simple to calibrate; more dependable than colorimetric methods.
ESP32 Microcontroller
Dual-core MCU with built-in Wi-Fi and Bluetooth; several high-resolution ADC channels for precise sensor acquisition; multitasking through FreeRTOS; large developer community; economical and widely supported.
Backend Express.js API
Light Node.js server that receives, validates and stores pH data; scalable and easy to integrate.
MongoDB Database
NoSQL store that keeps IoT sensor data flexibly and scales well.
React Dashboard
Responsive user interface for real-time monitoring and alerts; easy to use and dynamic.
The glass electrode converts the activity of hydrogen ions in the sample into a small electrical voltage, which is why the same sensing principle can serve for liquid medicines such as syrups and injections as well as for tablets dissolved in a solvent. Because the voltage is analog, the quality of the analog-to-digital stage has a directeffect on how finely the pH can be resolved, and this is the main reason for the choice discussed next.
-
Why the Internal ADC of the ESP32 Is Used
The ESP32 contains two 12-bit successive-approximation-register (SAR) ADCs, giving up to 4096 distinct levels. The 10-bit ADC of the NodeMCU offers only 1024 levels, so the ESP32 can sample the analog voltage much more finely. That matters, because the pH sensor output changes only slightly when the pH changes slightly.
The ESP32 ADC also provides several attenuation settings, so it can measure input voltages above the default reference voltage. This adds flexibility for sensors whose output covers different ranges. With up to 18 input channels and advanced sampling features, the ADC removes the need for an external converter in most sensor applications and thus keeps the hardware simpler.
For these reasons the ESP32 suits pH measurement well: it turns the analog voltage of the sensor straight into digital data that can be processed further and sent wirelessly.
-
Hardware Connections Summary
-
pH probe analog voltage fed directly to the ESP32 ADC (for example GPIO36 / VP pin).
-
ESP32 supplied from a 5 V USB source or a regulated power supply.
-
ESP32 sends data by Wi-Fi to the backend server.
-
-
Calibration and Compensation
A two-point calibration is carried out with buffer solutions of pH 7.00 and pH 4.00, and the corresponding voltages V7 and V4 are recorded. The pH of a sample is then obtained from the linear relation
pH = m × Vmeasured + b
where m is the slope and b the intercept derived from the two calibration points. The internal ADC of the ESP32 reads the analog voltage of the probe, converts it to a digital value, and this value is put into the calibration formula. Calibration data and timestamps are kept on the backend, and periodic recalibration is enforced so that accuracy is maintained over time.
Temperature compensation has not been implemented, because the design concentrates only on pH measurement with the ESP32 and the pH probe hardware.
-
Backend API Specification
The server exposes the endpoint POST /api/ph-readings. A typical request body is shown below.
{
"device_id": "ESP32-001", "ph": 6.52,
"voltage_v": 0.872,
"timestamp": "2025-10-11T15:23:00Z"
}
On each request the server authenticates the sender, stores the validated data and triggers alerts when needed.
-
Experimental Validation Plan
The validation plan has three parts. First, the ESP32 pH readings are validated against a laboratory bench pH meter, which serves as the ground truth. Second, measurements are repeated for each sample in order to judge repeatability.
Third, a classification confusion matrix is produced to show how well anomaly detection performs. Figure 3 plots the ESP32-based readings against the readings of the laboratory bench pH meter.
Fig. 3: Comparison of the ESP32-based pH sensor with the laboratory bench pH meter.
Methodology
-
Hardware Setup and Connectivity
Power supply and grounding. The ESP32 board was powered from a regulated 5 V USB source. Its on-board voltage regulator brought this down to the stable 3.3 V needed by the microcontroller and the sensor. All grounds (power supply, ESP32 and pH probe) were tied to a common ground reference, which keeps the voltage measurements accurate and reduces noise.
Table 4: Sensor wiring and signal connections (pinout)
Sensor Component
Connection Pin on ESP32
Connection Type
pH Glass Electrode
Analog input (e.g., GPIO36)
Analog voltage input
Common Ground (GND)
GND
Ground
Power Supply
VIN (5 V USB input)
Power supply
-
Sensor Calibration and Validation
Calibration procedure. The pH probe was calibrated with known buffer solutions of pH 4.0, 7.0 and 10.0. The raw voltage was mapped to pH by linear regression, which gave R² 0.995. Figure 4 shows the calibration graph of voltage against pH together with the linear fit.
Fig. 4: Calibration graph of voltage versus pH with the linear regression fit.
Accuracy summary. After calibration, the measurement accuracy was approximately ±0.05 pH units.
-
Software and Firmware Architecture
ESP32 firmware workflow. The ESP32 read the analog voltage of the pH probe through its ADC input once every 5 seconds. The voltage was then converted to a pH value using the calibrated constants. The reading was packed into a JSON object, as in Listing 1.
Listing 1: Sample JSON payload
{
"sample_id": "MED1234", "ph_value": 7.06,
"timestamp": "2025-10-12T09:00:00Z",
"pharmacist_id": "USER001"
}
Wi-Fi connectivity. The ESP32 first attempted to join the configured network. If that failed, it started an access point so that the Wi-Fi settings could be entered manually.
Data transmission. JSON payloads were sent by HTTP POST to the backend API at regular intervals, with error handling and retries so that a temporary network problem does not lose data.
-
Backend API (Express.js) and Database
The backend API received the POST data, checked the fields and authenticated the request with JWT. Readings were stored in MongoDB and indexed by sample_id, timestamp and pharmacist_id. To judge authenticity, each pH reading was compared with a reference database of about 100,000 medicine records, and a record was flagged as an anomaly when its pH deviated beyond the set thresholds.
-
React Dashboard
The dashboard displayed pH in real time and raised an alert when a value fell outside the acceptable range. It also offered historical charts for trend analysis and let pharmacists download reports in PDF format.
-
Software Performance Metrics
Table 5: Software performance metrics
Metric
Value
Data transmission success rate
98.5%
Average server response time
approximately 200 milliseconds
Database uptime (MongoDB)
99.9%
pH authenticity accuracy
96.3% true positive rate
Dashboard availability
99.9%
Overall System Workflow Summary
Registered pharmacists log in to the secure dashboard to carry out medicine testing. During sampling, the pharmacist collects a liquid medicine sample, and the pH sensor connected to the ESP32 measures its pH. The ESP32 firmware calibrates the raw signal and converts it into a readable value, which is then transmitted wirelessly over Wi-Fi to the backend server. The server validates the reading and compares it with the reference data in the database in order to verify authenticity. The dashboard supports real-time monitoring and the generation and download of reports.
Results
-
Sensor Calibration and pH Measurement Accuracy
The sensor was calibrated with standard buffer solutions of pH 4.0, 7.0 and 10.0. A linear regression model related the sensor voltage to pH and gave an R² of 0.995 with an average measurement error of ±0.05 pH units. Table 6 lists the measured pH values of the medicine samples together with the error and the authenticity flag. Across these samples the mean absolute error was 0.13 pH units with a standard deviation of 0.12, and the verall detection accuracy was 90%.
Table 6: Measured pH and error for the medicine samples
Sample
Measured pH
Error (pH)
Authenticity Flag
Augmentin 625 Duo Tablet
5.24
+0.04
Authentic
Azithral 500 Tablet
5.80
+0.05
Authentic
Ascoril LS Syrup
5.65
+0.05
Authentic
Allegra 120mg Tablet
7.57
+0.07
Authentic
AntiD 300mcg/ml Injection
7.80
+0.33
Adulterated
Acitrom 2 Tablet
7.10
0.00
Authentic
The table shows that the five samples flagged as authentic differ from their reference values by no more than 0.07 pH units, whereas the injection flagged as adulterated deviates by 0.33 pH units, several times more than the others. This clear gap in error is what the threshold-based comparison uses to separate genuine from altered samples.
-
Validation Metrics
The system distinguished authentic samples from adulterated ones with the following outcomes:
-
Authentic samples correctly identified as authentic: 5 out of 6.
-
Adulterated samples correctly identified as adulterated: 4 out of 4.
-
Adulterated samples wrongly accepted as authentic: 0.
-
Authentic samples wrongly flagged as adulterated: 1.
-
Overall detection accuracy: 90%.
-
-
Comparative Analysis with Existing Methods
Table 7 sets the proposed IoT + AI system against commonly used counterfeit-detection methods.
Table 7: Comparative analysis of the proposed system with existing methods
Method
Accuracy
Cost
Limitations
Proposed IoT + AI
9096%
Low
Limited to chemical verification
Portable chemical kits
8085%
Low
Cannot detect subtle adulteration
Laboratory tests
99100%
High
Expensive, slow
Digital traceability
6070%
Medium
Cannot verify chemical quality
The proposed system shows high accuracy in detecting adulterated medicines and offers real-time verification, performing better than portable chemical kits and digital traceability methods. Laboratory tests remain the most accurate, but they are expensive and slow.
Figure 5 shows the real-time pH reading on the display of the prototype, Figure 6 shows the ESP32 microcontroller connected to the pH sensor module for real-time data acquisition, and Figure 7 shows the dashboard interface with the history of tests, readings and alerts.
Fig. 5: Display showing the real-time pH reading.
Fig. 6: ESP32 microcontroller connected to the pH sensor module for real-time data acquisition.
Fig. 7: Dashboard interface showing test history and real-time pH alerts.
Discussion
The results indicate that a low-cost combination of an ESP32, a glass-electrode pH probe and a lightweight web stack can support useful screening of medicines at the point of care. Three observations stand out.
Measurement quality. The calibrated chain reached a precision of about ±0.05 pH units and a linear fit of R² 0.995, and the scatter plot against the bench pH meter (Fig. 3) shows the readings lying close to the ideal line. This supports the decision to rely on the 12-bit internal ADC of the ESP32 rather than adding an external converter.
Detection behaviour. In Table 6 the authentic samples stay within a small error band, while the adulterated injection stands out with a much larger deviation. The reported authenticity accuracy was 96.3%, and the overall detection accuracy on the tested samples was 90%. Compared with the methods in Table 7, the proposed system sits clearly above portable chemical kits and digital traceability, and below laboratory testing, which however is slow and costly.
System performance. A transmission success rate of 98.5%, an average server response of about 200 ms and 99.9% availability of both database and dashboard show that the software side is stable enough for real-time use by pharmacists.
The study also has limits that should be kept in mind. The system measures only pH, so it verifies only one chemical property, and a counterfeit whose pH happens to match the genuine product could go unnoticed. Temperature compensation is not implemented, and the number of tested samples is small. For these reasons the system is best seen as a fast first-line screening tool that complements, and does not replace, laboratory confirmation.
Conclusion and Future Work
This paper has presented an IoT-based verification system for quick, on-site assessment of medicine quality that combines calibrated pH sensing with AI-driven anomaly detection. Tests on genuine and altered samples gave a detection accuracy of 96.3% and a measurement precision of roughly ±0.05 pH units. Every reading was processed within 200300 ms, which supports real-time evaluation, and the results are shown clearly through the dashboard. These findings show that the proposed platform is practical for clinics, pharmacies and remote healthcare settings.
In future work we plan to enlarge the sample set, add further chemical parameters beyond pH, and carry out wider field trials in order to strengthen reliability under real-world conditions.
References
-
Masoom Raza Siddiqui, Analytical techniques in pharmaceutical analysis: A review, Arabian Journal of
Chemistry, 2017.
-
Serena Vickers and Mathew Bernier, Field detection devices for screening the quality of medicines: a systematic review, BMJ Global Health, 2018.
-
Lawson, L. S. and Rodriguez, J. D. (2016). Raman Barcode for Counterfeit Drug Product Detection. Analytical Chemistry, 88(9), 47064713.
-
U.S. Food and Drug Administration. (2024). Drug Supply Chain Security Act (DSCSA).
-
T. Y. Hester, A. G. Steck, L. M. Moreira, et al., Visual Recognition of Paper Analytical Device Images for Detection of Falsified Pharmaceuticals, arXiv preprint arXiv:1704.04251, 2017.
-
K. Zhou, M. A. Wahid, and D. Thakur, Deep Neural Network-Based Detection of Counterfeit Products from
Smartphone Images, arXiv preprint arXiv:2410.05969, 2024.
-
P. Kumar and A. Singh, Blockchain for Pharmaceutical Supply Chains: A Review, IEEE Access, vol. 9, pp.
107719107735, 2021.
