Skip to end of metadata
Go to start of metadata

Table of Contents

- Overview and Deliverables
- Interface
- Hardware
- Software
- Project Video
- Conclusion 

Overview and Deliverables 
The aim of this project it to refurbish an out of order Vending Machine in Electrical and Computer Engineering Department at Utah State University. This includes repairing the broken refrigeration and replacing existing mechanical interface with a Raspberry-pi based touchscreen interface. In addition, the conventional coin based payment system will be replaced by the honor payment system. A compact list of deliverables is given below. When fully functional, the vending machine should be able to:

  • Refrigerate drinks
  • Dispense ordered drinks
  • Provide a rough estimate of the number of drinks remaining
  • Display the drink temperature on touchscreen interface
  • Send email to a specified email address if the number of drinks fall below a certain number
  • Provide a user interface with options to configure drink/pricing detail

Image of the main interface is shown below. The 5 buttons on left present user with choice of a drink. The number immediately before slash indicates remaining drinks, whereas that after indicates the drinks user has ordered. Drink temperature is indicated on too right corner. On bottom right, the cancel order button cancels the ordered drinks in case user changes his mind. The button right next to it confirms the order and proceeds to the next step. Finally, the button in top right corner allows access to admin part.  


Micro-controller Board: The system was developed using Raspberry-pi 3 (Model B) board. Raspberry-pi provides huge computation power and has a built in WiFi module. The presence of an operating system provides flexibility for the choice of a programming language. It consists of 40 GPIO pins, ample for the purpose of this project.

Raspberry Pi model 3 B

Touch Screen: For user interface, 7-inch raspberry-pi capacitive touchscreen is used. The touchscreen connects to Raspberry-pi via DSI port. The large size of this touchscreen makes it a suitable fit for this project. Since this is manufactured by the same company as the raspberry-pi board, this makes the interface/programming part a lot easier as the handshaking is automatically handled. 

7 Inch Raspberry Pi Touchscreen

Distance sensors: To get an estimate of remaining drinks, the distance between top of slot and the cans was required. HR-S04 range finders were used, one for each slot. The HR-S04 has a range of 2-400 cm and a 3mm accuracy.

HR-S04 Range Finder

Temperature Sensor: The MCP9808 temperature sensor was installed to measure ambient temperature. MCP9808 can measure temperature with high accuracy and uses I2C interface for communication with raspberry-pi and has an operating voltage of 2.7-5.5 Volts.

MCP9808 Temperature Sensor

Relay board: The Elegoo 8 Channel 5 Volt relay board was used to provide interface between the electronics system (5V DC) and Vending machine (120V AC). 

Elegoo 8 Channel 5 Volt relay board

Power Supply: The power adapter used for this project supplies a maximum current of 2.5 Amperes. 

Due to its easy syntax, Python 2 was used for programming the pi on a Linux environment. The Graphical User Interface was developed using Tkinter python library (a link to Tkinter documentation can be found here). Tkinter provides various functions and methods for widget design (Buttons, Texts, Canvas, Backgrounds etc.). For a more detailed description of GUI design, refer to the project report (downloadable here).

The MCP9808 Adafruit library was used for setting up temperature sensor and measuring beverage temperature. MCP9808 communicates with the pie using I2C interface.

To measure distance, the trigger pin of HR-S04 is asserted. This produces a high frequency ultrasonic sound wave. At the same time, a timer is fired. This ultrasonic wave travels to the destination and reflects back to HR-S04, at which point the timer is stopped. The speed of sound in air is assumed to be 334m/s, whereas the time is given by the timer value divided by two. The distance is calculated as the product of speed and time.

Upon running low on beverages, the vending machine sends out an email to the specified email address (can be changed by accessing the administrator part). This email consists of quantity of each beverage. To stop receiving emails, the email address can be changed to NA.

The administrator part of pi is accessed using settings button on top right corner of interface. The screen that follows immediately prompts the user for a four digit pin code. After correct pin is entered, the setting page is displayed which provides following options:
- Change pin
- Change drink name
- Change button position
- Change beverage price
- Change beverage slot
- Access logo codes
- Change email address

The python script is configured to run upon system start. The script begins when the boot process has been sufficiently completed. At this time, systemd executes and manages the python script. If the program is ever terminated, systemd will restart the script.

Project Video

The Vending Machine was successfully refurbished in this project and will be placed in the ECE department for use by people. The main component of this project was designing user interface using Tkinter on a python platform. Interfacing different sensors with raspberry pi and running all in parallel without threading was a major learning outcome.

  • No labels