Professional Documents
Culture Documents
PSM 2 - Final Report - Nagace180100
PSM 2 - Final Report - Nagace180100
NAGALINGESWARAN ARMUGAM
JUNE 2022
ii
I hereby declare that the work in this thesis is my own except for quotations and
summaries which have been duly acknowledged
Student : ..............................................................
NAGALINGESWARAN ARMUGAM
Date : ..............................................................
Supervisor : ..............................................................
Dr. JONG SIAT LING
iii
ACKNOWLEDGEMENT
Foremost, I would like to acknowledge the Almighty God for His benevolence and
for granting me wisdom and perseverance not only in the time of research and
writing of this thesis, but indeed, throughout my life. I express, with heartfelt
appreciation, my gratitude to my supervisor, Dr Jong Siat Ling for her sincere and
invaluable intellectual guidance extended to me throughout the years of my
postgraduate studies. My sincere appreciation goes to the Ministry of Education
Malaysia and Universiti Tun Hussein Onn Malaysia for providing me with financial
support. I extend my appreciation to all my friends for their unwavering support and
who have stood by me through so many tough times. Last but not least, special
thanks to my beloved parents for their blessings and unflinching insistence, who have
always encouraged me to never stop achieving my goals in life.
iv
ABSTRACT
Yoga is a beneficial form of exercise that focuses on physical, mental, and spiritual
connections. Yoga, on the other hand, can lead to health issues such as muscle
sprains and soreness if done incorrectly. In this aim, I have proposed an E-Health
Yoga Mat Using Raspberry Pi. This project uses Raspberry Pi as a micro controller
and has 5 Force Sensitive Resistor sensors on the yoga mat which interface with the
Raspberry Pi. Using the sensors on the mat, the user will be able to detect the weight
of the body as well. When the user performs the wrong posture on the mat, there will
be a buzzer to alert the user. The data and information collected will be stored in
the Blynk Application for reference purposes and able to access the Raspberry Pi
from our hand phone using this Application. The study presented a yoga posture
guiding system on the mat, based on the GUI interfaced with the Phyton coding in
Raspberry Pi. Yoga posture performed by the user will be in real-time, according to
the yoga posture guidance, and can teach them to avoid wrong postures as well.
v
ABSTRAK
Yoga adalah bentuk latihan yang bermanfaat yang memfokuskan pada hubungan
fizikal, mental, dan rohani. Yoga, sebaliknya, boleh menyebabkan masalah kesihatan
seperti keseleo otot dan sakit jika dilakukan dengan tidak betul. Untuk tujuan ini,
saya telah mencadangkan E-Health Yoga Mat dengan menggunakan Raspberry Pi.
Projek ini menggunakan Raspberry Pi sebagai pengawal mikro dan mempunyai lima
penderia perintang sensitif daya pada tikar yoga yang bersambung dengan Raspberry
Pi. Dengan menggunakan sensor pada tikar, pengguna juga dapat mengesan berat
badan. Apabila pengguna melakukan postur yang salah di atas tikar, pembunyi
isyarat akan diaktifkan untuk memberi amaran kepada pengguna. Data dan maklumat
yang dikumpulkan akan disimpan di Aplikasi untuk tujuan rujukan dan dapat
mengakses Raspberry Pi dari telefon bimbit kami menggunakan Aplikasi ini. Kajian
ini mengkaji sistem panduan postur yoga di tikar, berdasarkan GUI yang
dihubungkan dengan pengekodan Phyton di Raspberry Pi. Postur yoga yang
dilakukan oleh pengguna akan berada dalam waktu nyata, sesuai dengan panduan
postur yoga, dan dapat mengajar mereka untuk menghindari postur yang salah juga.
vi
CONTENTS
TITLE i
DECLARATION ii
ACKNOWLEDGEMENT iii
ABSTRACT iv
ABSTRAK v
CONTENTS vi
LIST OF TABLES x
LIST OF FIGURES xi
CHAPTER 1 INTRODUCTION 1
3.1 Introduction 43
3.2 Working Plan 44
3.3 Project Flow 44
3.4 Block Diagram 47
viii
4.1 Overview 63
4.2 Hardware and Software Findings 63
4.2.1 Sensor Connection 64
4.2.2 Design and Assembly 65
4.2.3 Multiple Sensor Connection Testing 66
4.2.4 Display 68
4.2.5 Application 68
4.3 Result 71
CHAPTER 5 CONCLUSION 76
5.1 Overview 76
5.2 Conclusion 76
5.3 Recommendation for future work 77
REFERENCES 78
APPENDIX 79
ix
LIST OF TABLES
LIST OF FIGURES
LIST OF APPENDICES
INTRODUCTION
A day with 24 hours is not enough for many of us because of the workload and
busy schedule we are having in our daily life. As we commit ourselves to work and
the deadline we have on the work keeps us busy all day. The time that we spent on
ourselves is getting lesser and lesser day by day. Most importantly, to keep us going
with our busy schedule on daily basis is our health, mentally and physically. As some
of us are busy with work and other things, we focus less on our health. It is still
possible to focus on our goals and achievements while maintaining good health.
There are many ways to maintain our body health, both physically and mentally. As
an example schedule our timetable with daily work, consuming healthy food, self-
discipline, and many more. Nonetheless, to maintain good body health we need to
keep up on our exercise and stretching for a better performance to reach our goal and
keep up good energy in our body and mental as well.
The easiest and more efficient way to keep good mental health and body health
is by performing yoga which was advised by our ancients. Yoga is body and mind
practice, with various styles such as breathing techniques, physical posture, and
meditation. To perform yoga, more practice and many disciplines within the practice
are needed. The benefit of yoga is endurance, calmness, strength, flexibility,
concentration, and well-being. By performing the right yoga, able to build muscle
together with strength, enhance our body flexibility, promote better breathing to keep
up the mind always awake, supports the health of the heart, help in the treatment of
addictions, improve the quality of sleeping time, reduce stress and reduce chronic
2
pains as well. To gain all these benefits, should perform the right yoga. As in our
busy schedules, not every one of us can make time to attend classes and hit the gym.
This project is designed to maintain our body and mental health on good terms
with the right guidance. The project is implemented in Raspberry Pi and attached
with a yoga mat to guide the correct yoga postures. This project guides the user on
yoga and also keeps track of the body health on daily basis on the mobile phone.
In the modern era,the interaction between humans and physical devices in the
real world is gaining more attention and requires a natural and intuitive methodology
to employ. According to this idea, living well has been a growing demand. Moreover,
spending time on ourselves is getting less day by day as the daily workload with
deadlines is occupied in our daily routine. In this busy period, keeping some time to
spend on our body's health is very important, and not most of us can attend classes to
maintain body health, go to the gym, or do other activities. In this recent pandemic
period, we have not been able to spend time outside either. Sometimes it’s not easy
when we learn without a proper guide, and there will be many obstacles we have to
overcome during that learning period. Some of us refer to YouTube videos and ask
for help from others. Nonetheless, these traditional ways sometimes do not provide
the right benefit or it’s hard to understand when trying to figure it out on your own.
Moreover, not every one of us knows the right way of getting the correct exercises,
and sometimes advice or misguided will lead to some other problems. Therefore, an
E-Health Yoga Mat is proposed to safe more time of the user by performing yoga on
the mat to keep mind, breathing and mental health in good terms. This E-Health
Yoga Mat can guide the user to perform yoga postures on the mat itself using an
application which is android access also.
In addition, the yoga mat have sensors that is more efficient to detect the users
pressure and send signal to Arduino Pro mini to convert signal to digital and finally
send data to display and buzzer. Having a home assistance device that is able to
3
guide you to keep up good health, both mentally and physically, will be very
beneficial and efficient. As such, the device will save time and help you learn on
your own with the proper guide. The E-Health Yoga Mat has features to guide the
correct yoga postures on the yoga mat. Then, it is also able to detect any wrong
movements and send an alert to the user to re-correct the posture. The data will be
collected in our phone application to keep track of our exercises. It also has the
feature of reading the user’s body weight and keeping data as well. This device
makes our time more efficient and guides us to a healthy lifestyle both physically and
mentally to achieve our goals and achievements.
1.3 Hypothesis
As we are more busy in this modern world with our work and goals, we tend to
forget or not enough time to take care on our body. If planned to go for gym, outdoor
activities and classes to maintain body health, we need separate time for it. When
there is not much time for us to focus on our health, having a guide at home will be
more way easier and saves up more time. In this research, an E-health Yoga Mat
using Raspberry Pi is developed that help to guide us at home to keep fit and keep
track on our body health. E-Health Yoga Mat using Raspberry Pi is the perfect home
guide system to maintain our body health and mental health as well. If there is a
home guide system, there is no need to keep separate time to go for outdoor activities
or gym. Moreover, having this home guide system, saves more time and help us to
keep fit physically and mentally at the same time. The outcome of this project will be
maintaining the user’s good health, alert the user when they perform the wrong
posture, keep track of our body health with phone application as well.
1.4 Aim
1.5 Objective
Selected yoga postures will be uploaded in the Raspberry Pi interface with the
Phyton. The Force Sensitive Resistors will be attached on the yoga mat at five main
points. Few user’s will be tested on the yoga mat, to perform the yoga posture to
prove the outcome. Moreover, the user will be also tested with wrong moves on the
yoga mat, to check the alert system added in the project as a result the buzzer will
“beep” for the wrong posture on the yoga mat. As a result, The user is able to learn
the yoga posture while following the guidance shown on the TFT touch screen and
able to access the raspberry directly with touch and indirectly from the application
developed to access the microcontroller and also to store data.
The research on the E-Health Yoga Mat using Raspberry Pi, enable to provide a
guiding system for the user, In addition to that, it provides an alert system to the user
6
to make right the yoga posture as a learning process cause any wrong moves or
postures will give physical health issue. It also saves the data from the user of the
learning processes and also keep track on body fitness with the help of application in
the phone.
Chapter 1 gives the overview of the project for the microcontroller, Raspberry
Pi 4 Model B. Besides that, problem statement, objective of this project, scope of this
project and project outline will be presented in this chapter. From this chapter, the
scope target of build this device is become clearer. With the aim of this project, it
become a reason of this project should be developed.
Chapter 2 gives a literature review for this project. The literature review gives
guidelines in order to complete this project. With the various idea and method from
each source, the project becomes glorified. It also became a case study for this
project to overcome with the new idea and different design compared to the previous
project.
Chapter 3 describes the methodology of this project. First the block diagram of
overview circuit will discuss clarify and correct connection between inputs and
outputs. The process of operation and flow of source code will be shown in a
different flowchart. Other than that, each function and characteristics of electronic
such as Raspberry Pi 4 microcontroller, Force Sensitive Resistor sensor, TFT touch
screen, and Analog to Digital Converter.
Chapter 4 shows the results produced from this project. The result from the real
time will be considered as the desired output of this project. The result includes
successful operation of the Force Sensitive Resistor send data with the pressure given
7
by the user to the microcontroller Raspberry Pi, alert the user when there is wrong
pressure point with a buzzer and store data in application.
Chapter 5 which is the last chapter describes about the conclusion of this
project. The summarized results obtained will be concluded.
8
CHAPTER 2
LITERATURE REVIEW
accurately tracked with a single discreet on-body motion sensor and a GPS receiver,
such as one found in a smart phone.
In the domain of strength and muscular endurance training, there is much less
development, particularly in terms of widely useable unobtrusive devices.This type
of training improves bone strength and muscle fitness while also lowering the chance
of injury . There are two sorts of strength-training exercises. The first is based on
specialised fitness equipment commonly found in gyms. The second consists of
workouts that may be done anywhere, such as push-ups, crunches, and free weight
lifting. We will concentrate on the latter in this study. Because the exercises are
generally defined by complicated motion patterns involving several body parts, more
elaborate sensor systems are required than a single body-mounted motion sensor.
10
Figure 2.2: Exercises performed in the experiment: I. push-up, II. quadruped, III.
abdominal crunch, IV. chest press with dumbbell, V. bridge. The pictures on the
right are typical frames corresponding to the exercise.
the monitoring may be done without the use of any additional sensors by just
switching from a regular gym mat to a smart gym mat[1].
Figure 2.3: Detection rate of exercise counting for each subject and activity using
different templates [1].
A processor that reads and analyses data about the user's weight distribution
and posture may be operationally connected to the yoga mat. This information could
be transferred to a second processor that has more information about the user. The
second processor can then compare the user's ideal weight and position data and
provide them feedback.
13
The mat could eliminate the need for a private instructor by providing
dynamic real-time training tailored to a user's body type and practise via powerful in-
mat sensors that connect to an app on a computer, such as a smartphone or tablet.
The mobile component may provide real-time feedback and modifications to users,
allowing them to practise and achieve a more optimal stance. Users can utilise the
mat and mobile component to track and measure progress, as well as communicate
with top yoga instructors at home on their own time[2].
The yoga self-coaching system has been totally created in Python, with a
Python interface based on the Tkinter library, according to this review paper. The Tk
graphical user interface (GUI) toolkit's standard Python interface is Tkinter. Based
on the TL-MobileNet-DA model integrated in the Jetson Nano kit, the user interface
of the yoga self-coaching system captures the user's posture from a USB camera at
the top of the mirror panel and then recognises the yoga stance. To follow the yoga
practise, a user can select one of the 14 various yoga postures studied in this
study.The guidance yoga graphic appears on the system interface after a user
confirms their chosen pose for evaluation. To achieve posture recognition, the user
can then verify for the correct posture by watching the guiding image, which is
displayed in real-time.
14
Figure 2.6: Transfer learning process from pre-trained on ImageNet dataset to learn
new target datasets [2]
When the user achieves the correct stance, the resulting recognised posture
will pop up with a success message of "Correct:)" and a fail message of "Incorrect:("
when the user does not accomplish the correct posture. The identified yoga label
from our system appears underneath the performance checking results.
prediction, it may be reasonable to examine how to forecast weight using only the
upper-body sub array.
Complete sensor arrays, on the other hand, are required. This is due to the fact
that the FSR sensors must be arranged in a grid in order to measure weight regardless
of lying direction. To establish the patient's lying posture, it is important to assess the
location of the hands and feet. The MAE rose by discarding the measured values of
the lowest 1/3 of the FSR sensors while forecasting body weight, according to the
results of the temporal experiment. Even though 1/3 of the FSR sensors do not
accurately measure the values, it is tough to dismiss them totally.The proposed
method is marginally less accurate than the RGB-D sensor-based method in terms of
prediction accuracy. This is due to the fact that RGB-D sensors have the added
benefit of capturing image skeletal and depth information. Nonetheless, the method
suggested in this research has the advantage of being able to estimate human weight
without having any negative effects on the environment. If the sensors are tightly
packed to reduce dead spaces or the dataset size is raised, it is expected that better
prediction results would be obtained[4].
In this review paper, the platform was built from the ground up using Sensing
Tex's patented pressure pattern measurement technology. It enables the user to
quantify pressure from a variety of perspectives, including Movement Analysis and
Postural Detection. The product can be used for a wide range of applications. It can
be used in a variety of sports and wellness applications. Our goal is to deliver real-
time data to the customer so that the exercises in each application can be improved.
The Fitness Mat works with any smart device, including smartphones and tablets. On
your preferred device, you should be able to see your workout in real time. You can
tell when you're doing something correctly or incorrectly by keeping track of your
behaviours. The Mat can determine which exercise is the best for the correlation of
the position based on the recorded data in the event that the exercise is not in use[5].
17
Figure 2.8: Illustrates the block diagram of various components used in Automatic
Gym mat [6]
All of the components work together to make this mat automatic. This mat
also recommends exercises based on the age of the user. This mat may be adjusted to
the user's size and height thanks to the iris mechanism. Because it can save users
time and be further modified utilising new technologies and procedures, this mat has
a bright future[6].
18
2.1.7 Case Study 7: Social Yoga Mats: Designing For Exercising Or Socializing
Synergy
In this paper, introduced Social Yoga Mat design, which opens up a world of
possibilities for technology aimed at strengthening and extending the exercising or
socializing synergy. Through a discussion of design insights gathered during the
journey, gave an early articulation of this design space. Other interaction-design
researchers working in contexts where the exercising or socializing synergy is at
work including designs that incorporate other sorts of exercise and designs meant for
non-seniors might find the insights and example offered here useful. The viewpoint
of embodied interaction proved to be quite useful, leading to a design that gives a
tactile interface that allows users to interact and generate social meaning through
their physical activities. The current findings are based on user engagement sessions
that lasted only a few minutes. Moreover, to investigate the effects of long-term daily
interaction with prototypes in the future. They also like to try out more accurate
activity monitors, which would allow for better feedback and evaluation of yoga
workouts while also allowing for new forms of social interaction. Within the design
area we've been investigating, Social Yoga Mats are only one possible option. They
intend to develop more examples in the future to further define and grow this
space[7].
In this paper, there is a proposed embedded based smart yoga mat and
experimental setup as well. The proposed smart yoga mat is integrated with hardware
and software design approach represented in figure below.As shown on the circuit
diagram, FSR sensor is driven to control unit and the control unit is integrated with
sensor module, pattern generation, database module and comparator module. A voice
module is connected to the control unit as an output for this device. FSR sensor is
used to evaluate pressure of the user on the mat. An array of pressure is connected to
integrate the ESYM and sensor information data is stored in pressure sensor data
modules. In this project, embedded device myRIO is used as a control unit to
perform the ESYM and the method is developed by using virtual instrumentation. In
19
this ESYM, physical pressure modes are transferred into pattern generation wit FSR
sensory data. The ESYM algorithm is executed on myRIO using LabVIEW, the
FPGA technology intervention consume less power and computation time. This also
provides more area for executing more posture function in the mat[8].
In this system, have combined sensory input to enhance the patients balance
and stepping. This system includes with a mat that able to detect multiple target of
step on it. This mat is contacted by the patients and the output will be from the
audible signal. This system helps to analyze the gait and balance by the healthcare
professionals or patients. This invention is generally an exercise equipment which
provides sensory and motor feedback to improve balancing and stepping[9].
20
2.1.10 Case Study 10: Hiit Pi Makes Raspberry Pi Your Home Workout
Buddy
In this task, they use HII Pi which is a web application that utilizations AI on
Raspberry Pi which help to follow the exercise progressively. When utilizing the
application, clients can interface with the application through any internet browser
running on same neighbourhood network as Raspberry Pi, be that on PC or
differentgadgets. The primary capacity of this HIIT Pi is utilizes PC vision to
consequently catch and track recognized stances and development and scores them as
indicated by a bunch of rules and guidelines. Thus, this application functions as an
advanced exercise coach in the room checking the developments and help to
accomplish wellness objectives. This gadget work as the Raspberry Pi camera
module streams crude picture information from the sensor generally at 30 edges each
second. There will be a custom recording stream overseer that works off this posture
assessment model and takes outlines from video transfer, letting out present certainty
scored utilizing adjustment central issue position facilitates[10].
21
Summary
From the literature review, could understand that there are many option of
control unit, sensors, display and other components. Moreover, its very important to
choose the right components so that can reach the aim and objective of the project.
As for a comparison, Raspberry Pi function is more compare to Arduino, as for
Arduino need node mcu for internet connection but Raspberry Pi does not require
any additional device for connections. As for the sensors, Force Sensitive Resistor
are more capable for this project as it able to read the weight or pressure on the yoga
mat and provide analog signal towards Raspberry Pi. Comparing to load cell sensor,
Force Sensitive Resistor sensor gets direct contact to get input as well.
From the case study, there are many type circuits, components, ideas,
initiations, applications, and many more found from the review papers. As from there,
found that Raspberry Pi 4 is a very interesting processor which able to provide more
function from other control unit. Other than that, the idea on building the project is
based on the control unit, with yoga mat. As this will be an easy carry project and
able to use by most of the people.
This part will describe the description and important of each component and
electronic device that need to be considering in building this project. The component
list for each device is listed down in the Table 2.1
DEVICE COMPONENT
MICROCONTROLLER RASPBERRY PI 4
MODEL B
22
2.2.1 MICROCONTROLLER
Safety Feature
caution when handling the printed circuit board and connectors to avoid mechanical
or electrical damage. To reduce the danger of electrostatic discharge damage, avoid
handling the printed circuit board while it is powered and only handle it by the edges.
Python also has a memory management system built in.The product allows for
a lot of experimentation and transformation into something completely different. The
SD cards on the board can be readily swapped, allowing you to change the device's
capabilities without having to spend a lot of time reinstalling software. The
Raspberry Pi is ideal for adaptive technology since it can show visuals or play films
in high-definition resolution, which is ideal for prototyping embedded systems. This
tool allows you to create complicated and effective structures at a lower cost.The
product is effective, and it offers small businesses an ethical alternative. Unlike large
servers that require a lot of energy and extensive cooling systems, this little card-
sized product is easy to recycle and does not emit as much carbon dioxide into the
environment. It is not a computer replacement, and the processor is not as fast.
Downloading and installing software takes time, therefore you won't be able to do
any intricate multitasking. Other operating systems, such as Windows, are
incompatible.
This is for those who want a gadget that they can customise to their own
requirements and preferences, rather than for those who just want a job done quickly.
If the extra work is worth it, business owners should think about it. This product will
not be beneficial for larger businesses that already have large servers, which can
26
perform all of the tasks that the Raspberry Pi can. As a result, it would not be worth
it, and putting everything together would take time. The advantage and dis-advantage
of using Raspberry Pi 4 as a maincontroller is shown on the Table 2.3, below.
Sensors that detect physical pressure, squeezing, and weight are known as
Force Sensitive Resistor. They are easy to use and inexpensive. An Force Sensitive
Resistor, namely the Interlink 402 variant, is shown in the Figure 2.13. The sensitive
bit is the 1/2" diameter round portion.
A spacer separates the two layers of the Force Sensitive Resistor. The more
one presses, the more of those Active Element dots come into contact with the
semiconductor, lowering the resistance. The Figure 2.14 shows the layers of the
sensor.
Force Sensitive Resistor are essentially resistors that change their resistance
value (in ohms) based on how hard they are pressed. These sensors are inexpensive
and simple to use, but they are rarely precise. They also differ by about 10% from
one sensor to the next. So, when using Force Sensitive Resistor, you should only
anticipate to receive response ranges. While Force Sensitive Resistor can detect
weight, they're not the best option for determining how many pounds are on them.
The basic stat of the Force Sensitive Resistor sensor is shown below in Table 2.4
28
As show in Figure 2.5 above, the more the pressure or force given, the lesser
the resistance in the Force Sensitive Resistor sensor. It's crucial to note that the graph
isn't truly linear and that it quickly moves from infinite to 100K at really low force
readings.
Figure 2.6, below shows the Analog to Digital converter designed to work
with Raspberry Pi. Two Microchip MCP3424 A/D converters, each with four
analogue inputs, make up the ADC Pi. The MCP3424 is a low-noise differential
input delta-sigma A/D converter.
There are various methods for converting an analogue signal to a digital signal.
The ADC08xx series is one of many varieties of ADC chips available on the market
from various vendors. As a result, discrete components can be used to create a simple
Analog to Digital Converter. The high data collection rate of an Analog to Digital
Converter, even with multiplexed inputs, is one of its main advantages. Data
acquisition from diverse sensors has grown more accurate and faster because to the
advent of a range of Analog to Digital Converter integrated circuits (ICs). Improved
measurement repeatability, low power consumption, precise throughput, high
linearity, and outstanding Signal-to-Noise Ratio (SNR) are among the dynamic
properties of high-performance Analog to Digital Converter.
The analogue signal is first applied to the first block, a sample, which can be
sampled at a precise sampling frequency. The sample's amplitude value, like an
analogue value, can be kept and held in the second block, called Hold. The third
block, quantize, can be used to convert the hold sample into a discrete value. Finally,
the encoder transforms the discrete amplitude into a binary number.
SAMPLE
The analogue signal can be sampled at a precise interval of time in the sample
block. Although the samples are employed in continuous amplitude and have a real
value, they are discrete in time. The sample frequency is very important while
converting the signal. As a result, it can be kept at a precise rate. The sample rate can
be set based on the system requirements.
HOLD
QUANTIZE
ENCODER
An encoder transfers the signal from digital to binary form, which is the final
block in an Analog to Digital Converter. We know that binary signals are used in
digital devices. As a result, an encoder is necessary to convert the signal from digital
to binary. So that's how you use an Analog to Digital Converter to convert an analog
signal to a digital signal. The entire conversion can be completed in a fraction of a
second.
PROCESS OF CONVERSION
The digital output ranges between 0 and 255. A clock is required for ADC to
function. The amount of time it takes to convert an analogue value to a digital value
is determined by the clock source. CLK IN pin no.4 can be used to connect an
external clock. To use the internal clock, a suitable RC circuit is connected between
the clock IN and clock R pins. Pin 2 is the input pin; after conversion, the data from
the internal register is sent to the output pins via a high-to-low pulse. Pin3 is the
external clock receives a low to high pulse. From MSB to LSB, pins 11 to 18 are data
pins.
On each falling or rising edge of the sample clock, the Analog to Digital
Converter samples the analogue signal. The ADC receives the analogue signal,
measures it, and transforms it to a digital value once each cycle. The Analog to
Digital Converter approximates the signal with defined precision to convert the
output data into a series of digital numbers.
33
The accuracy of the digital value that captures the original analogue signal in
Analog to Digital Converter is determined by two variables. Quantization level, also
known as bit rate, and sampling rate are two of them. The analogue to digital
conversion process is depicted in the diagram below. The resolution of digital output
is determined by the bit rate, as shown in the Figure 2.8 below, where a 3-bit ADC is
used to transform the analogue signal.
Assume that you need to convert a one-volt signal from digital to analogue
using a 3-bit ADC. As a result, there are a total of 23=8 divisions available for
generating 1V output. This result 1/8=0.125V is referred to as the lowest change or
quantization level, with 000 being 0V, 001 denoting 0.125, and 111 denoting 1V. We
can improve the signal precision by increasing the bit rates to 6, 8, 12, 14, 16, and so
on. As a result, bit rate or quantization produces the smallest change in the analogue
signal value as a result of a change in the digital representation.
If the input signal is sampled at a different frequency than the desired one,
there is a very good risk that it will be misrepresented on the output side. As a result,
the sampling rate is a significant factor for the ADC. As shown in the diagram, the
Nyquist theorem asserts that the acquired signal reconstruction introduces distortion
unless it is sampled at (minimum) twice the rate of the signal's greatest frequency
content. In practise, however, this rate is 5-10 times the signal's maximum frequency.
Figure 2.19: Sampling Rate of Analog to Digital Converter
The 3.5-inch resistive touch screen display of this TFT LCD display is
compatible with any Raspberry Pi hardware. This 3.5" TFT display offers a
resolution of 480x320 pixels, a 16-bit colour depth, and a resistive touch option. It
fits on top of the Raspberry Pi Zero W board and is powered by the Vcc pin, the
display talks with the Pi using the SPI protocol. Additionally, the HDMI port on the
Pi can be used to connect it to another display. It's made for the Raspberry Pi Zero/Pi
2/Pi 3 Model B/B+, but it can also be used on other SPI-enabled hardware platforms.
The Figure 2.10 shows the 3.5 inch TFT touch screen display.
The TFT RPi LCD display has 26 pins. It's used to connect the Raspberry Pi
to the LCD through SPI and to power the LCD using the Raspberry Pi's 5V and 3.3V
pins. The following Table 2.5 is a list of pin descriptions.
Table 2.5: List of Pin and description on 3.5 inch TFT touch screen
Power input
5V 2 1 3.3V NC
(5V)
Power input
5V 4 3 SDA NC
(5V)
Power
GND 6 5 SCL NC
GND
NC TX 8 7 P7 NC
Power
NC RX 10 9 GND
GND
NC P1 12 11 P0 NC
Power
GND 14 13 P2 NC
GND
NC P4 16 15 P3 NC
NC P5 18 17 3.3V NC
TP SPI Bus
Power
GND 20 19 MI input
GND
(MOSI)
TP SPI Bus
TP Interrupt IRQ 22 21 MO output
(MISO)
TP SPI Bus
NC CE0 24 23 SCK Clock
(SCLK)
36
TP chip Power
TCS 26 25 GND
Select GND
2.2.5 BUZZER
The buzzer's pin arrangement is illustrated below. It has two pins, one positive
and one negative. The '+' symbol or a longer terminal is used to represent the positive
terminal of this. The positive terminal is represented by the '-'symbol or short
terminal and is connected to the GND terminal.
SPECIFICATIONS
TYPE OF BUZZER
There are many different type of buzzer that able to use for projects and others.
The available buzzer’s are Piezoelectric, electromagnetic, mechanical,
electromechanical and magnetic. The sound frequency and some features differs in
between these buzzer’s. We have to choose the correct buzzer according to the
project.
WORKING PRINCIPLE
Simple and premade buzzers are the most popular types of buzzers. When a
simple type is powered up, it will continuously emit a beep sound. A pre-made type
appears to be heavier and generates a Beep. Beep. Beep. The internal oscillating
circuit within it produces this sound.
There are many advantages and also disadvantages of using buzzer. First, the
advantage of using buzzer is it’s simply compatible. Then, the buzzer’s frequency
response is good enough to provide alert system or sound for the projects. The size of
buzzer are small so that it can fit easily in mini projects as well. More importantly,
the energy consumption of the buzzer is very less and the range of voltage usage is
large. This makes the buzzer work efficiently for most of the projects. Finally, the
sound pressure is high and provides a good sound or alert in the project.
The Arduino Pro Mini is a microcontroller board that uses the ATmega328
microprocessor. Six analogue inputs, 14 digital input or output pins such as reset
button, an internal 8Mhz resonator, and slots for mounting pin headers are all on the
board. To provide USB power and programme the board, a six-pin programming
header can be linked to an FTDI cable or a Spark fun breakout board. The pinout and
specifications for the Arduino Pro Mini based on the Atmega 328 are detailed in the
Figure 2.21
39
In this part, the software used to perform the application on Raspberry Pi and
others will be discussed. Computational algorithms are written in Phyton for
Raspberry Pi programming. Application is used to save data and to connect with
Raspberry Pi.
2.3.1 APPLICATION
The server component connects the application to the Raspberry Pi that runs
the library. By default, the platform makes use of the project's cloud service.
However, the server is available under an open source licence, so may easily install it
on own system. In reality, it may run both the server and the library on the same
41
Switch to the wiringPi directory that has resulted and run the build script as
shown on the Table 2.8
cd wiringPi
./build
Run the ‘gpio -v’ command to see if the library has been installed. It should
return the version information. Use the following commands to compile the
application library as shown in Table 2.
42
Although the project provides a service for connecting the application and
the Raspberry Pi, can alternatively run the server on own workstation. The only need
is that Java be installed on this PC. The Server GitHub repository contains.jar
binaries, so all you have to do to deploy the server is download the newest version of
the server-x.x.jar binary and run it using the java -jar server-x.x.jar command. This
will start the server on port 8443 by default, but you can change it with the -hardPort
parameter: server-x.x.jar -hardPort 8555 java -jar server-x.x.jar.
Python has become a data science standard, allowing data analysts and other
professionals to perform complex statistical computations, produce data
visualisations, design machine learning algorithms, handle and analyse data, and
perform other data-related tasks using the language.
Python can create a variety of data visualisations, including line and bar
graphs, pie charts, histograms, and three-dimensional plots. TensorFlow and Keras
are two Python frameworks that let programmers create data analysis and machine
learning systems more rapidly and efficiently.
WEB DEVELOPMENT
AUTOMATION OR SCRIPTING
If you find yourself repeating a task frequently, automating it with Python can
help you work more efficiently. Scripting is the process of writing code that is used
to create these automated procedures. Automation can be used to check for flaws
across numerous files, convert files, perform simple math, and delete duplicates in
data in the coding industry. Relative amateurs can use Python to automate simple
computer chores like renaming files, discovering and downloading web information,
and sending emails or SMS at predetermined intervals.
44
CHAPTER 3
RESEARCH METHODOLOGY
3.1 INTRODUCTION
The overview of this project is determined before conducting the work. Before
the work is conducted, there are a lot of preparations and planning need to be done to
make sure the project is done according to the flow. It also makes the project works
systematically. Time management of this project is planned properly through Gantt
Chart and the project flow is decided and constructed using flow chart for PSM 2.
Besides that, process flow and block diagram will give an overview of the flow of
this project and assign the tasks needed to be done by the device.
45
The flow chart below in Figure 3.1, shows the overall process to be executed
to complete the project successfully. The important part need to be accomplish is to
identify the problem statement and the objective. As this two important part will
direct us in the project to the right solution and with objective it’s easier to move
forward to reach the project completion. Objective of the project plays a very
important role as the final of the project, should accomplish the objectives. Moreover,
it is important to get a clear objective and scope as a guideline to continue the project.
The project objective must be achieved at the ending of this project.
The next step was literature review after deciding the objective and scope
analysis. In this literature review, have done some research on internet and libraries
as well to gather information and related project works. The literature review started
with previous related projects that have been done and collected information such as
components been used, software basics, designs, data information and analysis.
Knowledge and information gained will be useful in identifying appropriate
components for the projects.
flowchart. As flow chart is an easier way to read and understand about the project or
project flow. It will be easier to identify the workflow, strategy, and approach. Then,
the circuit connection are also mentioned in methodology with a schematic diagram
to show the components that have used in the project and connections of the
components to form the circuit. The measurement of yoga mat, Force Sensitive
Resistor wire connection length, and overall design of the project is also mentioned
in the methodology. The programming used to design this project is Phyton as the
micro controller is Raspberry Pi 4. The programming is done in 2 part. First part is to
send data from the Force Sensitive Sensors in analog form to Arduino Pro Mini will
convert the signal to digital form before sending to Raspberry Pi. The Arduino Pro
Mini perform to convert analog to digital in this project.
At last, the final testing of the project have done to get the result and collect
data for report purposes. The final testing is done to check the outcome of the project
and to make sure the project is functioning properly according to the programming
inserted.
47
The main criteria of the project is Input, Control Unit and Output. The Input
for this project is five Force Sensitive Resistor sensor and Arduino Pro mini. The
Force Sensitive Resistor sensor function to detect the pressure and the function of the
Arduino Pro Mini is to convert analog signal to digital signal as an input. Secondly,
the control unit for this project is Raspberry Pi 4 Model B. This control unit will
receive the data from the input and process it with coding. The outputs are 3.5 inch
TFT touch screen and buzzer. The coding have to run inside the control uni and have
to open the application in the Raspberry Pi 4 to get the reading and also to get the
data and will display by the TFT touch screen. Buzzer is for alert system in the
project. The flow of the input, output and control unit is shown in the figure 3.2
below.
The overall process flow starts from the control unit, Raspberry Pi 4. Once
connect the power supply to Raspberry Pi, it will authenticate and give power to the
TFT touch screen to display. Then, have to run the Phyton coding just once before
running the application. After running the programming, can access into the E-Health
Yoga Mat using Raspberry Pi application. In the application it shows the modes
available and selected mode can be performed on the mat by the user. If any
misplacement mistakes on the mat, the buzzer will give alert to the user to re-correct
the step. This is the overall process flow of the project.The figure 3.3 below shows
the project process flow.
Force sensitive resistor sensors in this project act as main input. As to provide
input signal, the user will perform the yoga posture on the yoga mat according to the
display shown in the screen. While the user perform on the mat, the force sensitive
resistor sensors will read the pressure in analog form and send signal to Arduino pro
mini. The figure 3.5 below shows the connection of the sensors connected in the
yoga mat accordingly.
As shown on the above figure 3.5, the sensors are labeled as 1,2,3,4 and 5.
Sensor 1 and 2 are placed on the top of yoga mat while sensor 3 placed in the middle
of the yoga mat. Finally the sensors 4 and 5, are at the bottom of the yoga mat. The
sensor will read the signal when there is pressure on the sensor cause this Force
Sensitive Resistor sensor have to give pressure or weight to lower the resistance.
According to this term, when the pressure increase in the sensors, the resistance will
be lesser.
The Arduino can both input and output analogue and digital signals. Unlike a
digital signal, which has just two values: HIGH and LOW, an analogue signal can
take on any number of values. The Arduino has an analog-to-digital converter built
in to measure the value of analogue signals (ADC). The analogue voltage is
converted to a digital value by the ADC. The analogRead function is used to get the
value of an analogue signal (pin). This function takes the value of an analogue input
pin's voltage and transforms it to a digital value between 0 and 1023, relative to the
reference value. The default reference voltage is either 5 V (for 5 V Arduino boards)
or 3.3 V (for 3.3 V Arduino boards) (for 3.3 V Arduino boards).
As in this project, the Arduino Pro mini work as analog to digital converter.
This is to convert the input signal given to the Force sensitive resistor from analog to
digital signal. The input signal produced by the user performing posture on the mat,
and there is pressure on each sensors according to the mode selected in the software.
Every signal from the sensor will converted by the Arduino Pro mini before going
into control unit. Figure 3.6 shows the Arduino Pro Mini used in this project.
54
The new USB-C power connector is perhaps the most important in terms of
everyday use. Its inclusion ensures an extra 500mA, bringing the total to 1.2A for
USB devices. There are also two USB 3.0 ports in addition to two USB 2.0
connectors. The possibility of connecting high-speed USB devices to the Raspberry
Pi 4 is fascinating. The USB-C connector also supports OTG, allowing you to
connect the Pi to a USB port on your PC and access it locally.The Ethernet port was
on the USB hub in prior models with on-board LAN. The port's speed was dropped
as a result, however this time the Ethernet port is a full Gigabyte, ensuring superior
speed. The Raspberry Pi 4 has built-in wireless networking (dual-band 802.11
b/g/n/ac) and Bluetooth 5.0 BLE capability, just like previous models. A new
processor is also included in the latest Raspberry Pi. On the BCM2837 SoC (System-
on-Chip), a 1.5GHz 64-bit quad-core ARM Cortex-A72 CPU (ARM v8) sits,
marking a substantial departure from prior generations of Raspberry Pi. Finally,
instead of a single HDMI port, the Raspberry Pi 4 offers a pair of micro-HDMI ports.
These support 4K, which opens up the possibility of ultra HD video for media
streaming and twin monitor projects.
In this project, Raspberry Pi 4 Model B 4GB RAM is the control unit. It runs
the coding and also carries application of E-Health Yoga Mat Using Raspberry Pi.
The analog signals from Force sensitive sensor will move into Arduino Pro Mini to
convert into digital signal. After that, the digital signal will direct into the Raspberry
Pi and provide sensor data to the application.
The TFT touch screen is used in this project to minimize the display according
to the yoga mat. When the user perform the posture, this screen will be more helpful
and convenient to use together with the yoga mat. This TFT touch screen is an output
55
display from Raspberry Pi. The Figure 3.7 below shows the TFT touch screen used
in this project.
Figure 3.7: 3.5 Inch TFT Touch Screen used in this project
3.4.5 Buzzer
The buzzer in this project is for alert system. While the user perform the
postures on the mat, if they missed out any point on the sensor point or wrongly do
the posture, the alert system will produce sound from the buzzer. The buzzer from
the project is shown in the Figure 3.8 below.
56
The yoga mat that used for this project is natural rubber material as it will e
more convenient for the user to use while perform the yoga posture. Moreover, this
material is more light and easier to handle. As for this project, I have to install the
sensors in the mat, it will be an easy installation as well. The yoga mat size is 173cm
long, 61cm width and 10mm thickness. The size of the yoga mat shown below in the
Figure 3.9
57
Figure 3.9: Measurement of the yoga mat used for this project
Figure 3.10 show the schematic diagram of the circuit. The components used are as
mentioned Raspberry Pi, Display, resistors, Arduino Pro mini and a buzzer.
3.5.1 Phyton
In this project, Phyton language is used as the main coding for the Raspberry
Pi. The coding is to activate the application and create an interface between the
software sensor, buzzer and control unit. First coding is for the TFT screen
interfacing with the Raspberry Pi 4. Th previous version of Raspberry Pi is easy to
connect with the displays as it is direct connection and there is no any additional
settings. Nonetheless, for TFT touch screen needed setup and coding to activate the
screen. So, firstly connected the Raspberry Pi with power supply and then connected
the screen to the Raspberry Pi directly. After that, used an HDMI cable to connect
the Raspberry Pi with a monitor. In the monitor, have done the basic setup and the
memory card with 32GB memory installed in the Raspberry Pi. Then, inserted the
coding shown in Figure 3.11 below in the Command prompt in the Raspberry Pi to
interface the TFT touch screen.
cd LCD-show/
sudo ./LCD35-show
59
Figure 3.11: Coding to interface TFT touch screen with Raspberry PI.
After that, the display on the monitor have turned off automatically and the
TFT touch screen is displayed. Then, started working on the programming of E-
Health Yoga Mat Using Raspberry Pi. In the coding have included the sensors,
buzzers and others as well. The Figure 3.12 below shows the coding for buzzer
connection in the overall process.
if (str(value)=="['0']"):
GPIO.output(BUZZ, False)
if (str(value)=="['3']"):
GPIO.output(BUZZ, True)
time.sleep(0.02)
GPIO.output(BUZZ, False)
time.sleep(0.02)
GPIO.output(BUZZ, True)
time.sleep(0.02)
GPIO.output(BUZZ, False)
time.sleep(0.02)
GPIO.output(BUZZ, True)
time.sleep(0.02)
GPIO.output(BUZZ, False)
60
time.sleep(0.02)
if (str(value)=="['2']"):
GPIO.output(BUZZ, True)
time.sleep(0.2)
GPIO.output(BUZZ, False)
time.sleep(0.2)
GPIO.output(BUZZ, True)
time.sleep(0.2)
GPIO.output(BUZZ, False)
time.sleep(0.2)
if (str(value)=="['0']"):
GPIO.output(BUZZ, False)
if (str(value)=="['5']"):
ser.write("A".encode())
blynk.notify("DEVICE IS NOW ONLINE!")
Next will be performing coding for sensors. This coding is to create the
numeric reading in the application from the Force Sensitive Resistor. When the
sensor detect pressure from the user while performing yoga posture, the resistance in
the sensor will decrease and will show a numeric reading on the pressure. On the
yoga mat, the sensor is arranged accordingly as Sensor 1 and Sensor 2 on top, Sensor
3 in the middle and Sensor 4 and Sensor 5 at the bottom shown in Figure 3.13 below.
61
Figure 3.13: The Force Sensitive Resistor sensor connected accordingly on the yoga
mat
After the sensor installation, the sensor coding is setup and uploaded to
activate the sensors to get input. The coding for the sensor is shown below in Figure
3.14
3.5.2 Application
For this project, I have created an Application named E-Health Yoga Mat
Using Raspberry Pi. In this application, it able to read the pressure value in numeric
from the sensors. Moreover, user’s can sign up or if already have an account can
login to perform the Asana’s they prefer in the Yoga Mode. This application also
able to save data of the user’s for reference purpose and keep track on the
performance as well. It also provides some doctor tips for better performance while
on the mat and off the mat as well. The icon of the application shown below in
Figure 3.14
CHAPTER 4
4.1 Overview
This chapter will show and explain the development of the E-Health Yoga
Mat Using Raspberry Pi. Thus, the design for the project is based on two
fundamental points as follows:
i. Designing and developing the hardware with Force Sensitive Sensor, Arduino Pro
Mini, Raspberry Pi, 3.5 inch TFT touch screen and buzzer.
ii. Analyzing data in the application to get numeric data of the pressure given and
alert sound from the buzzer.
In this part, will show the complete hardware design with circuit connections,
software working system and finally the outcome from this project with some
64
analysis. The overall project objective and scope will be proved in this chapter with
the results.
As for this project, have used five Force Sensitive Resistor on the Yoga Mat.
The connection of the sensors is from the resistor and Arduino Pro min. As the
sensor will read the data and send to Arduino Pro Mini to convert to digital signal
and will send information to the control unit. The five sensor that connected in this
circuit are shown below in Figure 4.1
65
The overall design of the project is completed after the circuit connections are done.
The Arduino Pro Mini and the resistors connected to the sensors are placed in a
casing separated from the control unit, Raspberry Pi 4 and Tft touch screen are
together in a casing. The Arduino pro mini will make a direct connection to the
Raspberry Pi along with buzzer. The figure 4.2 shows the overall circuit connection
and in Figure 4.3 shows the direct connection of the Arduino Pro mini to the
Raspberry Pi.
66
The sensor’s are connected on the yoga mat before the testing as shown in the
Figure 4.4 below. This is the final testing on the sensor accuracy to detect the
pressure on the mat when force is applied on the sensor.
67
A B C
D E F
As shown in the above figure, all sensors are able to detect in the application. The
numeric value will be shown on the application and save data as well.
4.2.4 Display
3.5 inch TFT touch screen is the display connected to the raspberry pi to send data in
digital form. The Phyton coding and the application are able to run in the Raspberry
pi and displays in the touch screen. As shown in the Figure 4.6, the Raspberry should
connect to the power to on the screen and then can use the touch screen for coding
and application.
4.2.5 Application
The Application created for the E-Health Yoga Mat using Raspberry Pi is apk
formatted software. This application is able to control in the phone and also on the
Raspberry Pi. There are few features in this application. Firstly, have to enter the
application after installing it, as shown in the Figure 4.7 below.
69
After enter into home page, have to select sign up or log in. If existing user can press
log in and insert the name and password, as shown in the figure 4.8
If new user, have to press Sign Up and insert the details of name, password and
confirm password to own an account, Once created, log in as usual.
After log in, it will show type of yoga postures. There are 8 type of postures for now
in the application as shown in Figure 4.10 below
71
After that, as an example, the user chooses Asana 1 to perform on the mat, it will
show the Sensor to read according to the posture. If the posture is wrong or wrong
sensor is detected it will produce alert sound from the buzzer. The Mode page is
shown in Figure 4.11
Finally, when the user perform on the yoga mat, the sensor will show detect when
there is pressure on the sensor. It will keep data of the user in the history and will
provide health info’s as well in the health info section.
4.3 Result
the detection of pressure delayed 3 seconds only. In Figure 4.12, shows the
participants perform the posture on the mat while the reading of pressure sensor in
the application.
73
Figure 4.12: Asana 8 performed by participant with result of the sensor detection in
the application.
Figure 4.12: Asana 3 performed by participant with result of the sensor detection in
the application.
75
Figure 4.12: Asana 7 performed by participant with result of the sensor detection in
the application.
76
CHAPTER 5
CONCLUSION
5.1 Overview
In this chapter, will conclude the overall project work, work flow, result, discussion
and finally the goal to achieve the aim and objective.
5.2 Conclusion
The objective and aim of this project is achieved. In this project, have
developed a E-Health Yoga Mat using Raspberry Pi 4 Model B. In this project, Force
Sensitive Resistor is used to detect the pressure or force given by the user to detect
the movement on the mat. Finally, after the hardware connection and software is
completed, the evaluation of the project is done completely to prove the result.
For the future work, would suggest to have more features in this application
so that it’s use will be more on this yoga mat. Moreover, this sensor design could be
improved more or add more sensors for better performance and multiple detection on
the mat as more the sensor, the more the posture able to perform on the mat.
78
REFERENCES
[1] research gate. 2014. Smart-Mat: Recognizing and Counting Gym Exercises
with Low-cost Resistive Pressure Sensing Matrix. [online] Available at:
<https://www.researchgate.net/publication/280765362_Smart
mat_Recognizing_and_counting_gym_exercises_with_low-
cost_resistive_pressure_sensing_matrix>
[2] 2015. INTERACTIVE EXERCISE MAT. 1st ed. [ebook] Patent Application
Publication, p.28. Available at:
<https://patentimages.storage.googleapis.com/a3/6b/16/1cd370c8a78f09/US2015036
4059A1.pdf>
[3] Long, C., Jo, E. and Nam, Y., 2022. Development of a yoga posture coaching
system using an interactive display based on transfer learning.
[4] Kim, T. and Hong, Y., 2022. Prediction of Body Weight of a Person Lying on
a Smart Mat in Nonrestraint and Unconsciousness Conditions.
[5] Sensingtex.com. 2022. [online] Available at: <h.
[6] Ijircst.org. 2022. [online] Available at: <https://www.ijircst.org/DOC/26-a-
research-paper-on-new-generation-gym-mat.pdf>
[7] ACM Conferences. 2022. Social yoga mats | Proceedings of the Sixth
International Conference on Tangible, Embedded and Embodied Interaction. [online]
Available at: <https://dl.acm.org/doi/10.1145/2148131.2148151> [Accessed 20 June
2022].
[8] Ieeexplore.ieee.org. 2022. Real–Time Yoga Activity with Assistance
of Embedded based Smart Yoga Mat. [online] Available at:
<https://ieeexplore.ieee.org/document/8902371> [Accessed 20 June 2022].
[9] HIIT Pi makes Raspberry Pi your home workout buddy – Binary Emotions
Blog, 2022
79
APPENDIX A
float CS;
void setup() {
Serial.begin(9600);
void loop() {
if (MODE==1){
//----------------------------------------------------------------
Sens1 = analogRead(A0); //read the value from the sensor
Sens1= (5.0 * Sens1 * 100)/1024.0; //convert the analog data to digital
Sens1=(500-Sens1) * 0.2;
/*
80
Serial.print(Sens1);
Serial.print("\t");
Serial.print(Sens2);
Serial.print("\t");
Serial.print(Sens3);
Serial.print("\t");
Serial.print(Sens4);
Serial.print("\t");
Serial.println(Sens5);
*/
//-------------------------------------------------------------------
delay(1000);
Count++;
if (Count==1){
Serial.println(Sens1);
}
if (Count==2){
Serial.println(Sens2);
}
if (Count==3){
Serial.println(Sens3);
if (Count==4){
Serial.println(Sens4);
}
if (Count==5){
Serial.println(Sens5);
Count=0;
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
81
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == 'A') {
MODE=1;
}
}
}
82
PHYTON Coding
import BlynkLib
import time
import serial
import RPi.GPIO as GPIO
STAT="0"
BUZZ = 23
GPIO.setup(BUZZ,GPIO.OUT)
T=0
BLYNK_AUTH ='quJuB8TwDl8GITidbULSBoEFwDoH4ECc'
blynk = BlynkLib.Blynk(BLYNK_AUTH, server='139.59.206.133', port=80,
heartbeat=30, log=print )
ser = serial.Serial(
port='/dev/ttyS0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
83
if (str(value)=="['0']"):
GPIO.output(BUZZ, False)
if (str(value)=="['3']"):
GPIO.output(BUZZ, True)
time.sleep(0.02)
GPIO.output(BUZZ, False)
time.sleep(0.02)
GPIO.output(BUZZ, True)
time.sleep(0.02)
GPIO.output(BUZZ, False)
time.sleep(0.02)
GPIO.output(BUZZ, True)
time.sleep(0.02)
GPIO.output(BUZZ, False)
time.sleep(0.02)
if (str(value)=="['2']"):
GPIO.output(BUZZ, True)
time.sleep(0.2)
GPIO.output(BUZZ, False)
time.sleep(0.2)
84
GPIO.output(BUZZ, True)
time.sleep(0.2)
GPIO.output(BUZZ, False)
time.sleep(0.2)
if (str(value)=="['0']"):
GPIO.output(BUZZ, False)
if (str(value)=="['5']"):
ser.write("A".encode())
blynk.notify("DEVICE IS NOW ONLINE!")
@blynk.VIRTUAL_READ(0)
def my_read_handler():
blynk.virtual_write(0, SENS1)
@blynk.VIRTUAL_READ(1)
def my_read_handler():
blynk.virtual_write(1, SENS2)
@blynk.VIRTUAL_READ(2)
def my_read_handler():
blynk.virtual_write(2, SENS3)
@blynk.VIRTUAL_READ(3)
def my_read_handler():
blynk.virtual_write(3, SENS4)
@blynk.VIRTUAL_READ(4)
def my_read_handler():
blynk.virtual_write(4, SENS5)
85
while True:
#while ser.in_waiting:
x=ser.readline()
finalValue = x.decode('utf-8').replace('\r','').replace('\n','')
if (str(finalValue)):
if (T==4):
print (finalValue)
SENS5=(finalValue)
blynk.virtual_write(4, SENS5)
T += 1
if (T==3):
print (finalValue)
SENS4=(finalValue)
blynk.virtual_write(3, SENS4)
T += 1
if (T==2):
print (finalValue)
SENS3=(finalValue)
blynk.virtual_write(2, SENS3)
T += 1
if (T==1):
86
print (finalValue)
SENS2=(finalValue)
T += 1
blynk.virtual_write(1, SENS2)
if (T==0):
print (finalValue)
SENS1=(finalValue)
T += 1
blynk.virtual_write(0, SENS1)
if (T==5):
T=0
#PH=(finalValue)PH
blynk.run()
87
APPENDIX
Gantt Chart
Week
2 3 4 5 6 7 8 9 10 11 12 13 14
No. Content
1 Briefing PSM 1
8 Presentation preparation
Planned
Actual