Medicine Dispensing System Using ESP32, GSM Module, MP3 Player, and Servo Motors
- Introduction
The aim of this project is to create a smart, automated medicine dispensing system using an ESP32 microcontroller, SIM800L GSM module, MP3 player, servo motors, a 20×4 LCD display, and a keypad. This system allows the user to select and dispense medicines from a set of medicine strips based on available stock. Additionally, the system has built-in security features, such as sending SMS alerts to the owner in case of low stock, as well as detecting unauthorized attempts to change the owner’s mobile number.
- System Components
- ESP32 Microcontroller: This microcontroller controls all the operations of the system, from managing the keypad input to controlling the GSM module, servos, and LCD display.
- SIM800L GSM Module: This module enables the system to send and receive SMS messages. It is used to notify the owner about low stock levels or changes in the mobile number.
- MP3 Player: The MP3 player plays audio alerts to notify the user about system statuses like low stock or successful dispensing.
- Servo Motors: Four servo motors are used to control the dispensing mechanism for different medicine strips.
- 20×4 LCD Module: The LCD displays real-time information, such as available medicine quantities, user selections, and system messages.
- Keypad: The keypad allows the user to input commands, select a specific medicine strip, and interact with the system.
- Power Supply: A reliable power supply is required to ensure stable operation of all components.
- System Features
- Medicine Selection and Dispensing:
- The user can select a medicine strip from the keypad interface.
- Upon selection, the system dispenses the selected strip using the servo motors that are mapped to each medicine strip.
- Stock Monitoring:
- The system keeps track of the quantity of each medicine strip.
- If the quantity of any selected strip drops to zero, the system automatically sends an SMS alert to the owner’s mobile number, notifying them of the stock depletion.
- Mobile Number Protection:
- The system is programmed to monitor any attempt to change the mobile number linked to the device.
- If an unauthorized user tries to change the mobile number, the system will send an SMS to the old owner’s phone number containing the new mobile number of the unauthorized user. This feature is designed to alert the previous owner if the device is stolen and reprogrammed.
- Owner Control:
- The owner can set and adjust the initial medicine quantities using a predefined interface.
- This flexibility allows the owner to maintain the system and ensure it functions properly for dispensing the right amount of medicine.
- System Operation
- Keypad Input:
- The user interacts with the system by pressing keys on the keypad to select a specific medicine strip.
- The system updates the LCD display with the name and quantity of the selected medicine.
- Dispensing Mechanism:
- Once the user selects a medicine strip, the corresponding servo motor is activated to release the strip.
- If the quantity of the selected medicine reaches zero, the system sends an SMS alert to the owner.
- Low Stock SMS Notification:
- The system continuously monitors the medicine quantities.
- If any medicine quantity drops to zero, the GSM module sends a predefined SMS to the owner, informing them about the stock depletion.
- Security Feature – Mobile Number Change Detection:
- If the GSM module detects an attempt to change the mobile number of the device, it sends an SMS to the old owner’s phone number.
- The SMS contains the new mobile number of the person who has tampered with the device, providing valuable information in case of theft.
- Flowchart
The flowchart for this system is as follows:
- Start:
- System initialization (ESP32, GSM, LCD, Keypad, Servo Motors)
- Keypad Input:
- User selects a medicine strip.
- The system displays the selection and quantity on the LCD.
- Dispensing:
- The corresponding servo motor is activated to dispense the selected medicine.
- Stock Monitoring:
- If the quantity of any strip reaches zero, an SMS is sent to the owner.
- Security Monitoring:
- If a change in the owner’s mobile number is detected, an SMS is sent to the previous owner’s number.
- End:
- The system returns to the initial state and waits for further input.
- Code Implementation
The code implementation involves setting up the GPIO pins for the keypad, servo motors, and LCD. It also includes configuration for the GSM module to handle SMS functionalities. The program includes logic to monitor medicine quantities and sends SMS notifications when necessary.
- Challenges and Solutions
- SMS Communication: Ensuring proper communication with the SIM800L GSM module was a challenge due to network connectivity issues. This was addressed by using error handling in the code and ensuring good signal strength.
- Servo Control: Controlling four servos simultaneously to dispense different strips required precise timing and coordination, which was achieved using non-blocking delays and careful programming.
- Security: Detecting unauthorized mobile number changes and sending notifications to the old owner was a critical feature, which was implemented by storing the old mobile number in the system’s memory.
- Conclusion
The Medicine Dispensing System using ESP32, GSM module, MP3 player, and servo motors is an efficient and secure solution for automating the dispensing of medicines. The integration of security features such as SMS alerts for low stock levels and mobile number change detection enhances the safety of the system. The owner can easily manage medicine quantities and receive timely updates via SMS, ensuring smooth operation and reducing the chances of misuse or theft.
This system provides a practical approach to managing medication dispensing, with added layers of security and user control. It can be used in medical environments or home care settings to automate the distribution of medicine in a safe and efficient manner.
- Future Enhancements
- Web/Cloud Integration: A web or mobile app interface can be integrated to monitor and control the system remotely.
- Voice Recognition: Voice commands could be used to select medicines, adding an additional layer of convenience for users.
- Inventory Management: The system could be expanded to track expiration dates and other details about each medicine, improving inventory management.
This project represents an innovative solution to automate medicine dispensing while ensuring secure communication and easy user interaction.


Reviews
There are no reviews yet.