Sunteți pe pagina 1din 68

Restaurant Automation

Final Year Project submitted to

National Institute of Technology, Agartala

for the award of the degree


of

Bachelor of Technology
by
Divya Trivedi(15UEC159)
Hima Sowndarya Obugari(15UEC055)
Ch. Sai Manish (15UEC062)
Vivek Kumar (15UEC072)
Navlit Kumar(15UEC071)

Under the Guidance of

Mr. Partha Kumar Deb


DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING NATIONAL INSTITUTE OF
TECHNOLOGY AGARTALA 2015-2019

i
DEDICATION

We would like to dedicate this report to our loving parents and teachers and lab
assistants who guided us and advised on our difficulties during this time span
and helped us throughout.
I also dedicate my work to my friends who helped me a lot throughout my Work.

ii
“All power is within you; you can do anything and everything.”

-Swami Vivekananda

iii
APPROVAL SHEET

This final year project report on Restaurant Automation by Divya, Hima,


Manish, Vivek and Navlit is approved for the degree of Bachelor of
Technology in Electronics and Communication Engineering Department.
Examiners
________________________

________________________

________________________

________________________

________________________

________________________

________________________

Supervisor (s)
________________________

________________________

________________________

Chairman
________________________

Date: ____________
Place: ____________

iv
DECLARATION

I declare that this written submission represents my ideas in my own


words and where others' ideas or words have been included, I have
adequately cited and referenced the original sources. I also declare that I
have adhered to all principles of academic honesty and integrity and have
not misrepresented or fabricated or falsified any idea/data/fact/source in
my submission. I understand that any violation of the above will be cause
for disciplinary action by the Institute and can also evoke penal action
from the sources which have thus not been properly cited or from whom
proper permission has not been taken when needed.

Divya Trivedi
(15UEC159)

Hima Sowndarya Obugari


(15UEC055)

Ch. Sai Manish


(15UEC062)

Navlit Kumar
(15UEC071)

Vivek Kumar
(15UEC072)

v
CERTIFICATE

It is certified that the work contained in this report titled “Restaurant


Automation” by “Divya Trivedi, Hima Sowndarya Obugari, Ch. Sai
Manish, Navlit Kumar, Vivek Kumar” has been carried out under my/our
supervision and that this work has not been submitted elsewhere for a
degree*

Signature of Project Guide Mr.Partha Kumar Deb, Department


of Electronics & Comm. Engg. N.I.T. Agartala May, 2019 *Note:
this statement is mandatory

vi
ACKNOWLEDGEMENT

During the entire course of our project, we had help and guidelines of our
respected guide, who deserve our greatest gratitude. The completion of
this report gave us much pleasure and we gathered a bunch of experience
and knowledge. We would like to hence show our gratitude to Mr. Partha
Kumar Deb, Assistant Professor, Department Electronics and
Communication, National Institute of Technology for giving us a good
guideline for project throughout numerous consultations. We would also
like to expand our deepest gratitude to all those who have directly and
indirectly guided us in every way. Many people especially our classmates
and team members itself have made valuable comments and suggestions
on this proposal which gave us an inspiration to improve our work. We
thank all the people for their help directly and indirectly to complete our
assignment.

Thank You

Name :

Place :

vii
CONTENTS

DEDICATION..................................................................................................................................ii

APPROVAL SHEET..........................................................................................................................iv

DECLARATION................................................................................................................................v

CERTIFICATE..................................................................................................................................vi

ACKNOWLEDGEMENT...................................................................................................................vii

CONTENTS...................................................................................................................................viii

LIST OF IMAGES.............................................................................................................................xi

ABSTRACT.....................................................................................................................................xii

Chapter 1:

INTRODUCTION 1

● 1.1 Overview 1
➔ 1.1.1 Why automation in restaurants? 1
➔ 1.1.2 How are restaurants transitioning towards automation? 2
➔ 1.1.3 Automation in front-of-house sites 2
➔ 1.1.4 Automation in restaurants back-of-house 2
➔ 1.1.5 Automated food delivery 3
● 1.2 Objectives 4
● 1.3 Idea 5

Chapter 2:

HARDWARE-RASPBERRY PI 6

● 2.1 Introduction to Raspberry pi 6


● 2.2 Capabilities of Raspberry pi 8
● 2.3 Scope of Raspberry pi 10

Chapter 3:

DESIGN METHODOLOGY 11

● 3.1 Idea of the project 11


● 3.2 Workflow 12

Chapter 4:

RASPBERRY PI AS ACCESS POINT 13

viii
● 4.1 Introduction to access point 13
● 4.2 Hostapd 14
● 4.3 Dnsmasq 14
● 4.4 Configuration for access point establishment 15
➔ 4.4.1 Setting Static ip 15
➔ 4.4.2 Configuring hostapd 16
➔ 4.4.3 Configuring dnsmasq 17

Chapter 5:

SETTING UP WEB SERVER 18

● 5.1 Introduction to NGINX 18


● 5.2 Installation and Configuration 19

Chapter 6:

PHP AS BACK-END LANGUAGE 24

● 6.1 Introduction to PHP 24


● 6.2 PHP-FPM 25
● 6.3 PHP-FPM Installation 25

Chapter 7:

MYSQL FOR DATABASE MANAGEMENT 28

● 7.1 Introduction to MySQL 28


● 7.2 MySQL Installation 29
● 7.3 Working on MySQL 29

Chapter 8:

LOGIN PAGE STRUCTURE 35

● 8.1 Files and their description 35


● 8.2 Algorithm for user data verification 36

Chapter 9:

FOOD MENU AND SHOPPING CART 38

● 9.1 Introduction 38
● 9.2 Sessions 38
● 9.3 File Structure 39

Chapter 10:

READING USER DATA STORED ON SERVER 41

● 10.1 Data stored in sessions on server 41


● 10.2 Process Flow 41

Chapter 11:

ix
CONCLUSION 43

Chapter 12:

FUTURE SCOPE 44

BIBLIOGRAPHY 45

x
LIST OF IMAGES

Image 1- Raspberry pi
Image 2- Workflow
Image 3- Command terminal with static ip
Image 4- Wi-Fi network
Image 5- Sign in page opens
Image 6- Sign in
Image 7- PHP test script
Image 8- Database creation
Image 9- Table creation
Image 10- Username and password entries
Image 11- Table
Image 12- Entries of items
Image 13- Login/ Sign in page
Image 14- Login successful page
Image 15- Add to cart
Image 16- View cart
Image 17- Deleted from cart
Image 18- Session file

xi
Abstract

This paper is about a technology that provides quick ordering system


inside the restaurant using restaurant’s Wi-Fi to the authenticated
customers. As customer gets connected to the hotel WiFi, a page will be
displayed to enter table number and password for authentication
purpose. During this time, he/she cannot access any sites other than
hotel’s menu page. As he/she completes the authentication, the menu
page will be displayed on his/her phone, through which the customer can
place the order. As the customer selects the dishes, it will be stored in the
cart, from which he/she can verify again and modify the quantity details
and then place the order. The ordered information is displayed on the
display in the kitchen through Wi-Fi for faster servicing without any delay.
The servicing is done by the restaurant personnel. Once the payment is
done by the customer, the ordered data will be stored in separate
database.

xii
0
Chapter 1

Introduction

1.1 Overview

1.1.1 Why automation in restaurants ?

The restaurant industry is no stranger to automation; from online


ordering to in-store kiosks and even a pancake-flipping robot chef, a
growing fleet of restaurants are embracing automation technologies in the
name of efficiency and cost control.

Today, nearly everything in your restaurant can be measured and


monitored. Thanks to big data, restaurateurs have unprecedented access
to business insights that can work in harmony with anecdotes or intuitions
to streamline operations, pinpoint opportunities, and improve the
customer dining experience.

So why is it, then, that the same savvy restaurateurs who invest in
accounting, restaurant point of sale software, or energy management
solutions often find themselves chained to their desks week after week,
spending as many as 8 hours trying to build the perfect schedule by hand?

Those who have worked under a pen-and-paper scheduling regime know


all too well the chaos caused by a communication slip-up or scheduling
mishap. Suddenly, your restaurant is understaffed, your team is
overworked, and your customers are underwhelmed…all because of a
misplaced sticky note restaurant industry is no stranger to automation.
The operational system is very tedious .Manual order placements with the
help of waiters have been carried out in restaurants. Menu card are
normally presented on to the customer out of whom he can select available

1
eatable items. All this process is cumbersome for customers from order
placement till bill payment.
Moreover, changing of menu cards or adding new items to menu, causes
problems for responsible persons to update menu cards frequently.
Therefore, existing system is time taking and requires a lot of human
effort. The existing system is non-computerized. Such manual systems
lead to problems because the waiter might not understand what the
customer had ordered therefore serving him/her a different menu. This
could be quite embarrassing as it will lead to customer dissatisfaction and
ruin of restaurant reputation.

1.1.2 How are restaurants transitioning towards automation?

With food assembly machinery set up at the back-of-house, kiosks


installed in the front along with self-driven vehicles to deliver the food –
there are endless automation possibilities for the restaurant sector. Yet,
instead of listing all the potential tasks that we only wish can be
automated, let us take a look at the processes that have all the chances of
getting automated in the coming years:

1.1.3 Automation in front-of-house sites

Automation in the front-of-house sites would not have a lot to do with the
installation of robots to take on basic tasks and would primarily be related
to substituting cashiers and servers with self-service kiosks. A number of
large-scale hospitality chains, such as McDonald's and Wendy's, are
actually starting to experiment with self-service kiosks in their eateries.
Although this continues to be in the testing stage, it can eventually turn
out to be a feature in each and every outlet if successful.
Furthermore, front-of-house automation is not restricted only to fast-food
facilities, as a number of notable fine-dine restaurant chains have adopted
automation as a part of their front-of-house sites.

1.1.4 Automation in restaurant’s back-of-house

2
Robots in restaurants are carrying out basic tasks that are repetitive in
nature, and this makes them ideal for the back-office management of
restaurants. Although this may appear to be more like science fiction,
there are now many real-life instances where robots are used in
restaurants as cooks in the kitchen. A Boston-based restaurant, named
Spyce, has been using robots in their kitchen and those robots manage
back-of-house tasks like fetching food from the refrigerator, prepping it,
cooking it, and also garnishing it prior to serving to the customers.

1.1.5 Automated food delivery

With the advancement in technology wherein cars can now be driven


without a driver or introduction of drone delivery, there are plenty of
lucrative opportunities for the restaurant sector with regards to updating
their delivery systems. Furthermore, food delivery has become an in-
thing, particularly with the increase in delivery-only food joints. In the
same way as robots in back-of-house, businesses have already begun
developing, testing, and determining how driverless food delivery can
work for restaurants.
For instance, a startup named Starship Technologies is known to
have tested the use of robots for delivering food from the restaurant to the
customer’s place. The company has programmed robots in such a way that
they use GPS and inbuilt cameras for navigating the sidewalks that lead to
the customer’s location. These robots also have an in-built, insulated
compartment wherein the food can be placed. Robots use smart
technology to recognize traffic signals, signposts, crosswalks as well as
pedestrians. As soon as the robot arrives at its destination, it can be
unlocked using a mobile application, and the customer thereafter can
obtain the food they’d ordered.
Despite the fact that this technology is incredible and quite advanced, it
presently works in a hyper-local region since the robots are only able to
travel at 4 miles/hour. Therefore, do not count on making deliveries
across the entire city with the help of robotics technology just yet.
Automation in restaurants is going to transform the sector as well as the
workforce entirely; nevertheless, the technology remains a couple of years

3
off. The majority of the restaurants involved in developing prototypes or
attempting to make use of robots in their franchises are large-scale
businesses. They have a considerable amount of money to pay for research
and innovation, therefore it is going to take a couple of years before they
have mastered the concept for robots and are able to introduce them to
the mainstream and make them available to regular eateries. Although
this technology is still in its growing stage, it is important to be completely
aware of it and the way it could impact your restaurant, so you can be
prepared to take your restaurant to the next level in the near future.

1.2 Objectives

1.) To reduce the monthly cost paid to employees. This will reduce the
overall cost paid by the owner from his income and ultimately lead to
better resources.
2.) Reduce mistake made by waiters. Sometimes waiters misinterpreting
the order and missing the quantity are not an uncommon sight. With the
help of this system this can be minimized.
3.) Reduce labour into minimum needed. The only labour required with
this system will be labour required at the backend side examples cooks.
4.) Increase customer comfortability. The customer can take his/her own
time to comfortably analyse the menu and order the food accordingly

4
1.3 Idea

The idea of the project was to automate the management or handling of


orders in a restaurant making use of local area wifi. Here the customer
would enter the restaurant and connect to the wifi , after which a popup
would allow them to sign-in using the table credentials.
The login credentials are pre-stored on the database so when customer
logs in this is checked , if credentials are matched the customer will be
redirected to products page . The products on the product page are
displayed after fetching it from the database. Now the customer can order
suitable to his/her need and this data is session variable data. The cart
products or ordered products data is saved on the server in a form of file
which can be read to know the order made by customer on cook’s side.
This way the whole transaction works

5
Chapter 2

Hardware: Raspberry pi

2.1 Introduction to raspberry pi

The raspberry pi is a series of small single-board computers developed in


the United Kingdom by the Raspberry Pi Foundation to promote teaching
of basic computer science in schools and in developing countries. All the
models of raspberry feature Broadcom system on a chip (SoC) with an
integrated ARM-compatible central processing unit (CPU) and on-chip
graphics processing unit (GPU).

Image 1. Raspberry pi

Raspberry pi 3 model was released in February, 2016 with the following


features:

● CPU: Quad-core 64-bit ARM Cortex A53 clocked at 1.2 GHz


● GPU: 400MHz VideoCore IV multimedia
● Memory: 1GB LPDDR2-900 SDRAM (i.e. 900MHz)

6
● USB ports: 4
● Video outputs: HDMI, composite video (PAL and NTSC) via 3.5
mm jack
● Network: 10/100Mbps Ethernet and 802.11n Wireless LAN
● Peripherals: 17 GPIO plus specific functions, and HAT ID bus
● Bluetooth: 4.1
● Power source: 5 V via MicroUSB or GPIO header

Raspberry Pi can be plugged into a TV, computer monitor, and it uses a


standard keyboard and mouse. It is user friendly as can be handled by all
the age groups. It does everything you would expect a desktop computer
to do like word-processing, browsing the internet spreadsheets, playing
games to playing high definition videos. It is used in many applications
like in a wide array of digital maker projects, music machines, parent
detectors to the weather station and tweeting birdhouses with infrared
cameras.
The Raspberry Pi Foundation provides Arch Linux ARM and Debian
distributions for download, and promotes Python as the main
programming language, with support for BBC BASIC, Java, C, Perl,Ruby,
PHP, Squeak Smalltalk, C++, etc.

7
2.2 Capabilities of raspberry pi

● Budget desktop
The Pi can be run as a budget desktop, providing you have the patience.
However, don't expect the Pi 3 to match a typical PC, it will lag loading
heavier websites and, when browsing these demanding sites, having more
than a handful of tabs open at once runs the risk of overloading the Pi's
memory--causing a lengthy freeze.
● Media Center
There are various options if you want to use the Pi 3 as a media center but
the most popular choices are the Kodi-based OSes OSMC or LibreElec.
The Pi 3 has the added advantage of a slightly faster graphics processor,
which the Raspberry Pi Foundation has said is able to play local H.264-
encoded video recorded at 1920x1080 resolution and 60 frames per
second. Another advantage is built-in support for Wi-Fi makes it easier to
stream content to the Pi, while native Bluetooth simplifies the hooking up
peripherals.
● Retro games console
A wide range of vintage games will run on the Pi with the help of emulators
like RetroPie, including some games from all of the systems listed above,
although the more recent the system, the more likely it is that more
demanding titles will struggle.
● Router
Raspberry Pi comes with wireless capabilities already on board. It can take
the place of a ton of different (and more expensive) devices – including a
router! If you turn your Raspberry Pi into a wireless access point, you can
make it act as a router.
● WiFi and Bluetooth device
Raspberry pi 3 comes with WiFi and bluetooth connectivity, where one
can access to internet as well connect to other devices very easily using
raspberry pi.

● Can run different operating systems

8
The Pi can run the official Raspbian OS, Ubuntu Mate, Snappy Ubuntu
Core, the Kodi-based media centers OSMC and LibreElec, the non-Linux
based Risc OS (one for fans of 1990s Acorn computers). It can also run
Windows 10 IoT Core, which is very different to the desktop version of
Windows, as mentioned below. However, these are just the officially
recommended operating systems, and a large array of other weird and
wonderful OSes also work on the Pi.

9
2.3 Scope of raspberry pi

Raspberry pi was once only hoped for the device to make computer science
appealing to young students. However, with millions of sales in just a few
years, IT experts and enthusiasts discovered many more use cases for the
mini computer. Today, one can use it for multiple projects such as
robotics, home automation and building a mini web browser or living
room PC.
Essentially, the Raspberry Pi makes sense as a VDI solution for SMBs
where the user base mainly consists of task workers. It functions
effectively as an embedded systems platform that can be configured to run
tasks without codec decompression. Any company with a modest IT
budget can use Raspberry Pi as a Thin Client and it is a safety net for those
that start small. This is a plus point for all the aspiring and upcoming
entrepreneurs out there. One can use it to initiate small-scale projects with
low computational power with just a few simple clicks. For these reasons,
the Raspberry Pi’s adoption rate shows great promise in the future and we
expect more computational experimentations to be carried out with this
device.
In keeping up with virtualization market trends, ClearCube has launched
the new C3Pi+ Raspberry Pi 3 Model B+ Thin Client which integrates
VMware Blast Extreme for virtual desktops and applications. It
dynamically increases the Thin Client device’s processor and network
speed and adds extra Wifi bands for further deployment opportunities.
Furthermore, the C3Pi+ includes a 2.4 GHz processor that offers users
faster response, improved video decoding and clearer images. Taking all
this into consideration, we can safely say that there is a lot more to expect
from this Thin Client model in the years to come.

10
Chapter 3

Design methodology

3.1 Idea of the project

The idea of the project was to automate the management or handling of


orders in a restaurant making use of local area wifi. Here the customer
would enter the restaurant and connect to the wifi , after which a popup
would allow them to sign-in using the table credentials.
The login credentials are pre-stored on the database so when customer
logs in this is checked , if credentials are matched the customer will be
redirected to products page . The products on the product page are
displayed after fetching it from the database. Now the customer can order
suitable to his/her need and this data is session variable data. The cart
products or ordered products data is saved on the server in a form of file
which can be read to know the order made by customer on cook’s side.
This way the whole transaction works.

11
3.2 Workflow

Image 2. Workflow

12
Chapter 4

Raspberry Pi as Access Point

4.1 Introduction to access point

A wireless access point (WAP) is a hardware device or configured node on


a local area network (LAN) that allows wireless capable devices and wired
networks to connect through a wireless standard, including Wi-Fi or
Bluetooth. WAPs feature radio transmitters and antennae, which facilitate
connectivity between devices and the Internet or a network.
A WAP is also known as a hotspot.
Wireless access points (WAP) may be used to provide network
connectivity in office environments, allowing employees to work
anywhere in the office and remain connected to a network. In addition,
WAPs provide wireless Internet in public places, like coffee shops, airports
and train stations.
Wireless access points are most commonly thought of in the context of the
802 series of wireless standards, commonly known as Wi-Fi. While there
are other wireless standards, the vast majority of the time the terms Wi-
Fi hotspot and WAP are synonymous.
In our project we will configure raspberry pi as wifi node and make
raspberry pi acts as wifi access point.

13
4.2 Hostapd

Hostapd is a user space daemon for access point and authentication


servers. It implements IEEE 802.11 access point management. Hostapd is
designed to be a "daemon" program that runs in the background and acts
as the backend component controlling authentication. hostapd supports
separate frontend programs and an example text-based frontend,
hostapd_cli, is included with hostapd.
This service lets pi to accept wireless connections from devices such as
phones or laptops etc. This is daemon service, so it is started when PI is
booted up and runs in the background.
When this service is running it does not let pi connect to wifi and Wifi is
turned off.

4.3 Dnsmasq

Dnsmasq provides network infrastructure for small networks: DNS,


DHCP, router advertisement and network boot. It is designed to be
lightweight and have a small footprint, suitable for resource constrained
routers and firewalls. It has also been widely used for tethering on
smartphones and portable hotspots, and to support virtual networking in
virtualisation frameworks. Supported platforms include Linux (with glibc
and uclibc), Android, *BSD, and Mac OS X. Dnsmasq provides full IPv6
support. Dnsmasq is a lightweight, easy to configure, DNS forwarder and
DHCP server. It is designed to provide DNS and optionally, DHCP, to a
small network. It can serve the names of local machines which are not in
the global DNS. The DHCP server integrates with the DNS server and
allows machines with DHCP-allocated addresses to appear in the DNS
with names configured either in each host or in a central configuration
file.
Here we have configured the name of our wifi to be “Welcome Buddy” with
password as “now you get it”.

14
4.4 Configuration for access point establishment

4.4.1 Setting static ip

Since the Raspberry Pi will be the DHCP server on the wireless network,
we need to assign a static IP address to its wireless adapter.
For setting up static ip we need to edit interface file found at
/etc/network/interfaces file and configure wlan0 setting to set up static ip
address as 198.162.1.1
Now typing ifconfig on command terminal we can see the ip address has
been changed to static ip address.

Image 3. Command terminal with static ip

15
4.4.2 Configuring hostapd

Hostapd is software that allows the Raspberry Pi to accept wireless


connections from clients. We need to build its configuration file for our
network.
Configuration file can be found at
/etc/hostapd/hostapd.conf
After configuring and restarting the hostapd service you should get

Image 4. Wi-Fi network

16
4.4.3 Configure dnsmasq

Dnsmasq is software that assigns IP addresses to devices when they


connect to the network (DHCP) and resolves host names to IP addresses
(DNS). Here we will be making few changes in terms of defining our
network so that it assigns proper ip address to devices connected to pi.
So now we need to save the new file with appropriate configuration at this
place
/etc/dnsmasq.conf

17
Chapter 5

Setting up web server

5.1 Introduction to NGINX

NGINX is open source software for web serving, reverse proxying,


caching, load balancing, media streaming, and more. It started out as a
web server designed for maximum performance and stability. In addition
to its HTTP server capabilities, NGINX can also function as a proxy server
for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer
for HTTP, TCP, and UDP servers.
The goal behind NGINX was to create the fastest web server around, and
maintaining that excellence is still a central goal of the project. NGINX
consistently beats Apache and other servers in benchmarks measuring
web server performance. Since the original release of NGINX however,
websites have expanded from simple HTML pages to dynamic,
multifaceted content. NGINX has grown along with it and now supports
all the components of the modern Web, including WebSocket, HTTP/2,
and streaming of multiple video formats (HDS, HLS, RTMP, and others).
NGINX Plus and NGINX are the best-in-class web server and application
delivery solutions used by high-traffic websites such as Dropbox, Netflix,
and Zynga. More than 358 million websites worldwide, including the
majority of the 100,000 busiest websites, rely on NGINX Plus and NGINX
to deliver their content quickly, reliably, and securely.
● NGINX makes hardware load balancers obsolete. As a software-only
open source load balancer, NGINX is less expensive and more
configurable than hardware load balancers, and is designed for
modern cloud architectures. NGINX Plus supports on-the-fly
reconfiguration and integrates with modern DevOps tools for easier
monitoring.

18
● NGINX is a multifunction tool. With NGINX, you can use the same
tool as your load balancer, reverse proxy, content cache, and web
server, minimizing the amount of tooling and configuration your
organization needs to maintain. NGINX offers tutorials, webinars,
and a wide array of documentation to get you on your feet.
NGINX Plus includes rapid-response customer support, so you can
easily get help diagnosing any part of your stack that uses NGINX or
NGINX Plus.
● NGINX keeps evolving. For the past decade NGINX has been at the
forefront of development of the modern Web, and has helped lead
the way on everything from HTTP/2 to microservices support. As
development and delivery of web applications continue to evolve,
NGINX Plus keeps adding features to enable flawless application
delivery, from the recently announced support for configuration
using an implementation of JavaScript customized for NGINX, to
support for dynamic modules. Using NGINX Plus ensures you’ll stay
at the cutting edge of web performance.

5.2 Installation and Configuration

Nginx can host multiple sites, and each one requires its own
configuration file. The configuration file tells nginx where the files for
the site are located and how to handle client requests. We need to create
a new configuration file for our site:
/etc/nginx/sites-available/mysite.conf

Here are the things to be written in the above file

server {
# Listen for requests over both HTTP and HTTPS
listen 80;
listen [::]:80;

19
#listen 443 ssl;
#listen [::]:443;
# Present a friendly name to the client, instead of an IP
address
server_name download.localnet;
#Include HTTPS configuration from the snippets directory
#include snippets/self-signed.conf;
#include snippets/ssl-params.conf;

root /usr/share/nginx/html/download;

index download.html index.html index.htm index.nginx-


debian.html;

# Redirect requests for /generate_204 to open the captive


portal screen
location /generate_204 {
return 302 http://download.localnet/download.html;
}
# Redirect requests for files that don't exist to the
download page
location / {
try_files $uri $uri/ /download.html;
}
}
Note the statement location /generate_204 on line 18. When an
Android phone connects to our hotspot it will send a request to
http://connectivitycheck.android.com/generate_204 to test if it has a
connection to the Internet. If it receives a redirect response, then a

20
notification will appear on the phone asking the user to sign in via the
captive portal.
Dnsmasq resolves connectivitycheck.android.com to the IP address of our
Raspberry Pi and nginx receives the phone’s request for generate_204.
We have configured nginx to return code 302 (redirect) when a request
for generate_204 comes in. This will cause the phone to display a
notification to sign into the network.
Activate the new site by creating a link to it in the sites-
enabled directory:
sudo ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-
enabled/mysite.conf
Deactivate the default nginx site to prevent conflicts:
sudo rm /etc/nginx/sites-enabled/default
Restart the server for the changes to take effect:
sudo service nginx restart
If you reconnect to the hotspot, you should receive a notification to sign
in:

21
Image 5. Sign in page opens

When you tap the notification, it should take you to the captive portal
and display our custom page:

22
Image 6. Sign in

23
Chapter 6

PHP as backend language

6.1 Introduction to PHP

PHP is a general purpose programming language mostly used in web


development. It is also known as server side scripting language. PHP is
usually used developing static and dynamic websites

PHP means - Personal Home Page, but it now stands for the recursive
backronym PHP: Hypertext Preprocessor. Only after installing PHP the
PHP scripts can be interpreted.
Web browser is the only requirement for the client systems to access PHP
scripts.
A PHP file contains PHP tags and ends with the extension ".php".
PHP code can be embedded into HTML code, as well an be combined with
various web template systems, web content management system and web
frameworks.

Though there are number of programming languages, we would want to


use PHP as our poison for the web programming because of the following
major reasons:
● PHP is open source and free.
● it’s a server side scripting language; this means you only need to
install it on the server and client computers requesting for resources
from the server do not need to have PHP installed; only a web
browser would be enough.

24
● PHP is cross platform; this means you can deploy your application
on a number of different operating systems such as windows, Linux,
Mac OS etc.
● PHP has in built support for working hand in hand with MySQL
● PHP can also be used to work with other database management
systems like Oracle, Postgres, ODBC, etc

6.2 PHP-FPM

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI


implementation with some additional features useful for sites of any size,
especially busier sites.These features include adaptive process spawning,
advanced process management with graceful stop/start, ability to start
workers with different uid/gid/chroot/environment and different php.ini
(replaces safe_mode), stdout & stderr logging, emergency restart in case
of accidental opcode cache destruction, accelerated upload support,
support for "slowlog", enhancements to FastCGI such as
fastcgi_finish_request() - a special function to finish request & flush all
data while continuing to do something time-consuming (video converting,
stats processing, etc.)

6.3 PHP-FPM installation

The following steps can be followed one after other so as to install php on
our Raspberry pi
● Initially PHP-FPM can be installed by the command sudo apt-get
install php-fpm
● Go to the default file in the sites-enabled folder of nginx where the
following line is found, index index.html index.htm;
which is edited as index index.php index.html index.htm;
● In the same file find the following portion
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

25
#
# location ~ \.php$ {
Remove the # in the following lines so as to look like
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
Now makes changes as shown below
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;

# With php-cgi alone:


# fastcgi_pass 127.0.0.1:9000;
# With php-fpm:
fastcgi_pass unix:/var/run/php-fpm.sock;
}
● Reload the configuration file
Hence, PHP-FPM is successfully installed.
The installed PHP-FPM can be tested. It can be done by the following
process:
● Go to cd /var/www/html/
● Rename index.nginx-debian.html to index.php using the command
sudo mv index.nginx-debian.html index.php
● Open index.php with a text editor using the command sudo nano
index.php
● Add some dynamic PHP content by replacing the current content
like

26
<!DOCTYPE html>
<html>
<body>

<?php
echo "My first PHP script!";
?>

</body>
</html>
● Now, open the index.php file using browser where we can find the
image as follows

Image 7. PHP test script

27
Chapter 7

MySQL for database management

7.1 Introduction to MySQL

MySQL is the most popular Open Source Relational SQL Database


Management System. SQL here stands for Structured Query Language.
MySQL is one of the best RDBMS being used for developing various web-
based software applications. MySQL is developed, marketed and
supported by MySQL AB, which is a Swedish company. With its proven
performance, reliability, and ease-of-use, MySQL has become the leading
database choice for web-based applications, used by high profile web
properties including Facebook, Twitter, YouTube, and all five of the top
five websites. Additionally, it is an extremely popular choice as embedded
database.

MySQL is based on a client-server model. The core of MySQL is MySQL


server, which handles all of the database instructions (or commands).
MySQL server is available as a separate program for use in a client-server
networked environment and as a library that can be embedded (or linked)
into seperate applications.

MySQL enables data to be stored and accessed across multiple storage


engines. MySQL is also capable of replicating data and partitioning tables
for better performance and durability. MySQL users aren't required to
learn new commands; they can access their data using standard SQL
commands.

MySQL is written in C and C++ and accessible and available across over
20 platforms, including Mac, Windows, Linux and Unix. The RDBMS
supports large databases with millions records and supports many data

28
types including signed or unsigned integers 1, 2, 3, 4, and 8 bytes long;
FLOAT; DOUBLE; CHAR; VARCHAR; BINARY; VARBINARY; TEXT;
BLOB; DATE; TIME; DATETIME; TIMESTAMP; YEAR; SET; ENUM;
and OpenGIS spatial types. Fixed- and variable-length string types are
also supported.

7.2 MySQL installation

MySQL can be installed by a simple command as follows sudo apt-get


install mysql-server. During the installation, you’ll be asked to set a root
password.
sudo mysql_secure_ installation
In this stage, you’ll have the option to change your root password, you
might as well say no if you do not want to have one. In all the others yes
must be chosen.

Thus, MySQL server is successfully installed

7.3 Working on MySQL

Firstly, go to the web browser on the pi and open


http://localhost/phpmyadmin/ where one can find phpMyadmin page.
Here, clicking on user accounts would show an option where a user
account can be created and one may choose whether to have a password
or not and privileges are chosen. Then, a database can be created by going
to databases and can create one by just giving a name to it and adding
privileges. A database can hold multiple tables which can be used for
different purposes like storing the username and passwords, list of the
items chosen by a customer, items to be displayed on the shopping cart
etc.

29
Image 8. Database creation

A table can be created for storing usernames and their respective


passwords by writing the below mentioned code in the SQL of the
database created.

CREATE TABLE `users` (


`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
)

The table is then provided with different values of username and


respective password which are unique for each table of the restaurant
where they are displayed. This can done by going to insert of the table
created and adding the values of usernames and passwords.

30
Image 9. Table creation

They can be provided as follows:


Entry 1: ID: 01, Username: Table1, Password: ********
Entry 2: ID: 02, Username: Table2, Password: ********
Entry 3: ID: 03, Username: Table3, Password: ********

31
Image 10. Username and password entries

Similarly, another table is created in the database to mention the items


those can be served, this may be created in the same procedure with
additional columns.

CREATE TABLE IF NOT EXISTS `products` (


`id` int(11) NOT NULL AUTO_INCREMENT,
`product_code` varchar(60) NOT NULL,
`product_name` varchar(60) NOT NULL,
`product_desc` tinytext NOT NULL,
`product_img_name` varchar(60) NOT NULL,
`price` decimal(10,2) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `product_code` (`product_code`)
) AUTO_INCREMENT=1 ;
In this table the entries would be the food items those are available to
serve in the restaurant which are updated by the owner according to the
resources.

32
Image 11. Table

Entries can be as follows:


Entry 1: ID: 01, Product code: 001, Product name: XXXXXX, Product
description: xxxxxxxxxxxxxx, Product image name: YYYYY.jpg, Price: Rs.
yyy
Entry 2: ID: 02, Product code: 002, Product name: XXXXXX, Product
description: xxxxxxxxxxxxxx, Product image name: YYYYY.jpg, Price: Rs.
yyy

33
Image 12. Entries of items

More tables can be created in the same database for less chaotic working
as well as editing.

34
Chapter 8

Login page structure

8.1 Files and their description

Here login page will be created in HTML , CSS and backend support
from php and mysql database for data storage.

download.html
|
assets
├─── css
├────── style.css
api
├─── config/
├────── DBM.php
├─── objects/
├────── USR.php
├─── User/.
├────── login.php

download.html – This is the file that contains code in html language


that will show up when the popup arises on connecting to wifi.
Style.css-This is the file that contains code in css language that will make
our login page more appealing in terms of writing style, font size,
background, text colour, padding etc.
Usr.php- This contains the definition of user functions or methods and
properties for “user” database queries.

35
Login.php- The file that will accept username & password from the user
and validate.

NOTE- This file Index.html along with all the folders should be saved in
/usr/share/nginx/html/download

8.2 Algorithm for user data verification

1.User enters data into the login page (username-tablenumber &


password –xxxxxxxx).
2. “Submit button” sends the data to login.php file.
3.login.php file includes DBM.php file which opens connection to
database mysql.
4. From there validation of username and password is done.
5. If username and password is correct.

The login/signup page looks like this

Image 13. Login/ Sign in page

36
After putting username and password as “table1” and “table1”
respectively, we will be able to login.

Image 14. Login successful image

37
Chapter 9

Food menu and shopping cart

9.1 Introduction

Once the user successfully enters the username and password and it is
correctly verified, food menu will be displayed to user. The data item
present in the restaurant will be saved in another table in mysql
database. Food database is fetched from the database and displayed on
webpage. When the user want to order some item, he has to select it and
put in the cart.

9.2 Sessions

An alternative way to make data accessible across the various pages of an


entire website is to use a PHP Session.
A session creates a file in a temporary directory on the server where
registered session variables and their values are stored. This data will be
available to all pages on the site during that visit.
The location of the temporary file is determined by a setting in
the php.ini file called session.save_path. Before using any session
variable make sure you have setup this path.
Here we will be making use of session in order to store username and
cart products to be saved across pages and also to store on server. This
data saved on server is read in order to determine the food products
ordered.
This data can be read and displayed on screen to intimate the cook of
next order.

38
9.3 File Structure

These files should be saved in /usr/share/nginx/download


download/
├─── config.php
├─── index.php
├──- cart_update.php
├──- view_cart.php

Image 15. Add to cart

39
Image 16. View Cart

Image 17. Deleted from Cart

40
Chapter 10

Reading user data stored on server

10.1 Data stored in sessions on server

When a session is started following things happen −


● PHP first creates a unique identifier for that particular session
which is a random string of 32 hexadecimal numbers such as
3c7foj34c3jj973hjkop2fc937e3443.
● A cookie called PHPSESSID is automatically sent to the user's
computer to store unique session identification string.
● A file is automatically created on the server in the designated
temporary directory and bears the name of the unique identifier
prefixed by sess_ ie sess_3c7foj34c3jj973hjkop2fc937e3443.
When a PHP script wants to retrieve the value from a session variable,
PHP automatically gets the unique session identifier string from the
PHPSESSID cookie and then looks in its temporary directory for the file
bearing that name and a validation can be done by comparing both values.
A session ends when the user loses the browser or after leaving the site,
the server will terminate the session after a predetermined period of time,
commonly 30 minutes duration.

10.2 Process flow

1. Migrate to /xxxxxxxxxxxxxxxxxx during session is active


2. Type
Sudo ls /xxxxxxxxxxxx

41
Here you will get the name of session file generated
3. Type
Sudo nano sessionfilename

Now you can watch the contents of file and see all the cart products from
the user.

Image 18. Session file

42
Chapter 11

Conclusion

Henceforth integrated system has been devised where customer comes to


the restaurant and orders the food.
This food data can be read on the servers in the form of session data. This
was achieved with the help of services such as hostapd, dnsmasq, nginx
and languages such as php,mysql,html.
The advantage of the system where only one hardware component
Raspberry pi is able to handle all the services such as providing access
point connectivity and running a web server and handling database and
queries from user.
There will be no additional cost in handling the web server apart from the
cost of hardware.

43
Chapter 12

Future scope

The project can be developed in various dimensions to improve the


functionality, features and security of the system. Various algorithms
available can be used to improve the request handling capability of the
system. QR code generation or unique code for each table can be
introduced into the system. Online gateway might be introduced to
facilitate the customer as well as reduce the responsibility on the manager.
This way automation can prove itself as major replacement of waiter in
food ordering sector.
Nowadays importance is given to the wireless technology and automation
system. To match the world’s fast-growing scenario of emerging
technologies there is a need for the innovative methods in every aspect of
the life creating wide opportunities. Digital India campaign has been
launched by the Government of India which aims at smart cities with the
intension of binding every field with the smarter technologies. Earlier,
costlier interface devices like touchpad’s and PDAs (Personal Digital
Assistants) were used, which makes installation costlier. Application
based services needs to be pre-installed; this also annoys the customers
with advertisements.
Restaurant operations need to be simplified. No doubt about that. As a
restaurant grows, we need to ensure that a system takes care of all our
operational chores. Particularly if we have outlets across the city and
outside, we will need to be constantly on top of our data at all times. This
makes the need of automation prominent in this sector.

44
Bibliography

● Wikipedia.org
● softwaresuggest.com
● businessinsider.in
● Codeofninja.com
● Codinginfinite.com
● Pimylifeup.com
● Stewright.me
● Sanwebe.com
● Brennham.com
● W3schools.com
● Tutorialspoint.com
● Stackoverflow.com
● Raspberrypi.org

45
46

S-ar putea să vă placă și