An-Najah National University Faculty of Engineering & Information Technology Presented in partial fulfillment of the requirements for Bachelor degree in Computer Engineering Graduation Project 2 Caffeine Shot Machine Students: Sondos Hijab Nabeel Kayed Supervisor: Dr. Samer Arandi May 27, 2023 Acknowledgment We would like to express our appreciation to our supervisor, Dr. Samer Arandi, for his time and effort as well as for the great pieces of advice he provided during the project. Our deepest thanks go to our families, friends, and everyone who supported us during this journey 1 Disclaimer Statement This report was written by Sondos Hijab and Nabeel Kayed, students at the Computer Engi- neering Department, Faculty of Engineering, An-Najah National University. It has not been altered or corrected, other than editorial corrections, as a result of assessment and it may con- tain language as well as content errors. The views expressed in it together with any outcomes and recommendations are solely those of the students. An-Najah National University accepts no responsibility or liability for the consequences of this report being for a purpose other than the purpose for which it was commissioned. 2 Contents List of Figures 5 1 Introduction 9 1.1 Statement of the problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.2 Objectives of the work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3 Scope of the work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4 Significance of our work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.5 Organization of the report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2 Constraints, Standards/ Codes and Earlier course work 11 2.1 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 Standards and Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.3 Earlier coursework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3 Literature Review 14 4 Methodology 17 4.1 Hardware Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.1.1 Microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.1.2 Motors and drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.1.3 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 4.1.4 Input/Output Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.1.5 Power Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.1.6 Other Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.2 Software Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.2.1 Flow Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.3 Hardware Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.3.1 Heating Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.3.2 Input-Output Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.3.3 Making Coffee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3 CONTENTS CONTENTS 4.3.4 Control Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.4 Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 5 Results and Discussion 43 6 Conclusions and Recommendation 44 6.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 6.2 Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.3 What we have learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.4 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 References 46 4 List of Figures 4.1 Arduino Mega 2560 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.2 ESP32-DevKitC ESP32-WROOM-32U Core Board . . . . . . . . . . . . . . . . . 18 4.3 Servo Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.4 J-5718HB2401 Stepper motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.5 YS-DIV268N driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.6 DC motor - Optical Disk Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4.7 H-Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4.8 IR Sensor Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 4.9 Ultrasonic Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.10 Water Temperature Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.11 20*4 LCD and I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.12 RFID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.13 Keypad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 4.14 Buzzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 4.15 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.16 Arduino Power Cable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.17 Cup Dispensing Piece . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.18 Conveyor Belt Rods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.19 Relay Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.20 Water Heater . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.21 Valve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.22 Valve Accessories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.23 Group head . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.24 Funnel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.25 Circular Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.26 Pump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.27 On/Off Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 4.28 Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 5 LIST OF FIGURES LIST OF FIGURES 4.29 Wires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4.30 Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.31 Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.32 Part 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.33 Part 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 4.34 Admin Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.35 Employee Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 6 List of Tables 7 LIST OF TABLES LIST OF TABLES Abstract Caffeine Shot is a coffee machine that extends beyond traditional coffee machines found in shops. Not only does it provide users with the choice of three options - Nescafe, dark coffee, and normal coffee - but it also allows users to customize their own drinks. What really sets it apart from other coffee machines is that it can be controlled remotely using a mobile applica- tion. This means that users can easily access Caffeine Shot from wherever they are. There are similar coffee machines existing, but none have the same additional features we propose. And we have benefited from previous machine design projects and workflows. The Caffeine Shot Machine consists of four units: a Heating Unit, an Input/Output Unit, a Control Unit, and a Making Coffee Unit. The heating unit uses a heating element to keep the water boiling. The Input/Output Unit allows users to order coffee using an LCD and a Keypad or a Mobile Application. The Control Unit enables communication between the units and connects the machine to the Mobile Application using an Arduino Mega and an ESP32. Finally, the Making Coffee Unit collects the ingredients and heated water in the group head. We built this project with various sensors, including a temperature sensor, 3 IR sensors, and 4 ultrasonic sensors. We also used DC, servo, and stepper motors. We needed a roller, a wooden body, and a belt to build the conveyor belt. We used a 3D-designed cup dispenser piece and a DC motor to dispense the cups. The microcontroller we used is an Arduino Mega, and we also used an ESP32 module. Lastly, we handled interfacing with external components such as a pump and a heater. The coffee machine boasts several useful features. Users can order drinks with an RFID card or mobile application. Moreover, it can make multiple drinks in succession, without pausing if one isn’t taken. This project proposes placing the machine in an office with multiple employees and a ma- chine manager to register personal information in a database, allowing them to use a mobile app, RFID cards, and an electronic wallet connected to their ID for payment. 8 Chapter 1 Introduction 1.1 Statement of the problem The Caffeine Shot Machine aims to address the limitations of previous drink machines, specifi- cally the inability of customers to fully customize their drinks by controlling ingredient amounts, the lack of mobile application support for ordering drinks, and the absence of real-time feedback on internal sensors and ingredient quantities. 1.2 Objectives of the work The objective of this work is to design and develop a new drink machine that meets the needs and preferences of modern consumers. Specifically, the aim is to provide customers with greater control over their drink customization, offer mobile application support for ordering and pay- ment, and provide real-time feedback on ingredient levels and sensor readings. The proposed machine also seeks to offer convenience and ease of use for both customers and machine admin- istrators. By achieving these objectives, our team hopes to provide a unique and innovative solution to the limitations of existing drinks machines and meet the growing demand for per- sonalized and technology-driven experiences in the food and beverage industry. 1.3 Scope of the work Throughout the project, we employed a comprehensive approach that involved several phases. Firstly, we identified the optimal features for our machine and proceeded to carefully select suitable components such as sensors, motors, drivers, and printed parts. Additionally, we de- termined the necessary controller for the system to ensure smooth operation. To simplify the process, we divided the project into separate units, including Input/Output, Heating, Drink Preparation, and Dispensing units. Each unit underwent rigorous testing in isolation before 9 1.4. SIGNIFICANCE OF OUR WORK CHAPTER 1. INTRODUCTION being integrated into the overall design of the machine. Dependent units were subsequently tested to ensure seamless functionality. Finally, we developed an algorithm to effectively con- trol the machine and carried out extensive tests on the integrated system to ensure optimal performance under all possible scenarios. 1.4 Significance of our work This level of customization and convenience is increasingly sought after in the market, particu- larly as consumers become more health-conscious and demand greater control over the contents of their drinks. Furthermore, the trend towards mobile ordering and the use of technology in the food and beverage industry is rapidly growing, making our machine well positioned to meet these demands. Overall, our work has the potential to revolutionize the drinks machine industry by providing a unique and user-friendly experience that addresses the growing demand for customization and convenience. 1.5 Organization of the report This report is organized into several sections. The introduction provides an overview of the project and its objectives. The second section describes the scope and boundaries of the work. The third section outlines the methodology and procedures followed in completing the project. The fourth section presents the results and findings, including any challenges encountered and how they were overcome. The fifth section discusses the significance and potential impact of the project. Finally, the conclusion summarizes the key points of the report and provides rec- ommendations for future work. Appendices are also included to provide additional information and data relevant to the project. 10 Chapter 2 Constraints, Standards/ Codes and Earlier course work 2.1 Constraints Through designing and building our machine, we faced multiple constraints: 1. Power supply - Multiple components in the machine needed different values of voltage and current, such as the heater and valve which needed 220 volts, and motors and pumps that needed 12 volts. We overcame this by using a power supply from an old computer that provided 5 volts and 12 volts, and taking the 220 volts from the normal electricity that is provided to homes and labs. 2. Arduino mega - We initially decided to use Arduino mega as the controller of the machine, but the one we bought was giving a 3 volts as a high voltage from Input/Output digital pins instead of 5 volts and 1 instead of 0 for the Input/Output digital pin that is set to be low. This was the reason why the relays used for pumps, heater, and valve didn’t work as they didn’t receive the voltage they needed, which was 5 volts. We overcame this by replacing the Arduino mega with a new one that had the correct voltage output. 3. Stepper motor - We initially used a stepper motor that is Nema17 and it was used before, but it didn’t do its job to rotate the disk that has the ingredients or to rotate the roller of the conveyor belt. After a lot of experimentation, We needed to use another 2 stepper motors which are Nema23 to do both functionalities. 4. Designing the outer shape of the machine - We faced a problem in designing the outer 11 2.2. STANDARDS AND CODESCHAPTER 2. CONSTRAINTS, STANDARDS/ CODES AND EARLIER COURSE WORK shape of the machine since it depended on summing all the units and components together in a box that should be holdable and user-friendly. To overcome this, we measured all the units and components and decided on the measurements and specifications of the outer design. 2.2 Standards and Codes The software components of the system include an Arduino program written in C++, which incorporates several libraries and functions such as Keypad.h, LiquidCrystalI2C.h, wire.h, OneWire.h, DallasTemperature.h, and Servo.h. The user interface was developed using Flut- ter, while the backend and database were implemented using Firebase. The system adheres to relevant industry standards and codes in the design and implementation of its software components. 2.3 Earlier coursework Taking the Microcontroller using PIC controller course was extremely beneficial. It helped us gain a better understanding of microcontroller programming, which was essential for building our machine using Arduino Mega. Additionally, we learned how to interface with various com- ponents and utilize techniques such as I2C and PWM. The knowledge gained from this course allowed us to effectively write the code containing the needed algorithm for the machine, which is the heart of the project. The Critical Thinking course played a critical role in the project by enabling us to approach the project systematically and make informed decisions. The course provided us with critical thinking skills, which helped us to identify potential issues, analyze them, and propose effective solutions. This was especially important when we faced design and power-related issues during the project. Taking an Arduino course was also essential for building the machine, as it provided us with the necessary skills and knowledge to work with the Arduino Mega board. The course allowed us to gain hands-on experience in coding and debugging the Arduino board, which was crucial in developing the control system for our machine. The Networks course provided us with an understanding of communication protocols and net- working fundamentals, which helped us to design the machine’s networking infrastructure. This was important as we needed to build a system that allowed the user to operate the machine remotely via an app. 12 2.3. EARLIER COURSEWORKCHAPTER 2. CONSTRAINTS, STANDARDS/ CODES AND EARLIER COURSE WORK Finally, the Electronics course provided us with a solid foundation in the fundamental con- cepts of electronics, which helped us to design and troubleshoot the hardware components of the machine, such as the sensors, motors, valve, and pumps. 13 Chapter 3 Literature Review The Caffeine Shot Machine aims to provide customers with the convenience of mobile ordering and real-time feedback on sensor readings and ingredient levels. This part will review the re- lated literature on coffee vending machines, IoT concepts, smart coffee vending machines using sensor and actuator networks, and innovative coffee machine design projects. ”Smart Coffee Vending Machine Using RFID” Rahul Jadhv, Mrunali Jejurkar, and Pranita Kave developed a smart coffee vending machine that uses RFID technology to control product consumption and reduce waste in low-budget scenarios. The project also stores historical data in EPROM. While the study is not directly related to the Caffeine Shot Machine, it demonstrates the benefits of using technology to reduce waste and improve product monitoring.[1] ”Smart Coffee Vending Machine Based on IoT Concept” Sawai Pongswatd, Krit Smerpitak, and Teerawat Thepmanee used IoT concepts to enhance the remote monitoring and control capabilities of an existing coin-operated coffee vending machine. The upgraded machine allows for real-time tracking of technical and sales data, improving over- all machine performance. The study demonstrates the potential benefits of incorporating IoT concepts into coffee vending machines, such as remote monitoring and control.[2] ”Smart Coffee Vending Machine Using Sensor and Actuator Networks” Kwangsoo Kim, Dong-Hwan Park, Hyochan Bang, and Geonsoo Hong introduced a smart vend- ing machine that automatically measures its own indoor environmental conditions and controls the amount of coffee, sugar, and powdered coffee creamer to make a cup of coffee according to the customer’s preference on taste. The study shows the potential for sensor and actuator net- works to improve the customizability of coffee vending machines, which is a goal of the Caffeine Shot Machine.[3] 14 CHAPTER 3. LITERATURE REVIEW ”A Coffee Machine Design Project Through Innovative Methods, QFD, Value Anal- ysis, and Design for Assembly” This study demonstrates how innovative methodologies can improve the design process for sim- ple objects like a coffee machine. Quality Function Deployment, Value Analysis, and Design for Assembly are three methods used to improve quality during the design process. The study shows how a well-organized design process can lead to a more easily assembled and higher quality product, which is an essential goal of the Caffeine Shot Machine. ”Opensource Portable Coffee Machine” Yunseong Hong designed an opensource portable coffee machine that can produce a large amount of coffee outdoors. The project used a reverse engineering approach to understand the machine mechanism and followed the Engineering Design Process to organize the project plan. The study shows the potential benefits of opensource hardware and how it can improve the design process for coffee machines. ”Concept of a New Generation IoT Coffee Machine” This thesis researched the prospect of creating a new IoT coffee machine. The study focused on finding a method for detecting the coffee jug’s content and implementing monitoring for the users. The study shows the potential benefits of incorporating IoT concepts into coffee machines, such as the ability to prevent overflowing jugs. The literature review demonstrates that incorporating technology, such as IoT concepts, sensor and actuator networks, and RFID technology, can significantly improve coffee vending machine performance. Additionally, innovative methodologies like Quality Function Deployment, Value Analysis, and Design for Assembly can improve the design process and lead to a higher quality product. In designing and developing The Caffeine Shot Machine, we benefited from these findings by incorporating similar technologies and methodologies. Our project shares a common sub-process with previous works in the field, including tech- niques for heating the water, preparing the beverage, and dispensing the ingredients and water. This process is carried out by reading sensors and outputting an action accordingly. However, our machine boasts several unique added features that distinguish it from its predecessors. Firstly, it enables customers to customize their drinks by selecting the ingredients they desire. Moreover, it offers a range of beverage options beyond coffee. In addition, it features a cup dispensing and conveyer belt mechanism that allows for automatic cup dispensing upon order placement. Lastly, our machine is equipped with mobile app capabilities that enable customers 15 CHAPTER 3. LITERATURE REVIEW to place orders remotely, while administrators can control and monitor its operations. In addition to the aforementioned unique features, our machine also boasts the ability to auto- matically provide water to the machine when it runs low. This feature eliminates the need for manual refilling of the water tank and ensures a seamless and uninterrupted experience for the user. It further enhances the convenience factor of our machine and sets it apart from others in the market. 16 Chapter 4 Methodology This chapter will cover the hardware components used in building the system, their intercon- nections, and the overall system design. We will also discuss the system’s functioning process, as well as the software implementation, mobile application, and database that were used. 4.1 Hardware Components 4.1.1 Microcontrollers 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. This comprehensive set of features makes it an all-inclusive microcontroller solution for our project needs. Given the large number of connected devices required to interface with the microcontroller, the Arduino Uno was deemed unsuitable, hence we opted to use the Arduino Mega 2560 as our primary microcontroller. Figure 4.1: Arduino Mega 2560 17 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY ESP32-DevKitC ESP32-WROOM-32U Core Board Our project involved establishing a serial communication channel between the ESP32 and Ar- duino Mega microcontrollers. Additionally, we developed a web server-like access point to facilitate client connectivity to the Caffeine Shot machine network. This access point enabled remote ordering of customized drinks through a mobile device from any location within the user’s office. Once an order was placed, it was transmitted through the serial communication channel to the Arduino Mega, which automatically initiated the drink preparation process. The ESP32 microcontroller has a lot of features, including:[4] 1. Single or Dual-Core 32-bit LX6 Microprocessor with clock frequency up to 240 MHz. 2. 520 KB of SRAM, 448 KB of ROM and 16 KB of RTC SRAM. 3. Supports 802.11 b/g/n Wi-Fi connectivity with speeds up to 150 Mbps. 4. Support for both Classic Bluetooth v4.2 and BLE specifications. 5. 34 Programmable GPIOs. 6. Up to 18 channels of 12-bit SAR ADC and 2 channels of 8-bit DAC 7. Serial Connectivity include 4 x SPI, 2 x I2C, 2 x I2S, 3 x UART. 8. Ethernet MAC for physical LAN Communication (requires external PHY). 9. 1 Host controller for SD/SDIO/MMC and 1 Slave controller for SDIO/SPI. 10. Motor PWM and up to 16-channels of LED PWM. 11. Secure Boot and Flash Encryption. 12. Cryptographic Hardware Acceleration for AES, Hash (SHA-2), RSA, ECC and RNG. Figure 4.2: ESP32-DevKitC ESP32-WROOM-32U Core Board 4.1.2 Motors and drivers Servo motor Servo motors are widely used for their ability to provide precise control over position, speed, and torque, and are found in many types of machinery and devices that require accurate and 18 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY controlled movement. A servo motor is typically made up of a small DC motor, a gearbox, and a control circuit that regulates the motor’s movement. The control circuit provides feedback to ensure that the motor rotates to a precise position based on input signals, and then maintains that position with great accuracy, often within a few degrees. In our project, we used Micro Servo motors, which have a rotational range of approximately 180 degrees (90 degrees in each direction). We used them to regulate the dispensing quantity of each ingredient based on the order. One servo motor was assigned to control the Nescafe, another to regulate the sugar, a third to dispense instant coffee, and the fourth was responsible for the coffee mate. Figure 4.3: Servo Motor J-5718HB2401 Stepper motor and YS-DIV268N driver A stepper motor is an electrically powered motor that creates rotation from electrical current driven into the motor. Physically, stepper motors can be large but are often small enough to be driven by current on the order of milliampere. Current pulses are applied to the motor, and this generates discrete rotation of the motor shaft. This is unlike a DC motor that exhibits continuous rotation. Although it is possible to drive a stepper motor in a manner where it has near continuous rotation, doing so requires more finesse of the input waveform that drives the stepper motor. Stepper motors have input pins or contacts that allow current from a supply source into the coil windings of the motor. Pulsed waveforms in the correct pattern can be used to create the electromagnetic fields needed to drive the motor. 19 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY In our project, we used bipolar four-wire stepper motors, specifically the J-5718HB2401 model, as they are highly precise and efficient to do 2 functionalities: rotating the disk that holds the funnels that contains the ingredients and for the rotation of the conveyor belt that holds the dispensed cups. To drive the motors, we used the YS-DIV268N driver with a 12A power supply. The motor coils were connected to the A and B pins of the driver, while the control pins were connected to the corresponding Arduino pins, with the negative pins unified with the Arduino ground. The DC+ and DC- pins were supplied from a 12A power supply that offered sufficient power to move three stepper motors and had reliable voltage values. To determine the distance per cycle for each motor, we used the mechanical characteristics of the pulley and the timing belts. To drive the motors using code, we wrote a program that utilizes pulse width modulation on the step pin of the driver. The number of pulses can be modified to adjust the amount of movement, while the delay amounts can be altered to adjust the speed. Finally, the enable pin is always activated for each motor, while the direction pin is altered according to the required direction of movement. Figure 4.4: J-5718HB2401 Stepper motor Figure 4.5: YS-DIV268N driver 20 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY DC motor and H-Bridge A DC motor is an electrical machine that converts electrical energy into mechanical energy. It consists of a rotating armature and a stationary field magnet, which generates a magnetic field. When an electric current is applied to the armature, a torque is generated that causes the motor to rotate.[5] For our project, we required a DC motor to drive the 3D printed cup dispensing part, and we repurposed a computer disk’s DC motor for this purpose. To regulate the motor’s operation, we implemented an H-Bridge. Although the Arduino can produce a PWM signal, its voltage and current levels are too low to directly control the DC motor. Hence, we integrated a hardware driver which is the H-Bridge, between the Arduino and the DC motor. The H-Bridge served two functions in our design. Firstly, it amplified the PWM signal’s voltage and current levels from the Arduino, allowing for speed control. Secondly, it received the control signal from the Arduino and switched the pole of the power supply to enable directional control. Figure 4.6: DC motor - Optical Disk Drive Figure 4.7: H-Bridge 21 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY 4.1.3 Sensors IR Sensor Module An infrared sensor is a type of electronic sensor that detects infrared radiation in its surrounding environment. The sensor is designed to measure the temperature of objects or detect motion based on changes in the infrared radiation emitted by objects. Infrared sensors are commonly used in a variety of applications, such as remote temperature sensing, motion detection, and security systems.[6] The IR sensor module was utilized in three different locations of the conveyor belt in our project. The purpose was to detect the presence of cups at the points where the cup is dispensed, where the drink is poured into the cup, and where the cup reaches the end of the conveyor belt and stops. Figure 4.8: IR Sensor Module Ultrasonic Sensor An ultrasonic sensor is a device that uses sound waves with frequencies above the upper audible limit of human hearing to measure the distance to an object. The sensor emits ultrasonic waves that bounce off the object and return to the sensor. By measuring the time taken for the waves to return, the sensor can calculate the distance to the object.[7] In our project, the ultrasonic sensor was utilized to determine the quantity of ingredients remain- ing in the funnel by measuring the distance. This information is displayed to the administrator to enable them to refill the ingredients as necessary. 22 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY Figure 4.9: Ultrasonic Sensor Water Temperature Sensor A water temperature sensor is an electronic device that is designed to measure the temperature of water. These sensors typically consist of a thermistor or other temperature-sensitive element that is placed in contact with the water to be measured. The temperature-sensitive element is connected to a signal processing circuit that converts the temperature reading into an electrical signal that can be read by a computer or other electronic device.[8] In our project, we utilized a water temperature sensor to measure the temperature of the water in the heater. This allows us to ensure that the water is at an appropriate temperature before it is transferred to the group head. Figure 4.10: Water Temperature Sensor 23 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY 4.1.4 Input/Output Devices LCD and I2C A Liquid Crystal Display (LCD) is an electronic display device that is commonly used in var- ious electronic applications. The 20x4 LCD is a type of LCD display that can display up to 20 characters in each of its 4 rows. This display is widely used in different applications that require the display of large amounts of data such as in industrial automation systems, medical devices, and consumer electronics.[9] In our project, we utilized the LCD 20x4 as an output device to present relevant information and instructions to the customer. This approach provides a user-friendly interface, allowing the customer to interact with the system in a straightforward manner. Specifically, the LCD displays prompts and questions, prompting the customer to provide input through the keypad. The system then processes the input and provides appropriate responses on the LCD. We also used I2C Serial Interface Adapter. The I2C Serial Interface Adapter is a small module that can be used to connect an LCD display to a microcontroller using the I2C communica- tion protocol. It acts as a bridge between the microcontroller and the LCD display, converting the parallel signals from the display into serial signals that can be transmitted over the I2C bus. The I2C Serial Interface Adapter greatly simplifies the process of connecting an LCD display to a microcontroller, as it requires fewer wires and can be controlled using only two I/O pins on the microcontroller. Additionally, it allows multiple devices to be connected to the same I2C bus, making it a useful tool for applications where space and wiring are limited. [10] Figure 4.11: 20*4 LCD and I2C 24 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY RFID An RFID (Radio Frequency Identification) tag or card is an electronic device that stores and remotely retrieves data. It consists of a small microchip attached to an antenna on a substrate. When the tag or card is within the range of a reader, the reader sends an electromagnetic field to the tag, which powers it up and allows the reader to receive the data stored on the tag.[11] In our project, we utilized RFID as a means of authorization. By enabling customers to scan their RFID cards, they can place orders for drinks in the regular mode. The system associates the ordered drink with their unique ID, allowing for seamless payment processing. Figure 4.12: RFID Keypad A keypad is a set of buttons arranged in a matrix where each button can be identified by its row and column coordinates. Keypads are commonly used as input devices for microcontroller- based systems, including those built with the Arduino platform.[12] Within our project, we have made use of the keypad as an input device to provide customers with the ability to select their desired drink. This is achieved by displaying clear and concise instructions on the accompanying LCD display, which the customer can then input into the keypad to confirm their choice. 25 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY Figure 4.13: Keypad Buzzer A buzzer is an electronic component that produces sound by vibrating a diaphragm at a specific frequency. In our project, the buzzer was utilized as an output device to alert the customer when the drink they ordered is prepared and ready to be picked up.[13] Figure 4.14: Buzzer 26 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY 4.1.5 Power Devices Power Supply To meet the voltage requirements for our project, we chose to utilize a computer power supply, as it can provide the necessary 5 volts for multiple devices and 12 volts for pumps and stepper motors. Additionally, the power supply offers a sufficient current output that meets our project’s demands. Figure 4.15: Power Supply Arduino Power Cable The Arduino Power Cable is a type of cable that enables connection between an Arduino board and a power source, such as a computer’s USB port or a wall adapter. Its primary function is to provide power to the board, while also facilitating programming and data transfer. In our project, we utilized the Arduino Power Cable to ensure that the Arduino board received a stable 5-volt power supply, which was necessary for the proper functioning of the board. Figure 4.16: Arduino Power Cable 27 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY 4.1.6 Other Devices Cup dispensing piece We used a 3D-printed cup dispensing part in our machine, which functions as a cup separator, allowing one cup to drop through while holding the stack of cups intact. This single piece design efficiently dispenses cups one at a time as expected. Figure 4.17: Cup Dispensing Piece Conveyor Belt components In our machine, we utilized a wooden structure consisting of 2 rods and 4 connectors to create the conveyor belt. A coupler was also utilized to link the rod and the stepper motor. To facilitate the movement of the cups above it, we incorporated a friction material belt that could rotate easily while moving the cups. Figure 4.18: Conveyor Belt Rods Relay A relay is an electronic switch that can be used to control high voltage and current loads using a low voltage and current signal. A 5-volt relay module is a type of relay that can be controlled by 28 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY a 5-volt signal, which is compatible with the Arduino microcontroller. These modules typically have a small circuit board with a relay, an LED indicator, and screw terminals for connecting the load and control signals. [14] Figure 4.19: Relay Module Water Heater We used the water heater which is an electronic device that operates on 220 volts and is used for heating water. It is connected to a relay that is controlled by the Arduino, determining when the heater will work. The primary purpose of the water heater is to keep the water hot at all times. It automatically activates when the temperature sensor detects non-hot water, ensuring continuous hot water availability. Figure 4.20: Water Heater 29 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY Valve A non-pressure valve was utilized to ensure automatic water refilling in the water heater when- ever the water level runs low. We also used valve accessories to ensure that both sides of the valve were compatible with both the water heater and the tube. Figure 4.21: Valve Figure 4.22: Valve Accessories Group-head We used a temperature-resistant container as a group head in our machine. The hot water is transferred to the group head, where the ingredients from the disk are dispensed and mixed with heated water using the mixing pump. The second pump of the group head is then used to transfer the mixture to the cup. 30 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY Figure 4.23: Group head Disk and Funnels We incorporated 5 funnels in our machine, with 4 dedicated to holding the four main ingredients: coffee, Nescafe, coffee mate, and sugar. The fifth funnel was specifically designed to dispense the required quantity of each ingredient to the group head, ensuring the correct proportions are maintained for each drink. We made a circular disk to hold the 4 funnels that holds the ingredients. Figure 4.24: Funnel 31 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY Figure 4.25: Circular Disk Pumps and Tubes We incorporated three 12-volts pumps into our machine: the first pump transfers hot water from the water heater to the group head, the second pump is responsible for mixing the ingredients in the group head, and the third pump transfers the prepared drink from the group head to the cup. Figure 4.26: Pump On/Off switch We used an on/off switch to control the power supply. 32 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY Figure 4.27: On/Off Switch Breadboard We utilized a breadboard to connect various components, such as the 5 volts and 12 volts power supply, to the devices that require these voltages. Additionally, we used the breadboard to connect the resistance required for the temperature sensor, which was used as a pull-up for its input pin. Figure 4.28: Breadboard 33 4.1. HARDWARE COMPONENTS CHAPTER 4. METHODOLOGY Wires We used 3 types of wires: male-to-male, female-to-female, and male-to-female wires for various connections. Figure 4.29: Wires 34 4.2. SOFTWARE IMPLEMENTATION CHAPTER 4. METHODOLOGY 4.2 Software Implementation As a first step, we checked if the queue was full. If it was, we couldn’t accept the order, so we told the employee to wait until we had a place for his cup. As soon as we have a spot in the line, we ask if the person is an employee or a guest since there are two modes available. There is an employee mode and a guest mode. The employee mode will require that the employee pay for the drink, while the guest mode will provide it for free. Employees are asked to scan their cards to ensure their balance is enough to purchase drinks. As part of the Ordering process, there are three predefined types of drinks the employee can choose from. These are Nescafe, Coffee, and Double Coffee. For each, the employee can specify how much sugar he wants to add to the drink, as well as order drinks without sugar. Also, we offer customized drinks, where employees can specify the amounts of coffee, Nescafe, coffee mate, and sugar. As well, we ask him what size of cup he should choose: large or small. Depending on the type of drink and its specifications, we show the employee his order and ask him if he wants to confirm or cancel it, and if he confirms, we begin preparing it. As part of the drink preparation process, we first check to see if the water temperature is below 90 degrees and then wait until it reaches 90 degrees, then using the heater pump, we move water at a volume based on the cup size from the heater to the group head. After that, we rotate the disc that holds all the ingredients to bring the required ingredi- ent above the group head. Then, we open the servo motor to let the ingredients move to the group head. After that, we turn on the mixing pump for a specific time to mix the water with the ingredients. Once the mixing is completed, we dispense a cup and verify if it has been dispensed cor- rectly using the IR sensor. Then, we turn on the belt stepper to move the cup to the coffee station and check if the cup is in the correct position using the IR sensor. If it is, we turn on the cup pump to move the prepared drink from the group head to the cup. When the coffee is ready in the cup, we display a message on the LCD and turn on the buzzer to inform the employee that the drink is ready. After every order, we update the ultrasonic sensor values on the admin page of the web server. 35 4.2. SOFTWARE IMPLEMENTATION CHAPTER 4. METHODOLOGY 4.2.1 Flow Chart Figure 4.30: Part 1 36 4.2. SOFTWARE IMPLEMENTATION CHAPTER 4. METHODOLOGY Figure 4.31: Part 2 37 4.2. SOFTWARE IMPLEMENTATION CHAPTER 4. METHODOLOGY Figure 4.32: Part 3 38 4.2. SOFTWARE IMPLEMENTATION CHAPTER 4. METHODOLOGY Figure 4.33: Part 4 39 4.3. HARDWARE IMPLEMENTATION CHAPTER 4. METHODOLOGY 4.3 Hardware Implementation We have four units each one of which has its own responsibilities in ordering and preparing and delivering the drink. 4.3.1 Heating Unit Our heating unit consists of a water heater, water temperature sensor, and a valve connected to a tube that fills the heater from the tap. The heater has a range of 80-90 degrees and is controlled by the water temperature sensor. Additionally, a pump and tube are used to move the water from the heater to the group head. 4.3.2 Input-Output Unit We have the LCD and Keypad to accept orders from employees, and the RFID to identify employee IDs and use them for payment and cup dispensing. The cup dispensing mechanism consists of a PC disc that automatically dispenses cups, a 3D-printed cup dispenser, a belt with couplers, connectors, rollers, and a wooden shape, and a stepper that rotates the belt and moves the cup to the correct position. IR sensors ensure that the cup is in the right place, and a buzzer notifies the employee when their drink is ready. 4.3.3 Making Coffee We have a disc that holds the ingredient funnels, each equipped with a servo motor and a locker to control the amount of ingredients dispensed. The ingredients include coffee, Nescafe, coffee mate, and sugar. We rotate the disc using a stepper motor. Above each funnel, we place an ultrasonic sensor to measure the ingredient level and inform the manager when an ingredient falls below a specific level, indicating the need for a refill. In addition, we have the Group Head, where we make the drink. The Group Head has a large funnel to collect the ingredients from the disc, and two pumps: one for mixing water with the ingredients and the other for dispensing the prepared drink into a cup using a tube. 4.3.4 Control Unit In the control section, the Arduino manages all the machine’s operations. The Arduino is con- nected to the ESP32, which, in turn, is connected to the web server. This allows employees to place orders via the web server, while the admin controls the machine. Additionally, a PC 40 4.4. WEB SERVER CHAPTER 4. METHODOLOGY power supply is used to power the machine’s components. 4.4 Web Server The web server is divided into two parts. One part is for the admin, who can view the levels of the ingredients in the funnel and open the valve to fill the heater with water from the tap. The other part allows employees to order drinks using a mobile device instead of a keypad and LCD. The ordering process involves two screens: one to select the type of drink and another to choose the cup size. If the employee selects a customized drink, they can also choose the amount of coffee, coffee mate and sugar to add. In addition, we use the web server for payment. When an employee orders a coffee, the price is deducted from their wallet. Figure 4.34: Admin Page 41 4.4. WEB SERVER CHAPTER 4. METHODOLOGY Figure 4.35: Employee Page 42 Chapter 5 Results and Discussion At the end of this project, we successfully achieved the desired results by building a smart, automatic coffee machine with outstanding features such as cup dispensing parts. The admin can also use the mobile app to fill the heater with water, and employees can place orders using the app. Some of the problems that we faced and how we solved them: 1. After we debugged the problem, we found that the relays were not functioning properly. Upon investigation, we discovered that the output of the Arduino was only 3.1 volts in- stead of the required 5 volts. As a result, the relays that were designed to work on 5 volts did not work. After careful consideration, we decided to use another Arduino output that provided the required 5 volts. This solution allowed the relays to work correctly and ensured that the project was successful. 2. The ESP32 didn’t accept the code for multiple tries, after doing a lot of searching, we found that we should press the boot button while the code is uploading. 3. One issue we faced was powering the different components within the machine. Some required 220 volts, while others needed 12 volts. We solved this by using a power supply from an old computer that provided both 5 volts and 12 volts, and using the normal electricity from homes and labs for the 220-volt components. 4. One issue was with the stepper motor. We tried using a Nema17 motor, but it was not powerful enough to rotate the disk or roller. After experimentation, we found that we needed to use two Nema23 motors to handle both functions. 43 Chapter 6 Conclusions and Recommendation 6.1 Summary Our team has designed and developed the Caffeine Shot Machine, an automated device that makes it easy for employees to order their favorite drinks without any hassle. The machine is equipped with a web server and a keypad that can be used remotely to order drinks. One of the most impressive features of our machine is its accuracy in dispensing cups. The cup dispensing part works perfectly, dispensing the cups accurately without any human assistance. The belt is also well-designed, ensuring that each cup is moved to the coffee place swiftly and smoothly. Our machine also has IR sensors that allow us to accept multiple orders at the same time. This means that employees can make various orders simultaneously, which helps to save time and increase efficiency. To make the machine even more user-friendly, we have added customized drink options. This feature allows employees to specify the amount of drink ingredients they want in their cup, creating a personalized experience for each user. The machine also offers the option of choosing between small and large cup sizes, depending on personal preference. We have also overcome several challenges during the development of the machine. One of the challenges we faced was powering the different components within the machine. Some com- ponents required 220 volts, while others needed 12 volts. To solve this problem, we used a power supply from an old computer that provided both 5 volts and 12 volts and utilized normal electricity from homes and labs for the 220-volt components. Additionally, we initially used a stepper motor that was Nema17, but it didn’t do its job to rotate the disk that has the 44 6.2. RECOMMENDATIONS CHAPTER 6. CONCLUSIONS AND RECOMMENDATION ingredients or to rotate the roller of the conveyor belt. After a lot of experimentation, we had to use another 2 stepper motors which are Nema23 to do both functionalities. In summary, our Caffeine Shot Machine is a well-designed and efficient device that makes it easy for employees to order their favorite drinks. With its advanced features, customization options, and smooth automation, the machine offers a unique and user-friendly experience for its users. 6.2 Recommendations Recommendations: 1. Be careful when using the Arduino board, especially the Chinese version, as its output voltage is 3.1 volts instead of 5 volts. We recommend using the Italian version instead. 2. Avoid powering sensors and devices directly from the Arduino board. Use a separate power supply. 3. Always solder wires instead of just connecting them, as they are easily broken. 6.3 What we have learned 1. How to work with sensors like ultrasonic and IR, and motors like DC motors, servo motors, and stepper motors, as well as devices like pumps, heaters, and valves. 2. How to connect and use various types of high-voltage sensors and devices with Arduino. 3. How to connect Arduino to ESP32 and use its Wi-Fi features. 6.4 Future Work 1. Add GSM to allow the machine to give notifications to the manager. 2. Improve the web server by adding a login page and a statistics page for employees to track their machine usage. 3. Make the machine programmable so employees can create custom drinks and add them to the list of available drinks. 4. Clean the group head after every use to ensure the quality of the next drink. 5. Add a second cup dispenser for larger cup sizes. 6. Make the valve automatic with a water level sensor. 45 References [1] Rahul Jadhv et al. “Smart coffee vending machine using RFID”. In: Instrumentation Engineering department, Advances in Wireless and Mobile Communications 10 (2017), pp. 793–800. [2] Sawai Pongswatd, Krit Smerpitak, and Teerawat Thepmanee. “Smart coffee vending ma- chine based on IoT concept”. In: International Journal of Innovative Computing, Infor- mation and Control 16.4 (2020), pp. 1441–1448. [3] Kwangsoo Kim et al. “Smart coffee vending machine using sensor and actuator networks”. In: 2014 IEEE International Conference on Consumer Electronics (ICCE). IEEE. 2014, pp. 71–72. [4] Pavel Smutny Marek Babiuch Petr Foltynek. “Using the esp32 microcontroller for data processing”. In: International Carpathian Control Conference (ICCC) (2019), pp. 1–6. [5] M. Santhanakrishnan V. Nagarajan S. Sivakumar. “Design and Simulation of DC Mo- tor Speed Control Using PID Controller”. In: International Journal of Engineering and Technology (2011). [6] S. Muruganand R. Gunasekaran V. Rajamani. “Design and implementation of obstacle detection and avoidance robot using infrared sensors”. In: International Conference on Circuit, Power and Computing Technologies (ICCPCT) (2016), pp. 1–6. [7] Li L Li W. “Design of Intelligent Ultrasonic Sensor for Internet of Things Applications”. In: Journal of Physics: Conference Series, 1827(1), 012065 (2021). [8] J. Hu X. Zhang and X. Cui. “Design and Implementation of a Wireless Water Tem- perature Monitoring System”. In: International Conference on Computational Science and Engineering (CSE) and IEEE International Conference on Embedded and Ubiquitous Computing (EUC) (2016), pp. 174–178. [9] A. Al-Khalidi and I. B. Abu-Sulyman. “Design and Development of a Portable Industrial Multi-channel Data Acquisition System”. In: 2021 IEEE 11th Annual Computing and Communication Workshop and Conference (CCWC) (2021), pp. 19–26. 46 REFERENCES REFERENCES [10] N. A. Popov V. L. Boyarintsev V. V. Koryanov. “LCD Display with I2C Interface”. In: Procedia Computer Science 101 (2016), pp. 528–536. [11] D. Wadhwa R. Garg. “RFID Based Attendance System Using Arduino and GSM”. In: International Journal of Computer Applications 179.23 (2021), pp. 6–11. [12] A. Kumar S. Sahu. “Arduino Based Smart Home Automation System Using Android Smartphone”. In: International Journal of Scientific Engineering Research 6.7 (2015), pp. 62–65. [13] S. V. Dudul S. S. Patil. “Design and Development of Voice Command Recognition System for Smart Home Automation using Arduino”. In: International Journal of Innovative Research in Science, Engineering and Technology 9.12 (2020), pp. 8667–8674. [14] Y. Lee J. Kim. “Design and Implementation of an Arduino-based Home Automation System”. In: International Journal of Smart Home 9.7 (2015), pp. 11–22. 47 List of Figures Introduction Statement of the problem Objectives of the work Scope of the work Significance of our work Organization of the report Constraints, Standards/ Codes and Earlier course work Constraints Standards and Codes Earlier coursework Literature Review Methodology Hardware Components Microcontrollers Motors and drivers Sensors Input/Output Devices Power Devices Other Devices Software Implementation Flow Chart Hardware Implementation Heating Unit Input-Output Unit Making Coffee Control Unit Web Server Results and Discussion Conclusions and Recommendation Summary Recommendations What we have learned Future Work References