An-Najah National University Faculty Of Engineering And Information Technology Computer Engineering Department Smart Vending Machine Done by : Zeina Abu-dheir Mohammad Jury Supervised by : Dr. Hanal Abu-zant August 2023 Acknowledgements Foremost , we would like to express our sincere gratitude to our supervisor Dr. Hanal Abu-zant for the continuous support during our work on this project , for his motivation , immense knowledge and enthusiasm. His guidance helped us through our journey in university, especially in this project. We would also like to express our thanks to the professors and teachers in our department who were a huge and a main part that helped us reach this point in our academic life. As well as our friends and family who had faith in us and gave us endless support from the beginning of our journey. Disclaimer The following report has been authored by students Zeina Abu-dheir and Mohammad Jury from the Computer Engineering Department, Faculty of Engineering, An-Najah National University. The report has been through minimal modifications, limited to editorial corrections, and may still contain errors in language and content. It is important to mention that the opinions expressed within the report, including any conclusions and recommendations, solely belong to the students. An-Najah National University bears no responsibility or liability for any consequences arising from the utilization of this report for purposes other than its intended commission. Table Of Contents Acknowledgements 2 Disclaimer 3 Contents 4 Abstract 6 1. Introduction 7 1.1 Statement of the problem 7 1.2 Objectives 7 1.3 Scope of work 8 1.4 significance 9 2. Constraints , limitations , Standards / codes and earlier coursework 10 2.1 Constraints and limitations 10 2.2 Standards / codes 10 2.3 earlier coursework 10 3. Literature review 11 - “A simulation-optimisation genetic algorithm approach to product allocation in vending machine systems” 2020, Expert Systems with Applications : 12 - “Healthier vending machines in a university setting: Effective and financially sustainable” 12 4. Methodology 13 4.1 System architecture 13 4.2 hardware components and devices 20 4.3 How does the system work? 37 5. Results and discussion 39 6. Conclusion and Recommendations 40 6.1 conclusion : 40 6.2 Recommendations : 41 6.3 Future work : 42 7. References 43 List Of Figures Figure ‎4.1: Initial design of the cabinet 13 Figure ‎4.2: helical coil for products movement on the cell 14 Figure ‎4.3: pulleys and small plastic belts 15 Figure ‎4.4: pulleys and small plastic belts #2 16 Figure ‎4.5: wooden boxes for stepper motors 17 Figure ‎4.6: wooden boxes for stepper motors #2 18 Figure ‎4.7: Final result of the cabinet 19 Figure ‎4.8: Arduino mega 2560 20 Figure ‎4.9: ESP32-WROOM-32 21 Figure ‎4.10: Power Supply 22 Figure ‎4.11: Nema17 Stepper Motor 23 Figure ‎4.12: Servo motor MG995 24 Figure ‎4.13: A4988 Stepper Driver Module 25 Figure ‎4.14: IR sensor 26 Figure ‎4.15: Fingerprint sensor AS608 27 Figure ‎4.16: Keypad 4x4 28 Figure ‎4.17: LCD 16X2 29 Figure ‎4.18: i2C 30 Figure ‎4.19: i2C With LCD 30 Figure ‎4.20: Temprature Sensor DHT11 31 Figure ‎4.21: FAN 32 Figure ‎4.22: Breadboard 32 Figure ‎4.23: Intercom Wires 33 Figure ‎4.24: Jumper Wires 33 Figure ‎4.25: Lock 34 Figure ‎4.26: module Relay 34 Figure ‎4.27: ASM Chart 35 Abstract Our project idea came from pharmacy visits. We noticed that pharmacists face some difficulties in finding medicines sometimes because they are distributed in different places and far from each other, so we came up with our smart vending machine to help them access these medicines which may be demanded frequently and we tried to give them the chance to save effort and time during their working hours. Our machine stores the medicines in cells and they can be reached through a user interface which facilitates its use and makes it user friendly, easy to use and understood by pharmacists. It has a box or a basket that collects the demanded medicines and brings them to the user so that they don't have to look for them all over the pharmacy. Our project is initially designed for medicines that don't need a refrigerator and for commonly used ones like painkillers, antibiotics and so on. This initial design came after asking a number of pharmacists and saying that this would help them a lot with their job. It's also a secured machine that can’t be accessed by anyone because it needs a fingerprint and a passcode to open it. It also has a temperature sensor which will turn on a fan if the temperature exceeds a specific degree. 1. Introduction When you visit a pharmacy you may notice that the pharmacist faces some difficulties in finding some medicines when you ask for them, our smart vending machine works on reducing these difficulties for the pharmacist and to facilitate their job by bringing the requested medicines without the need for the pharmacist to search for them manually, all they need is to select the medicines they want and the machine will collect them easily and bring them all at once. 1.1 Statement of the problem The main problem is difficulties in finding specific products in different locations that are spread all over a large area. Here in our project we took pharmacies as an example and we tried to solve this problem for them. 1.2 Objectives 1. Efficient medicine retrieval: the main goal of the project is to build a smart vending machine that makes it easier for pharmacists to retrieve medications. The system intends to drastically minimize the time pharmacists spend looking for and collecting medications from various locations by storing medications in easily accessible cells and leveraging an easy user interface. 2. Time and effort savings: by cutting down on the time and effort needed for searching for and putting together medications, the method aims to maximize pharmacist productivity. Pharmacists can concentrate more on patient care and counseling by using a consolidated platform for medication delivery, which enhances the level of service overall. 3. User-Friendly interface: the user interface of the smart vending machine is intended to be simple to use and understand by pharmacists. This interface will make it easier for pharmacists to find, choose, and retrieve medications quickly, improving their overall technology experience. 4. Medicine temperature monitoring: a temperature sensor will be added to the system to ensure the medications integrity. The device will engage a cooling mechanism (fan) to maintain appropriate storage conditions and protect the medications' efficiency if the surrounding temperature rises above a certain threshold. 5. Security Measures: Robust security features, such as fingerprint identification and passcode authentication, will be incorporated into the smart vending machine. By taking these precautions, unauthorized access to the machine will be prevented, and only authorized individuals, such as pharmacists, will be able to modify medicines on it. 1.3 Scope of work 1. System Development: · Combine passcode and fingerprint authentication for secure access. · Ensure data security and privacy while conforming to applicable security standards. 2. Efficient Medicine Handling: · Design storage spaces and dispensing systems for easy access to medications. · Speed up pharmacy operations and decrease search times. 1.4 significance The Smart Pharmacy Medicine Dispensing System has the potential to significantly improve accessibility and efficiency while revolutionizing pharmaceutical operations. Pharmacists' time constraints are addressed by the system through accelerated medicine retrieval and delivery, allowing them to concentrate on patient care. With integrated security features and temperature monitoring, the technology puts patient safety and data integrity as a priority. The ultimate goal of this project is to provide a user-friendly pharmacy environment that enhances both pharmacist experience and patient care quality. 2. Constraints, limitations, standards/ codes and earlier coursework 2.1 Constraints and limitations 1. Servo motors couldn’t rotate 360 degrees so we had to modify them from the inside which was challenging. 2. Stepper motors needed to be controlled by the potentiometers connected with their drivers and we had to adjust them more than once. 3. Designing the outer shape of the machine because we couldn’t at first find a carpenter who is used to dealing with graduation projects machines and their designs. 2.2 Standards/ codes The system's software components comprise a C++ program for the Arduino, which integrates various libraries and functionalities like Keypad.h, LiquidCrystalI2C.h, wire.h, DHT.h, SoftwareSerial.h, Adafruit_Fingerprint.h, and Servo.h. The user interface was crafted using HTML code. The system follows applicable industry standards and codes in both designing and executing its software elements. 2.3 Earlier coursework 1. Electronics courses and electronic labs were very useful for understanding the electronic components we used and how they worked. 2. Microcontroller course using PIC by DR.Raed Qadi also was extremely important because it made us understand how microcontrollers work and how we should deal with them and interface them with other components. 3. Critical thinking course: the ability to approach the project methodically and make wise conclusions was provided by the Critical Thinking course, which was crucial to the project's success. The course helped us develop critical thinking abilities that enabled us to recognize potential problems, examine them, and come up with workable solutions. This became even more crucial as the project progressed and we encountered design and power-related challenges. 3. Literature review Over the years, considerable advancements have been made in the development of vending machines. Vending machines were first launched as basic coin-operated dispensers of food and beverages, but they have since developed into sophisticated systems. Early vending machines mostly sold simple commodities like gum, snacks, and beverages, and they used mechanical processes to release the products when money was inserted. Electronic components were added to vending machines as technology developed, allowing for more precise product delivery, improved security measures, and the acceptance of a variety of payment methods, including credit cards and mobile payments. The range of things available increased as a result of this transition, including fresh groceries, technology, and even healthful snacks. Additionally, the addition of touch interfaces and digital screens to vending machines increased their level of involvement. Through user-friendly interfaces, customers can now browse product information, nutritional information, and even customize their orders. Real-time data collection was made possible by the technology integration, allowing operators to remotely check inventory levels, consumer preferences, and machine performance. The idea of "smart vending machines" has developed recently, utilizing machine learning and artificial intelligence to optimize inventory management, customize suggestions, and forecast customer trends. These devices can modify their product selections in response to variables including location, hour of the day, and even the weather. A combination of consumer desire for convenience, technological developments, and an increasing focus on healthier and more varied product alternatives have all contributed to the development of vending machines. Vending machines have evolved from being basic dispensers to complex, adaptive retail platforms, becoming a crucial component of contemporary retail and customer experiences. · “A simulation-optimisation genetic algorithm approach to product allocation in vending machine systems” 2020, Expert Systems with Applications: The rise of vending machines as a convenient solution for quick access to products has brought economic benefits. However, optimizing the logistics behind vending machines presents challenges. This paper proposes a model to optimize product allocation within vending machines, considering fixed restocking schedules. The approach integrates Genetic Algorithms and simulation, focusing on product profitability based on net revenue after restocking costs. The method enhances decision-making for both product selection and restocking schedules, benefiting vending logistics. The model, validated with real data, showed network-wide revenue improvements of approximately 3.4%, especially benefiting high-performing machines with up to 6% gains. This approach combines simulation and optimization to address vending machine logistic challenges effectively. · “Healthier vending machines in a university setting: Effective and financially sustainable” 2018, Appetite The adoption of healthier snack options in schools has gained momentum, supported by guidelines like "A Guide to Smart Snacks in School" by the FDA. Private institutions and local governments are also taking steps to promote healthier choices from vending machines. Strategies involve increasing the availability of healthy items, adjusting prices, and using branding and posters to highlight nutritious options. This trend extends beyond schools to various settings like hospitals, city parks, public buildings, workplaces, and college campuses. 4. Methodology 4.1 System architecture We designed a 80cm * 50cm * 60cm cabinet with wheels to facilitate moving it, at first we didn’t put the front wall and the back one so that we could work easily. Then we made the CNC using door rails and connected a small basket to them which will collect the medications and bring them to the pharmacist. So this was the initial appearance : Figure ‎4.1: Initial design of the cabinet After that we put the medicines into discharging units. We made a helical coil out of 3 mm thick metal wire by wrapping it around a 7 cm in diameter spray paint can. Figure ‎4.2: helical coil for products movement on the cell We also used pulleys and small plastic belts which we hung the basket to, so it can be moved by the motors. Figure ‎4.3: pulleys and small plastic belts Figure ‎4.4: pulleys and small plastic belts #2 Also we made small wooden boxes for stepper motors to hold them in proper places to achieve accurate movement. Figure ‎4.5: wooden boxes for stepper motors Figure ‎4.6: wooden boxes for stepper motors #2 And this was the result after all: Figure ‎4.7: Final result of the cabinet 4.2 hardware components and devices 1. Arduino Mega 2560: The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. We used the arduino as our controller which was responsible for driving all of the components mentioned below . Figure ‎4.8: Arduino mega 2560 2. ESP32-WROOM-32: ESP32-WROOM-32 (ESP-WROOM-32) is a powerful, generic Wi-Fi+BT+BLE MCU module that targets a wide variety of applications, ranging from low-power sensor networks to the most demanding tasks, such as voice encoding, music streaming and MP3 decoding. At the core of this module is the ESP32-D0WDQ6 chip*. The chip embedded is designed to be scalable and adaptive. There are two CPU cores that can be individually controlled, and the clock frequency is adjustable from 80 MHz to 240 MHz. We used the esp to connect the webpage we designed using html code to the arduino. This page helps the pharmacist to choose the medications they want in a user-friendly way. Figure ‎4.9: ESP32-WROOM-32 3. Power supply : we used a huntkey power supply hk280-22fp Figure ‎4.10: Power Supply And these are the specifications of the device: 4. Nema 17 stepper motors: A NEMA 17 stepper motor is a stepper motor with a 1.7 x 1.7 inch (43.18 x 43.18 mm) faceplate. The NEMA 17 is larger and generally heavier than for example a NEMA 14, but this also means it has more room to put a higher torque. However, its size is not an indication of its power. In our project we used two stepper motors to control the movement of the basket in horizontal and vertical axes. By determining the appropriate number of steps for each column and each row so that if we had to add more cells all we need to do is to call these functions that contain the exact steps. Figure ‎4.11: Nema17 Stepper Motor 5. Servo motors: MG995 Servo Motor is a heavy-duty reliable servo motor. It is a low-power, cost-effective motor. MG995 is a dual shock-proof ball-bearing servo design with metal gear making it quite feasible for industrial production. The motor has a quick response and rotates at high speed. It comes with great holding power and a stable constant torque range. They are widely used in consumer robotics and hobby projects. The servo motors we bought earlier could only rotate up to 180 degrees.So, we modified their functionality manually to suit our machines needs to rotate up to 360 degrees so they can dispense the medicine we want. In our machine the servos were responsible for pulling the medicines into the basket by rotation 360 degrees. Figure ‎4.12: Servo motor MG995 6. A4988 stepper motor driver module: A stepper driver module controls the working of a stepper motor. Stepper drivers send the current to the stepper motor through various phases. The A4988 Nema 17 stepper driver is a microstepping driver module that is used to control bipolar stepper motors. This driver module has a built-in translator that means that we can control the stepper motor using very few pins from our controller. Figure ‎4.13: A4988 Stepper Driver Module 7. IR sensors: The IR sensor or infrared sensor is one kind of electronic component, used to detect specific characteristics in its surroundings through emitting or detecting IR radiation. These sensors can also be used to detect or measure the heat of a target and its motion. In many electronic devices, the IR sensor circuit is a very essential module. This kind of sensor is similar to human’s visionary senses to detect obstacles. In our project we used them to detect if a cell is empty (has no medicines) or not. Figure ‎4.14: IR sensor 8. Fingerprint sensor AS608: AS608 is a fingerprint scanner and reader module but does more than that like fingerprint enrollment, image processing, print matching and many more. It processes the data and sends processed data to the microcontroller through serial. The device uses a DSP chip that does image rendering, feature finding, calculation and searching. In our smart vending machine we used the fingerprint sensor for security purposes, so that only specific people can open the cabinet and add medications to it. Figure ‎4.15: Fingerprint sensor AS608 9. Keypad 4x4: The 4×4 matrix keypad is an input device, usually used to provide input value in a project. It has 16 keys in total, which means it can provide 16 input values. The most interesting thing is it used only 8 GPIO pins of a microcontroller. We used the keypad as a way of security beside the fingerprint, also it allows the pharmacists to open the cabinet by entering the right password. Figure ‎4.16: Keypad 4x4 10. LCD 16X2: An electronic device that is used to display data and the message is known as LCD 16×2. As the name suggests, it includes 16 Columns & 2 Rows so it can display 32 characters (16×2=32) in total & every character will be made with 5×8 (40) Pixel Dots. So the total pixels within this LCD can be calculated as 32 x 40 otherwise 1280 pixels. We used our LCD to display some comments and warnings such as “Temperature is high!”,”enter password ”, “correct password ” and so on. Figure ‎4.17: LCD 16X2 11. I2C module: we used the i2c and connected it with the LCD so that we only need 4 pins from it instead of 16 pins. Figure ‎4.18: i2C Figure ‎4.19: i2C With LCD 12. Temperature and humidity sensor DHT11: The DHT22 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and spits out a digital signal on the data pin (no analog input pins needed). It's fairly simple to use but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds old. In our machine we used the DHT22 to measure the temperature continuously and turn on the fan when it's needed for the medicines. Figure ‎4.20: Temprature Sensor DHT11 13. Fan qfr0812vh: Figure ‎4.21: FAN 14. Breadboard : Figure ‎4.22: Breadboard 15. Wires: we used intercom wires and breadboard jumper wires. Figure ‎4.23: Intercom Wires Figure ‎4.24: Jumper Wires 16. Lock: we used a lock like this one to ensure the security of the cabinet, this lock will be opened when a valid fingerprint is detected or when a correct password is entered using the keypad. Figure ‎4.25: Lock 17. module Relay: we used this relay for the fan and for the lock so that we can control them. Figure ‎4.26: module Relay 4.3 How does the system work? Figure ‎4.27: ASM Chart When the Arduino Mega and the ESP32-WROOM are turned on, the ESP tries to connect to the internet and connect to the localhost server. After that, the system checks if all cells are empty, which means no medicines are available on the machine. If so, the system will not accept any request from the user and will remain idle. For the fingerprint, keypad, temperature sensor, and irs, they will be reading inputs all the time and checked within each loop iteration. If a fingerprint is detected on the fingerprint sensor, the system will accept it, and if it finds a match, it will open the lock so that the pharmacist can fill the cabinet manually. The same goes for the keypad; if a key is pressed, the system will ask the user to enter the correct password to open the machine.Also whenever an empty place is detected the ir sensor will send a notification to the user on the LCD with the number of the cell that has no medicines. For the temperature sensor, whenever it detects a degree that exceeds a specific threshold, the fan will be turned on for a specific amount of time. For the request part, if there is at least one cell that is not empty (has at least one medicine), the pharmacist will be able to make a request by choosing the medicines they want using the user interface and get the medicines they want. Once they have made the request, the motors will immediately work and move the basket to get the requested medications from the proper cells (each cell contains a specific medicine). When the basket arrives at the medicine, the servo motor will rotate 360 degrees so that it pulls the medicine to the basket. After that, the cell will move to the next position if the pharmacist requested more than one medicine, and when it's finished, it will return to the reference. 5. Results and discussion Results : Smart vending machine systems have successfully created an efficient and user-friendly solution for pharmaceutical management. It offers automatic access to commonly used medicines, reducing the time pharmacists spend searching for medications. Furthermore, the inclusion of a mobile app enhances the system's usability, allowing healthcare professionals to remotely manage medication requests and monitor inventory levels. These results demonstrate the system's potential to improve pharmacy operations, save time for healthcare providers, and ultimately enhance patient care within healthcare facilities. Discussion : Our project marks a substantial change from typical pharmacy distribution strategies. It creates new opportunities for efficiency and convenience in healthcare settings by integrating automation and smart technology into medicine access. Our technology, which is presently in the implementation phase, has a great deal of potential to revolutionize pharmaceutical management. In the future, it might improve patient care while also automating pharmacy operations. 6. Conclusion and Recommendations 6.1 conclusion : In conclusion, our project on smart vending machines provides a comprehensive answer to the problems that pharmacists encounter in effectively collecting often needed medications. We created a system that satisfies the requirements of contemporary healthcare facilities while also aligning with the needs of pharmacists by fusing user-friendly design principles with cutting-edge automation and security features. The encouraging comments we got from pharmacists during the concept validation stage of our project highlight the potential influence of our solution on pharmacy operations. Our idea for a smart vending machine can be used as a guide to boost productivity, cut down on manual labor, and eventually improve patient care as the pharmaceutical industry develops. Future iterations and improvements to the smart vending machine's capabilities may pave the way for wider uses in healthcare settings, fostering the development of a more efficient and effective healthcare ecosystem. Our initiative is an example of how technology, user-centric design, and healthcare knowledge can come together to address real-world problems and significantly improve industry processes. 6.2 Recommendations : We provide the following suggestions for future improvements and considerations based on the design and implementation of our smart vending machine project for pharmaceutical settings: 1. Expanded Medication Range: Although the basic design of the smart vending machine concentrates on non-refrigerated and frequently used pharmaceuticals, there is room to increase the variety of medications kept there. The machine's applicability can be increased by working with pharmacists and healthcare professionals to identify more pharmaceuticals that can be included. 2. Integration with Inventory Management Systems: You might think about combining the smart vending machine with the current pharmacy inventory management systems to increase efficiency even more. Medication supply levels can be monitored in real-time, and computerized reordering can speed up the refilling process and avoid stockouts. 3. Customization and Modular Design: The flexibility and usefulness of the smart vending machine can be improved by providing a modular design that enables pharmacists to alter the cell configuration in accordance with their particular demands. Different pharmacy layouts and medicine delivery patterns can be accommodated by this functionality. 4. Remote Monitoring and Maintenance: Include features that enable pharmacy managers to monitor machine status, temperature, and usage patterns remotely. Additionally, software updates and remote troubleshooting help reduce downtime and guarantee smooth functioning. 5. Accessibility and Inclusivity: The smart vending machine's user interface should be simple to operate and accessible to people of all technological backgrounds. Inclusivity can be improved by clear instructions, visual aids, and different language choices. 6. Data Analytics and Insights: Include data gathering and analytics capabilities in the machine to offer insights regarding pharmaceutical demand patterns, usage frequency, and top picks. Future optimizations and inventory management decisions can be guided by this knowledge. 6.3 Future work : 1. Partnerships with Healthcare Providers: Collaborate with healthcare providers and clinics to deploy smart vending machines in medical facilities, allowing patients to conveniently access prescribed medications on-site. 2. Mobile App Integration: Develop a companion mobile app that allows pharmacists to remotely interact with the vending machine, monitor stock levels, place restocking orders, and receive notifications about machine status. 3. Integration with Electronic Health Records (EHR): Investigate the possibility of integrating the smart vending machine with electronic health record systems. This integration can enable pharmacists to have a holistic view of patients' medication histories and tailor their recommendations accordingly. 4. Cells filling mechanism: in the future we hope to improve our smart vending machine so that it would be smart enough to fill itself automatically without the need to open the back or the door and fill the cells manually. 7. References · Arduino. "Software." Accessed [2.5.2023]. www.arduino.cc/en/software. · Draw io. "Software." Accessed [5.8.2023]. http://draw.io. · Adafruit. "Software." Accessed [12.6.2023]. learn.adafruit.com. · ESP32. "Hardware" Accessed [24.7.2023]. www.espressif.com/en/products/socs/esp32. · Servo MG995. "Hardware" Accessed [15.5.2023]. datasheet/MG995_Tower-Pro.pdf. · Stepper Motor. "Hardware." Accessed [5.5.2023]. Data-Sheet-Stepper-Motor.pdf. · A4988 Driver. "Hardware" Accessed [5.5.2023]. datasheetA4988StepperMotorDriver.pdf. · 2020, Expert Systems with Applications. A simulation-optimisation genetic algorithm approach to product allocation in vending machine systems - ScienceDirect · 2018, Appetite. Healthier vending machines in a university setting 38 image2.jpg image3.jpg image4.jpg image5.jpg image6.png image7.png image8.png image9.png image10.png image11.png image12.png image13.png image14.png image15.png image16.png image17.png image18.png image19.png image20.png image21.png image22.png image23.png image24.png image25.jpg image26.png image27.png image28.png image29.png image30.png image31.jpg image1.png