Vous êtes sur la page 1sur 71

Smart Asthma Meter With Internet of Things

ABSTRACT

There are 300 million people suffering from asthma worldwide. It is a chronic disease, which requires
regular self-monitoring and strict control of medication. Apart from watching for signs and symptoms, including
coughs and wheezes, doctors advise their patients to perform Lung Capacity checks on a regular basis and to
record the results.

This system helps the Asthma patients as well as the doctor to know about the lung capacity of the patient.
In this project, we are interested to take a sensor which is a transducer that converts our air pressure into an
equivalent voltage level. Thus, it is an analog input and based on the output voltage generated, Peak Time and
Peak Voltage can be calibrated.

As the sensor employed is of very less cost, the total cost of the device has drastically come down. This
makes it affordable to all people. Doctor suggests treatment to asthma patients based on these two parameters,
so when we interface these two values to the doctor then the doctor can guide the patient to the right level. This
can act as a Wearable Device where every asthma patient can take suggestions from the doctor by sending their
data through Internet of Things (IOT) framework.

The transducer used is a DYNAMO which converts the Mechanical energy of the patients blow to electrical
energy. Basing on the voltage generated by the patients blow the Peak Time is calibrated and programmed in the
MSP – Controller. The controller has Bluetooth drive connected to it which transmits the recorded peak time to
the patient’s mobile phone. The application in patients mobile receives the data from the controller, displays it
to the patient and updates the values to the IOT framework in built in the application. The IOT framework has
been interfaced with the doctor so that he can access the values at any time. It also has the feature to store the
recorded values of previous three months.

Thus it will be easier to access the previous values and conclude for the best prescription for the patients.
Existing peak flow meters require the user to remember and follow the procedure to take peak flow
measurements and thus have reduced compliance.

This system is a low cost, portable, Smartphone compatible peak flow meter design that connects to a
Smartphone through the Bluetooth drive. Asthma meter can show you that you may need to change the way you
are using your medicines. For example, the readings may help be a signal for patient to implement the
medication plan doctor had developed for worsening asthma On the other hand, if the patient is doing well, then
measuring the readings may be helpful as doctor try to lower the level of your medicines.

Dept of ECE page 1


Smart Asthma Meter With Internet of Things

Hardware Components Used:

1. MSP 430 G2253 Controller


2. Bluetooth Module HC 05
3. LCD Display
4. 9V Battery
5. LM1117-N Dropout Linear Regulator
6. Dynamo
7. Smart Phone
8. Laptop or a PC

Software Tools Used:

1. Eclipse
2. HTML
3. Energia
4. Internet Of Things (IoT)

Dept of ECE page 2


Smart Asthma Meter With Internet of Things

INDEX
Topic Page No
1.Introduction 9

2.Literaure Survey 11

3.Patient UI 13

3.1 Patient 14

3.2 Pipe Mechanism 14

3.3 Transducer 15

3.4 MSP – 430 16

3.5 Bluetooth Module 24

3.6 LCD Display 27

3.7 LM1117 IC 29

4. Data UI 30

4.1 Crating Android Application 31

4.2 IoT 41

5. Doctor UI 46

5.1 Webpage Development 47

6. Code 50

6.1 Android Application 51

6.2 Webpage 60

6.3 Project CODE/ CODE FOR MSP 62

7. Testing And Results 66

8. Salient Features And Disadvantages 71

9. Conclusion And Future Scope 73

10. References 75

Dept of ECE page 3


Smart Asthma Meter With Internet of Things

List Of Figures:

Figure No. Figure Name Page NO

1 Existing Peak Flow Meter 12


2 Block Diagram For Patient User Interface 14
3 Working Of Dynamo 16
4 Msp Launch Pad 18
5 Starting Energia 21
6 Bluetooth Module 24
7 Interfacing Bluetooth To Msp 26
8 LCD Display 27
9 Lm1117 Regulator IC 29
10 Data UI Block Diagram 31
11 Asthma Meter Android Application 40
12 Doctor UI Block Diagram 47
13 Testing And Results 67-70
13.1 Staring Application
13.2 Bluetooth Prompt
13.3 Pairing Bluetooth To Hc-05
13.4 Asthma Meter On Startup
13.5 Android Application On Startup
13.6 Blowing Mechanism For Asthma Meter
13.7 Values Recorded In Application
13.8 Values Displayed In Asthma Meter
13.9 Login Page For Doctor
13.10 Plotted Graphs Of Asthma Levels

List Of Tables:

Table no Table name Page no


1 Pin Description Of Bluetooth Drive 25

2 Pin Functions Of LCD Display 29

3 Features Of Android 33

Dept of ECE page 4


Smart Asthma Meter With Internet of Things

CHAPTER 1
INTRODUCTION

Dept of ECE page 5


Smart Asthma Meter With Internet of Things

INTRODUCTION

Asthma is a chronic air way inflammatory disease that restricts airflow in lungs through acute
reduction of airway by a combination of smooth muscle constriction, swelling, and increased mucus
secretion. While there is no cure for asthma, the disease can be controlled by avoiding or removing triggers,
closely monitoring lung function, and medication management.

The home environment is essential to the prevention, control, and treatment of asthma. Home care
includes self-monitoring using peak expiratory flow (PEF) device and a written asthma action plan.

The ASTHMA METER is used to measure the volume of forced exhalation, and is a reliable and
objective measure to signify potential onset of exacerbation before symptoms are felt, determine the severity
of exacerbations, and evaluate treatment. Existing peak flow meters require the user to remember and follow
the procedure to take peak flow measurements and thus have reduced compliance. This system is a low cost,
portable, smart phone compatible peak flow meter design that connects to a smart phone through the
Bluetooth.

The target audience for ASTHMA METER is low-socioeconomic status patients with asthma, and at
risk for depression or anxiety. Lifetime incidences of depression (30.6%) and anxiety (23.5%) among persons
with asthma are significantly greater than the incidences among persons without asthma (14.4% and 10.2%,
respectively) (Strine et al., 2008). With the help of a custom smart phone application (app) and INTERNET
OF THINGS (IoT) technologies, this system will allow patients and their clinicians to monitor patients’
asthma health by tracking asthma-related peak values and how they relate to one another.

The Asthma meter can help patient when his asthma is getting worse. Asthma sometimes changes
gradually. His readings may show changes before he feel them. It can allow his health care provider to adjust
his treatment to prevent urgent calls to the health care provider, emergency room visits or hospitalizations.

A peak flow meter is not a medicine; hence for most of the people, it has no major side effects. So it
is a kind of precaution with no side effects. It encourages patients to self-monitor their asthma health
constantly without negligence increase adherence of medication usage depending upon the recorded blow
intensities

Dept of ECE page 6


Smart Asthma Meter With Internet of Things

CHAPTER 2
LITERATURE SURVEY

Dept of ECE page 7


Smart Asthma Meter With Internet of Things

LITERATURE SURVEY
The Existing system available for checking asthma level is PEAK FLOW METER. These Peak flow
meters are costly when compared to the cost of ASTHMA METER.

Apart from being costly these peak flow meters are calibrated for only calculating Peak Time and only
understandable by a doctor whereas the asthma meter readings can be understandable by everyone when the
calibrated readings and their intensities are provided.

The main use of asthma meter is its property of internet of things. This means the doctor can login to the
interface provided and monitor any patients asthma levels. This also comes handy in emergency situations
whereas the peak flow meter fails at such case.

The interface also has a property to store previously recorded values which the peak flow meter lacks.
Using this, the doctor and patient can analyze his progress across the month and change the prescription
accordingly.

Hence the peak flow meter allows the doctor to monitor the patient even if he is out of station just through
a click which helps the patients under observation to a large extent and peak flow meter doesn’t have this
property

Hence using the asthma meter will be helpful to people with low socio economic status and better
prescription yields to lower the costs for the medicines

Figure 1 : Existing Peak Flow Meters

Dept of ECE page 8


Smart Asthma Meter With Internet of Things

CHAPTER 3
PATIENT USER INTERFACE

Dept of ECE page 9


Smart Asthma Meter With Internet of Things

PATIENT USER INTERFACE

Figure 2 : Block diagram for Patient UI

3.1 Patient:
The patient block in the patient User Interface refers to a patient who is confirmed for asthma by a certified
clinician. He has to undergo the tests recommended by the doctor before confirming his asthma.

The patient in order to check his asthma levels has to blow into the pipe mechanism provided. The blow
intensity should be the maximum of the person could exert upon, failing which may result in false results. The
patient can record his readings twice or thrice and reach a conclusion upon the values with minimal error.

3.2 Pipe Mechanism:


A Pipe mechanism has been designed in order make it convenient for the patient to blow. This mechanism is
mainly implemented to focus the total blow intensity onto the fans of the dynamo.

An inlet and an outlet are provided for the airway allowing easy motion. The blowing angle has been kept
tangential to the fans of the dynamo and fixed, because blowing at any other incident angle cannot rotate the
fans of the dynamo and hence errors may occur. A transparent pipe with enough radius has been provided for
input which should be disinfected regularly if used among multiple persons.
Dept of ECE page 10
Smart Asthma Meter With Internet of Things

3.3 Transducer:
The transducer used is a dynamo whose principal is to convert the mechanical energy to electrical energy.
Dynamo is used here to convert the mechanical energy produced from the blow of the patient to electrical
energy or equivalent voltage levels.

Working principle of dynamo:


An electric motor is essentially just a tight coil of copper wire wrapped around an iron core that's free to
rotate at high speed inside a powerful, permanent magnet. When you feed electricity into the copper coil, it
becomes a temporary, electrically powered magnet in other words, an electromagnet and generates a magnetic
field all around it. This temporary magnetic field pushes against the magnetic field that the permanent magnet
creates and forces the coil to rotate. By a bit of clever design, the coil can be made to rotate continuously in the
same direction, spinning round and round and powering anything from an electric toothbrush to an electric train.

So, Suppose we have an electric toothbrush with a rechargeable battery inside. Instead of letting the battery
power the motor that pushes the brush, what if you did the opposite? What if you turned the brush back and
forth repeatedly? What you'd be doing would be manually turning the electric motor's axle around. That would
make the copper coil inside the motor turn around repeatedly inside its permanent magnet. If you move an
electric wire inside the magnetic field, you make electricity flow through the wire in effect, you generate
electricity. So keep turning the toothbrush long enough and, in theory, you would generate enough electricity to
recharge its battery. That, in effect, is how a generator works.

Figure 3: Working of a Dynamo

Use of Dynamo In The Project:

In this project dynamo is used at input terminal. The patient’s blow intensity is incident on the fans of the
dynamo. The angle is set such that the fans rotate even if little pressure is exerted. This increases the sensitivity
of the whole system.

Dept of ECE page 11


Smart Asthma Meter With Internet of Things

When the patients blow rotates the fan the Iron core attached to the fan rotates which is wound by copper
wire. The iron core is placed in strong magnetic field. When iron core gets rotated in strong magnetic field some
current is produced in the conductor. The current produced depends upon the speed with which the core rotates
i.e., more cutting of magnetic lines implies more production of current. Hence the voltage produced is
analogous to the intensity of blow. The voltage levels from the dynamo are fed to controller and calibrated
accordingly

3.4 MSP – 430 LAUNCH PAD:


Overview

The MSP-EXP430G2 low-cost experimenter board called Launch Pad is a complete development solution
for the Texas Instruments MSP430G2xx Value Line series. The integrated USB-based emulator offers all the
hardware and software necessary to develop applications for all MSP430G2xx series devices. The Launch Pad
has an integrated DIP target socket that supports up to 20 pins, allowing MSP430™ Value Line devices to be
dropped into the Launch Pad board. It also offers an on-board flash emulation tool allowing direct interface to a
PC for easy programming, debugging, and evaluation. The Launch Pad experimenter board is capable of
programming the eZ430-RF2500T target boards, the eZ430-Chronos watch module or the eZ430-
F2012T/F2013T target boards. The USB interface provides a 9600-Baud UART serial connection from the
MSP430G2xx device to the host PC or a connected target board.

The MSP-EXP430G2 can be used with IAR Embedded Workbench™ Integrated Development Environment
(IDE) or Code Composer Studio™ (CCS) IDE to write, download, and debug applications. The debugger is
unobtrusive, allowing the user to run an application at full speed with hardware breakpoints and single stepping
available while consuming no extra hardware resources.

MSP-EXP430G2 Launch Pad features:

• USB debugging and programming interface featuring a driverless installation and application UART serial
communication with up to 9600 Baud

• Supports all MSP430G2xx and MSP430F20xx devices in PDIP14 or PDIP20 packages

• Two general-purpose digital I/O pins connected to green and red LEDs for visual feedback

• Two push button for user feedback and device reset

• Easily accessible device pins for debugging purposes or as socket for adding customized extension boards

• High-quality 20-pin DIP socket for an easy plug-in or removal of the target device

Dept of ECE page 12


Smart Asthma Meter With Internet of Things

Kit Contents:

The MSP-EXP430G2 experimenter kit includes the following hardware:

• LaunchPad emulator socket board (MSP-EXP430G2)


• Mini USB-B cable, 0.5 m
• Two MSP430 flash devices
– MSP430G2553: Low-power 16-bit MSP430 microcontroller with an 8-channel 10-bit ADC, on-
chip comparator, touch-sense enabled I/Os, universal serial communication interface, 16kB flash
memory, and 512 bytes of RAM (preloaded with a sample program)

– MSP430G2452: Low-power 16-bit MSP430 microcontroller with an 8-channel 10-bit ADC, on-chip
comparator, touch-sense enabled I/Os, universal serial interface, 8kB flash memory, and 256 bytes
of SRAM

• Two 10-pin PCB connectors female


• 32.768-kHz clock crystal from Micro Crystal
• Quick start guide
• Two LaunchPad stickers

Figure 4 : MSP Launch Pad

Description:

 Universal Serial Communication Interface (USCI)


– Enhanced UART Supporting Auto Baud rate Detection (LIN)
– IrDA Encoder and Decoder
– Synchronous SPI
Dept of ECE page 13
Smart Asthma Meter With Internet of Things

– I2C™
 On-Chip Comparator for Analog Signal Compare Function or Slope Analog-to-Digital (A/D)
Conversion
 10-Bit 200-ksps Analog-to-Digital (A/D) Converter With Internal Reference, Sample-and-Hold, and
Auto scan
 Brownout Detector
 Serial Onboard Programming,
 No External Programming Voltage Needed, Programmable Code Protection by Security Fuse
 On-Chip Emulation Logic With Spy-Bi-Wire Interface
 Package Options
– TSSOP: 20 Pin, 28 Pin
– PDIP: 20 Pin
– QFN: 32
MSP PORTS Interfaced In The Project :

1. Vcc pin of the msp controller is connected to a 3.3V Power supply which is generated using an external
battery. An LM1117 IC is used to drop down the voltage from 9V to 3.3 V

2. The GND pin of the msp controller is connected to the Ground of the power supply.

3. The Bluetooth drive is interfaced to the controller at port 2 i.e., at P2.5 & P2.6 terminals

P2.5 - transmitter of Bluetooth drive.

P2.6 - Receiver of Bluetooth drive.

GND - GND

4. Dynamo is connected to msp controller at port 2 i.e., at P2.7

5. LCD Display is interfaced to msp controller at port1. The port no’s and LCD terminals are as follows

LCD MSP Controller


Pin 4 RS P1.0
Pin5 R/W P1.1
Pin6 ENABLE P1.2
Pin 11 D0 P1.3
Pin 12 D1 P1.4
Pin 13 D2 P1.5
Pin 14 D3 P1.6

Dept of ECE page 14


Smart Asthma Meter With Internet of Things

Programming MSP 430:

Energia:

Energia is an open-source electronics prototyping platform started by Robert Wessels in January of 2012
with the goal to bring the Wiring and Arduino framework to the Texas Instruments MSP430 based
LaunchPad. The Energia IDE is cross platform and supported on Mac OS, Windows, and Linux. Energia uses
the mspgcc compiler by Peter Bigot and is based on the Wiring and Arduino framework. Energia includes an
integrated development environment (IDE) that is based on Processing.

The foundation of Energia and Arduino is the Wiring framework that is developed by Hernando
Barragan. The framework is thoughtfully created with designers and artists in mind to encourage a
community where both beginners and experts from around the world share ideas, knowledge and their
collective experience. The Energia team adopts the philosophy of learning by doing and strives to make it easy
to work directly with the hardware. Professional engineers, entrepreneurs, makers, and students can all benefit
from the ease of use Energia brings to the microcontroller.

Energia started out to bring the Wiring and Arduino framework to the Texas Instruments
MSP430 LaunchPad. Texas Instruments offers a MSP430, MSP432, TM4C, C2000, and
CC3200 LaunchPad. The LaunchPad is a low-cost microcontroller board that is made by Texas
Instruments. The latest release of Energia supports the majority of the LaunchPad product offerings. Together
with Energia, Launch Pad can be used to develop interactive objects, taking inputs from a variety of
switches or sensors, and controlling a variety of lights, motors, and other physical outputs. LaunchPad
projects can be stand-alone (only run on the Target Board, i.e. your LaunchPad), or they can communicate
with software running on your computer (Host PC)

Dept of ECE page 15


Smart Asthma Meter With Internet of Things

Setup Energia on Windows

Figure 5: Starting Energia

Installing the LaunchPad drivers:

To use Energia you will need to have the LaunchPad drivers installed.

If TI's Code Composer Studio 5.x with MSP430 Support is already installed on your computer then the drivers are
already installed. Skip to the next step.

1. Download the LaunchPad drivers for Windows:

MSP-EXP430G2 and MSP-EXP430FR5739 drivers zip file for Windows 32 and 64 bit

MSP-EXP430F5529LP driver zip file for Windows 32 and 64 bit

EK-LM4F120XL and EK-TM4C123GXL driver zip file for Windows 32 and 64 bit

2. Unzip and double click DPinst.exe for Windows 32bit or DPinst64.exe for Windows 64 bit.

3. Follow the installer instructions

 Starting energia
 Selecting the serial ports
 Selecting the board
 Uploading Your First Blinky Sketch
 Uploading to MSP430

Dept of ECE page 16


Smart Asthma Meter With Internet of Things

Selecting the Serial Port


Select Serial Port from the Tools menu to view the available serial ports. On windows, they will be listed as
COMXXX port and usually a higher number is the LaunchPad com port

Selecting the Board

To select the board or rather the msp430 in your LaunchPad, select Board from the Tools menu and choose
the board that matched the msp430 in the LaunchPad.

Dept of ECE page 17


Smart Asthma Meter With Internet of Things

Uploading Your First Blinky Sketch

To load the Blinky example into the editor, select Blink from the Blink from the File->Examples-

>1.Basics menu.

Uploading to MSP430

Dept of ECE page 18


Smart Asthma Meter With Internet of Things

3.5 BLUETOOTH MODULE HC- 05:

Figure 6 : Bluetooth Module

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent
wireless serial connection setup. Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR
(Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR
Blue core 04‐External single chip Bluetooth system with CMOS technology and with AFH (Adaptive
Frequency Hopping Feature).

Hardware features:

 Typical 80dBm sensitivity.

 Up to +4dBm RF transmit power.

 Low Power 1.8V Operation, 3.3 to 5 V I/O.

 UART interface with programmable baud rate.

 With integrated antenna.

 With edge connector.

●Has External 8 Mb Flash

● Has a 2.4GHz digital wireless transceiver.

● Storage temperature range: -40 ℃ - 85℃, operating temperature range: -25 ℃ - +75℃

Dept of ECE page 19


Smart Asthma Meter With Internet of Things

● Low power consumption

●Application fields:

 Bluetooth Car Hands free Device


 Bluetooth GPS
 Bluetooth PCMCIA , USB Dongle
 Bluetooth Data Transfer

Software features:

 Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.

 PIO9 and PIO8 can be connected to red and blue led separately. When master and slave are paired, red and
blue led blinks 1time/2s in interval, while disconnected only blue led blinks 2times/s.

 Auto connect to the last device on power as default.

 Permit pairing device to connect as default.

 Auto pairing PINCODE:”1234” as default.

 Auto reconnect in 30 min when disconnected as a result of beyond the range of connection.

Pins Description:

Table 1: Pin Description Of Bluetooth Drive

Pin Out Configuration:

Dept of ECE page 20


Smart Asthma Meter With Internet of Things

Interfacing Bluetooth To Msp Controller:

Figure 7 : Interfacing Bluetooth to MSP Micro Controller

Establishing a Connection With the controller:

 First connect the Bluetooth with the controller as shown above.


 Now scan for new devices from the PC/Mobile and you will find the module with the device name “HC
05”.
 After that, click to connect, if some message appears asking about “Pairing code” just put “1234” as
default code.

Getting Standard Communication Mode:

 Leave free KEY, don’t connect it to VDD neither GND.

Dept of ECE page 21


Smart Asthma Meter With Internet of Things

 Supply power to the module. Then the module will enter to communication mode. It can be used for
pairing.

3.6 LIQUID CRYSTAL DISPLAY (LCD):


LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs (seven segment
LEDs or other multi segment LEDs) because of the following reasons:

1. The declining prices of LCDs.


2. The ability to display numbers, characters and graphics. This is in contrast to LEDs, which are limited to
numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing
the LCD. In contrast, the LED must be refreshed by the CPU to keep displaying the data.

Figure 8: LCD Display

A model described here is for its low price and great possibilities most frequently used in practice. It is
based on the HD44780 microcontroller (Hitachi) and can display messages in two lines with 16 characters each.
It displays all the alphabets, Greek letters, punctuation marks, mathematical symbols etc. In addition, it is
possible to display symbols that user makes up on its own.
Pins Functions

There are pins along one side of the small printed board used for connection to the microcontroller.
There are total of 14 pins marked with numbers (16 in case the background light is built in). Their function is
described in the table below:

Dept of ECE page 22


Smart Asthma Meter With Internet of Things

Function Pin Number Name Logic State Description

Ground 1 Vss - 0V

Power supply 2 Vdd - +5V

Contrast 3 Vee - 0 – Vdd

Control of operating 4 RS 0 D0 – D7 are interpreted as


1 commands
D0 – D7 are interpreted as data

5 R/W 0 Write data (from controller to


1 LCD)
Read data (from LCD to controller)
6 E 0 Access to LCD disabled
1 Normal operating
From 1 to 0 Data/commands are transferred to
LCD
Data / commands 7 D0 0/1 Bit 0 LSB

8 D1 0/1 Bit 1
9 D2 0/1 Bit 2
10 D3 0/1 Bit 3
11 D4 0/1 Bit 4
12 D5 0/1 Bit 5
13 D6 0/1 Bit 6
14 D7 0/1 Bit 7 MSB

Table 2: Pin Functions Of LCD Display

Dept of ECE page 23


Smart Asthma Meter With Internet of Things

3.7 LM1117-N/LM1117I 800MA LOW-DROPOUT LINEAR REGULATOR


FEATURES DESCRIPTION 2 The LM1117-N is a series of low dropout voltage

• Available in 1.8V, 2.5V, 2.85V, 3.3V, 5V variation

• Space Saving SOT-223 and WSON Packages.

• Current Limiting and Thermal Protection

• Output Current 800mA

• Line Regulation 0.2% (Max)

• Load Regulation 0.4% (Max)

Application

• 2.85V Model for SCSI-2 Active Termination

• Post Regulator for Switching DC/DC Converter

• High Efficiency Linear Regulators stability.

• Battery Charger

• Battery Powered Instrumentation

Figure 9: LM1117 REGULATOR IC

Dept of ECE page 24


Smart Asthma Meter With Internet of Things

Chapter 4
DATA USER INTERFACE

Dept of ECE page 25


Smart Asthma Meter With Internet of Things

DATA USER INTERFACE

Figure 10: Data UI

4.1 CREATING ANDROID APPLICATION:


Android:

Android is an open source and Linux-based Operating System for mobile devices such as smartphones and
tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies.

Android offers a unified approach to application development for mobile devices which means
developers need only develop for Android, and their applications should be able to run on different devices
powered by Android.

The first beta version of the Android Software Development Kit (SDK) was released by Google in 2007
where as the first commercial version, Android 1.0, was released in September 2008.

On June 27, 2012, at the Google I/O conference, Google announced the next Android version, 4.1 Jelly Bean.
Jelly Bean is an incremental update, with the primary aim of improving the user interface, both in terms of
functionality and performance.

The source code for Android is available under free and open source software licenses. Google publishes
most of the code under the Apache License version 2.0 and the rest, Linux kernel changes, under the GNU
General Public License version 2

Dept of ECE page 26


Smart Asthma Meter With Internet of Things

Features of Android:

Android is a powerful operating system competing with Apple 4GS and supports great features. Few of them are listed
below

Feature Description
Beautiful UI Android OS basic screen provides a beautiful and intuitive user interface.

Connectivity GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and WiMAX.

Storage SQLite
Media support H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1,
MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP
Messaging SMS and MMS

Web browser Based on the open-source WebKit layout engine, coupled with Chrome's V8
JavaScript , HTML5 and CSS3.
Multi-touch
Android has native support for multi-touch which was initially made available
Multi-tasking in handsets such as the HTC Hero.
User can jump from one task to another and same time various application can
Resizable widgets run simultaneously.
Widgets are resizable, so users can expand them to show more content or shrink
them to save
Multi-Language Supports singlespace
direction and bidirectional text
GCM Google Cloud Messaging (GCM) is a service that lets developers send short message
data to their users on Android devices, without needing a proprietary sync solution.
Wi-Fi Direct A technology that lets apps discover and pair directly, over a high-bandwidth peer-
to- peer connection.
Table 3: features of andorid

Android Applications:

Android applications are usually developed in the Java language using the Android Software Development
Kit.Once developed, Android applications can be packaged easily and sold out either through a store such as
Google

Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It's the
largest installed base of any mobile platform and growing fast. Every day more than 1 million new Android
devices are activated worldwide.

Dept of ECE page 27


Smart Asthma Meter With Internet of Things

This tutorial has been written with an aim to teach you how to develop and package Android application.
We will start from environment setup for Android application programming and then drill down to look
into various aspects of Android applications.

Environment Setup:

 You will be glad to know that you can start your Android application development on either of the
following operating systems:
 Microsoft Windows XP or later version.
 Mac OS X 10.5.8 or later version with Intel chip.
 Linux including GNU C Library 2.7 or later.
 Second point is that all the required tools to develop Android applications are freely available
and can be downloaded from the Web. Following is the list of software's you will need before you
start your Android application programming.
 Java JDK5 or JDK6
 Android SDK
 Eclipse IDE for Java Developers (optional)
 Android Development Tools (ADT) Eclipse Plugin (optional)

Step 1 – Setup Java Development Kit(JDK)

You can download the latest version of Java JDK from Oracle's Java site: Java SE Downloads. You
will find instructions for installing JDK in downloaded files, follow the given instructions to install and
configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory
that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.

If you are running Windows and installed the JDK in C:\jdk1.6.0_15, you would have to put the
following line in your C:\autoexec.bat file.

set PATH=C:\jdk1.6.0_15\bin;%PATH%

set JAVA_HOME=C:\jdk1.6.0_15

Alternatively, you could also right-click on My Computer, select Properties, then Advanced, then
Environment Variables. Then, you would update the PATH value and press the OK button.On Linux, if the
SDK is installed in /usr/local/jdk1.6.0_15 and you use the C shell, you would put the following code into
your .cshrc file

Step 2 – Setup Android SDK

Dept of ECE page 28


Smart Asthma Meter With Internet of Things

You can download the latest version of Android SDK from Android official website Android SDK
Downloads. If you are installing SDK on Windows machine, then you will find a installer_rXX-
windows.exe, so just download and run this exe which will launch Android SDK Tool Setup wizard to
guide you through out of the installation, so just follow the instructions carefully. Finally you will have
Android SDK Tools installed on your machine. If you are installing SDK either on Mac OS or
Linux, check the instructions provided along with the downloaded android- sdk_rXX-linux.tgz file
for Linux. This tutorial will consider that you are going to setup your environment on Windows
machine having Windows 7 operating system. So let's launch Android SDK Manager using the option All
Programs > Android SDK Tools > SDK Manager, this will give you following window

SDK packages to reduce installation time. Next click Install 7 Packages button to proceed, which will
display following dialogue box:

Dept of ECE page 29


Smart Asthma Meter With Internet of Things

If you agree to install all the packages, select Accept All radio button and proceed by clicking Install
button. Now let SDK manager do its work and you go, pick up a cup of coffee and wait until all the
packages are installed. It may take some time depending on your internet connection. Once all the
packages are installed, you can close SDK manager using top-right cross button

Step 3 - Setup Eclipse IDE

All the examples in this tutorial have been written using Eclipse IDE. So I would suggest you
should have latest version of Eclipse installed on your machine.

Eclipse can be started by executing the following commands on windows machine, or you can simply
double c lick on eclipse.exe

%C:\eclipse\eclipse.exe

Eclipse can be started by executing the following commands on Linux machine:

$/usr/local/eclipse/eclipse

After a successful startup, if everything is fine then it should display following result:

Dept of ECE page 30


Smart Asthma Meter With Internet of Things

Step 4 – Setup Android Development Tools (ADT) plugin

This step will help you in setting Android Development Tool plugin for Eclipse. Let's start with
launching Eclipse and then, choose Help > Software Updates > Install New Software. This will display the
following dialogue box.

Dept of ECE page 31


Smart Asthma Meter With Internet of Things

Dept of ECE page 32


Smart Asthma Meter With Internet of Things

Create Android Application

The first step is to create a simple Android Application using Eclipse IDE. Follow the option
File -> New -> Project and finally select Android New Application wizard from the wizard list. Now
name your application as HelloWorld using the wizard window as follows:

Next, follow the instructions provided and keep all other entries as default till the final step. Once your
project is created successfully, you will have following project screen

Dept of ECE page 33


Smart Asthma Meter With Internet of Things

Anatomy of Android Application

Dept of ECE page 34


Smart Asthma Meter With Internet of Things

Asthma meter application:

Figure 11: Asthma Meter Application

Dept of ECE page 35


Smart Asthma Meter With Internet of Things

4.2 IOT (INTERNET OF THINGS):


The next wave in the era of computing will be outside the realm of the traditional desktop. In the
Internet of Things (IoT) paradigm, many of the objects that surround us will be on the network in one form or
another. Radio Frequency Identification (RFID) and sensor network technologies will rise to meet this new
challenge, in which information and communication systems are invisibly embedded in the environment
around us. This results in the generation of enormous amounts of data which have to be stored, processed and
presented in a seamless, efficient, and easily interpretable form. This model will consist of services that are
commodities and delivered in a manner similar to traditional commodities. Cloud computing can provide the
virtual infrastructure for such utility computing which integrates monitoring devices storage devices, analytics
tools, visualization platforms and client delivery. The cost based model that Cloud computing offers will enable
end-to-end service provisioning for businesses and users to access applications on demand from anywhere.

Smart connectivity with existing networks and context-aware computation using network
resources is an indispensable part of IoT. With the growing presence of Wi-Fi and 4G-LTE wireless Internet
access, the evolution toward ubiquitous information and communication networks is already evident.
However, for the Internet of Things vision to successfully emerge, the computing paradigm will need to go
beyond traditional mobile computing scenarios that use smart phones and portables, and evolve into
connecting everyday existing objects and embedding intelligence into our environment. For technology to
disappear from the consciousness of the user, the Internet of Things demands: (1) a shared understanding of
the situation of its users and their appliances, (2) software architectures and pervasive communication
networks to process and convey the contextual information to where it is relevant, and (3) the analytics tools
in the Internet of Things that aim for autonomous and smart behavior. With these three fundamental
grounds in place, smart connectivity and context-aware computation can be accomplished.

The term Internet of Things was first coined by Kevin Ashton in 1999 in the context of supply chain
management. However, in the past decade, the definition has been more inclusive covering wide range of
applications like healthcare, utilities, transport, etc. Although the definition of Things has changed as
technology evolved, the main goal of making computer sense information without the aid of human
intervention remains the same. A radical evolution of the current Internet into a Network of interconnected
objects that not only harvests information from the environment (sensing) and interacts with the physical
world (actuation/command/control), but also uses existing Internet standards to provide services for
information transfer, analytics, applications, and communications. Fuelled by the prevalence of devices
enabled by open wireless technology such as Bluetooth, radio frequency identification (RFID), Wi-Fi,
and telephonic data services as well as embedded sensor and actuator nodes, IoT has stepped out of its infancy
and is on the verge of transforming the current static Internet into a fully integrated Future Internet.

Dept of ECE page 36


Smart Asthma Meter With Internet of Things

The Internet revolution led to the interconnection between people at an unprecedented scale and pace.
The next revolution will be the interconnection between objects to create a smart environment. Only in 2011,
the number of interconnected devices on the planet overtook the actual number of people. Currently there are 9
billion interconnected devices and it is expected to reach 24 billion devices by

2020. According to the GSMA, this amounts to $1.3 trillion revenue opportunities for mobile network
operators alone spanning vertical segments such as health, automotive, utilities and consumer electronics. A
schematic of the interconnection of objects is depicted, where the application domains are chosen based on
the scale of the impact of the data generated. The users span from an individual to national level organizations
addressing wide ranging issues.

IoT Elements

We present a taxonomy that will aid in defining the components required for Internet of Things from a
high level perspective. Specific taxonomies of each component can be found elsewhere [12-14]. There are
three IoT components which enables seamless ubicomp: a) Hardware - made up of sensors, actuators and
embedded communication hardware b) Middleware - on demand storage and computing tools for data
analytics and c) Presentation - novel easy to understand visualization and interpretation tools which can be
widely accessed on different platforms and which can be designed for different applications. In this section,
we discuss a few enabling technologies in these categories which will make up the three components stated
above

These systems show characteristics such as interoperability, integration and adaptive communications.
They also have a modular architecture both in terms of hardware system design as well as software
development and are usually very well-suited for IoT applications. More importantly, a centralized
infrastructure to support storage and analytics is required. This forms the IoT middleware layer and there are
numerous challenges involved which are discussed in future sections. As of 2012, Cloud based storage
solutions are becoming increasingly popular and in the years ahead, Cloud based analytics and visualization
platforms are foreseen.

Accessing plugins

Getting Started

Quick Start

1. Sign Up for a Thing Speak account

2. Create a new Channel by going to your Channels page and clicking Create New Channel

3. Update your Channel via URL:

https://api.thingspeak.com/update?api_key=YOUR_CHANNEL_API_KEY&field1=7
Dept of ECE page 37
Smart Asthma Meter With Internet of Things

4. View your Channel feed:

https://api.thingspeak.com/channels/YOUR_CHANNEL_ID/feeds.json

Channels

Channels are where your application stores and retrieves any type of data. Each channel has a Private
View and a Public View. The Private View is only accessible by signing into your ThingSpeak.com user
account. The Public View is what other viewers will see when they visit your ThingSpeak Channel. You can
have different info on each view, customize the view with Plugins, and even disable the Public View

Channel API

To read and write to a ThingSpeak Channel, your application must make requests to the ThingSpeak
API using HTTP requests. Each ThingSpeak Channel allows for 8 fields of data (both numeric and
alphanumeric formats), location information, and a status update. Each entry is stored with a date and time
stamp and is assigned a unique Entry ID (entry_id). After the data is stored, you can retrieve the data by time
selection or by Entry ID. In addition to storing and retrieving numeric and alphanumeric data, the
ThingSpeak API allows for numeric data processing such as timescaling, averaging, median, summing, and
rounding. The channel feeds supports JSON, XML, and CSV formats for integration into applications

API Keys

Private / Public Channels

By default, your channel is private and requires a Read API Key to access its feed. You can make a channel
public which gives other users the ability to use your feed without a Read API Key.

Write API Key

In order to update a channel, you need to know your Write API Key. If your Write API Key gets
compromised you can generate a new key.

Follow these steps to get your Write API Key:

 Select Channels
 Select the Channel to update
 Select Manage API Keys

Read API Key

The Read API Key allows your application to read data from the API. You can generate multiple

Dept of ECE page 38


Smart Asthma Meter With Internet of Things

Read API Keys for different applications

Follow these steps to get a Read API Key:

 Select Channels

 Select the Channel to update

 Select Manage API Keys

 Select Generate New Read API Key

Get a Channel Feed:

To view a Channel feed, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/feeds ,


replacing CHANNEL_ID with the ID of your Channel.

Valid par

 api_key (string) Read API Key for this specific Channel (optional--no key required for public
channels)
 results (integer) Number of entries to retrieve, 8000 max, default of 100 (optional)

 days (integer) Number of 24-hour periods before now to include in feed (optional)

 start (datetime) Start date in format YYYY-MM-DD%20HH:NN:SS (optional)

 end (datetime) End date in format YYYY-MM-DD%20HH:NN:SS (optional)

 timezone (string) Timezone identifier for this request (optional)

 status (true/false) Include status updates in feed by setting "status=true" (optional)

 min (decimal) Minimum value to include in response (optional)

 max (decimal) Maximum value to include in response (optional)

 round (integer) Round to this many decimal places (optional)

 timescale (integer or string) Get first value in this many minutes, valid values: 10, 15, 20, 30,
60, 240, 720, 1440, "daily" (optional)

Charts:

The Charts API allows you to create an instant visualization of your data. The chart displays properly in all
modern browsers and mobile devices. The chart can also show dynamic data by loading new data
automatically.
Dept of ECE page 39
Smart Asthma Meter With Internet of Things

Use the Charts API to present numerical data stored in ThingSpeak Channels on charts. Supported chart
types are line, bar, column, spire, and step. Options include size, color, and labels.

Dept of ECE page 40


Smart Asthma Meter With Internet of Things

CHAPTER 5
DOCTOR USER INTERFACE

Dept of ECE page 41


Smart Asthma Meter With Internet of Things

5. DOCTOR USER INTERFACE

Figure 12 Doctor UI Block Diagram

5.1 WEB PAGE DEVELOPMENT


Elements of website

HTML:

Hyper Text Markup Language, commonly referred to as HTML, is the standard markup language
used to create web pages. It is written in the form of HTML elements consisting of tags enclosed
in angle brackets (like <HTML>). HTML tags most commonly come in pairs like

<h1> and </h1>, although some tags represent empty elements and so are unpaired, for example <img>. The
first tag in a pair is the start tag, and the second tag is the end tag (they are also called opening tags and
closing tags).

Web browsers can read HTML files and compose them into visible or audible web pages. Browsers do not
display the HTML tags and scripts, but use them to interpret the content of the page. HTML describes the
structure of a website semantically along with cues for presentation, making it a markup language, rather than
a programming language.

HTML elements form the building blocks of all websites. HTML allows images and objects to be embedded
and can be used to create interactive forms. It provides a means to create structured documents by denoting
structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. It can embed
scripts written in languages such as JavaScript which affect the behavior of HTML web pages.

Dept of ECE page 42


Smart Asthma Meter With Internet of Things

Web browsers can also refer to Cascading Style Sheets (CSS) to define the look and layout of text and other
material. The World Wide Web Consortium (W3C), maintainer of both the HTML and the CSS standards,
encourages the use of CSS over explicit presentational HTML.

Structure of html

In the browser window you can see a web page that features exactly the same content as the Word document
you met on the page 18. To describe the structure of a web page, we add code to the words we want to appear
on the page. You can see the HTML code for this page below. Don't worry about what the code means yet.
We start to look at it in more detail on the next page. Note that the HTML code is in blue, and the text you see
on screen is in black.

<html>
<body>
<h1>This is the Main Heading</h1>
<p>This text might be an introduction to the rest of the
page. And if the page is a long on it might
be split up into several sub-headings.<p>
<h2>This is a Sub-Heading</h2>
<p>Many long articles have sub-headings so to help you
follow the structure of what is being written. There may even
be sub-sub-headings (or lower-level headings).</p>
<h2>Another Sub-Heading</h2>
<p>Here you can see another sub-heading.</p>
</body>
</html>

How the Web Works

It’s useful at this point to outline, in very basic terms, just how the World Wide Web actually works in
practice. What really happens when you turn on your computer, open up your web browser and type
www.the-web-book.com into the address bar? How does the information get onto your screen? And where does
it come from in the first place? As I mentioned above, a web page is a document file, stored on a web server,
created with a program that’s a bit like a word processor but which saves its files in HTML format. When you
open up your web browser and type www.the-web-book.com, your computer connects via the internet to a
large, centralized directory in order to find out where the www.theweb-book.com site is stored. This directory
is called a DNS Server.

DNS is the Domain Name System, which gives each web server (or rather, each site) a unique name.
In this case, the-web-book.com. Computers, of course, don’t like names. They prefer numbers. In the case of
the internet, each web server has a unique number known as an IP address.

Dept of ECE page 43


Smart Asthma Meter With Internet of Things

So the DNS directory allows your computer to look up the IP address of the server which holds the-
web-book.com site. Once your computer knows the IP address of the web server which holds the site, your
computer can then connect, again over the internet, directly to that server.

Your web browser sends a request to the web server, asking for a specific page of the site. The server
sends that page (or, if no specific page is specified, it sends the home page). Your browser then displays the
contents of that page, and the process is complete. At least, until you click on a link in order to see another
page, and the process starts all over again.

Creating website

We build a simple website in Dreamweaver CC, guiding you through the process of defining the site, building
the structure with HTML (Hypertext Markup Language), adding text and images, and styling the pages with
CSS (Cascading Style Sheets)

In Dreamweaver, a site organizes on your local computer all the documents associated with your website and
lets you track and maintain links, manage files, share files, and transfer your site files to a web server. A
typical Dreamweaver site has at least two parts:

 Local Folder: This is your working directory—usually a folder on your hard drive.
 Remote Folder: This is where you store your files on the computer that's running your web server.
The web server is often (but not always) the computer that makes your site publicly available on the
web.
In some circumstances, you might have more than one remote folder. For example, if you work in a team
environment, all members of the team might upload their files to a common testing server before they are
deployed on the live website. Also, it's normal to set up a testing server when developing websites that use a
server-side technology, such as PHP. You can define multiple remote and testing servers for each site.
However, only one of each can be selected within Dreamweaver at any given time.

Dept of ECE page 44


Smart Asthma Meter With Internet of Things

Chapter 6
CODE

Dept of ECE page 45


Smart Asthma Meter With Internet of Things

6.1 ASTHMA METER ANDROID APPLICATION CODE

1. Main activity. java

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.UUID;

import android.app.Activity;

import android.bluetooth.BluetoothAdapter;

import android.bluetooth.BluetoothDevice;

import android.bluetooth.BluetoothSocket;

import android.content.Intent;

import android.os.Bundle;

import android.os.Handler;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.TextView;

import android.widget.Toast;

import android.webkit.WebView;

public class MainActivity extends Activity {

Button btnOn, btnOff;

TextView txtArduino, txtString, txtStringLength, sensorView0, sensorView1, sensorView2, sensorView3;

Handler bluetoothIn;

WebView webView;

Dept of ECE page 46


Smart Asthma Meter With Internet of Things

final int handlerState = 0; //used to identify handler message

private BluetoothAdapter btAdapter = null;

private BluetoothSocket btSocket = null;

private StringBuilder recDataString = new StringBuilder();

private ConnectedThread mConnectedThread;

// SPP UUID service - this should work for most devices

private static final UUID BTMODULEUUID = UUID.fromString("00001101-0000-1000-8000-


00805F9B34FB");

// String for MAC address

private static String address;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

//Link the buttons and textViews to respective views

txtString = (TextView) findViewById(R.id.txtString);

txtStringLength = (TextView) findViewById(R.id.testView1);

sensorView0 = (TextView) findViewById(R.id.sensorView0);

sensorView1 = (TextView) findViewById(R.id.sensorView3);

webView = (WebView) findViewById(R.id.webView1);

bluetoothIn = new Handler() {

public void handleMessage(android.os.Message msg) {


Dept of ECE page 47
Smart Asthma Meter With Internet of Things

if (msg.what == handlerState) {
//if message is what we want

String readMessage = (String) msg.obj; // msg.arg1 =


bytes from connect thread

recDataString.append(readMessage); //keep
appending to string until ~

int endOfLineIndex = recDataString.indexOf("~"); // determine the end-of-line

if (endOfLineIndex > 0) { // make sure there data before ~

String dataInPrint = recDataString.substring(0, endOfLineIndex); // extract string

txtString.setText("Data Received = " + dataInPrint);

int dataLength = dataInPrint.length(); //get length of


data received

txtStringLength.setText("String Length = " + String.valueOf(dataLength));

if (recDataString.charAt(0) == '#') //if it


starts with # we know it is what we are looking for

String sensor0 = recDataString.substring(1, 4); //get sensor value from string between
indices 1-5

String sensor1 = recDataString.substring(5, 8); //same again...

//String sensor2 = recDataString.substring(11, 15);

//String sensor3 = recDataString.substring(16, 20);

sensorView0.setText(" Peak Value = " + sensor0 + "Points"); //update the textviews with
sensor values

sensorView1.setText(" Peak Time = " + sensor1 + "ms");

//sensorView2.setText(" Sensor 2 Voltage = " + sensor2 + "V");

//sensorView3.setText(" Sensor 3 Voltage = " + sensor3 + "V");

String m="https://api.thingspeak.com/update?key=6WY4A8TWQIRW8QJX&field1=";

m = m + sensor0;

webView.loadUrl(m);
Dept of ECE page 48
Smart Asthma Meter With Internet of Things

recDataString.delete(0, recDataString.length()); //clear all


string data

// strIncom =" ";

dataInPrint = " ";

};

btAdapter = BluetoothAdapter.getDefaultAdapter(); // get Bluetooth adapter

checkBTState();

/* // Set up onClick listeners for buttons to send 1 or 0 to turn on/off LED

btnOff.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

mConnectedThread.write("0"); // Send "0" via Bluetooth

Toast.makeText(getBaseContext(), "Turn off LED", Toast.LENGTH_SHORT).show();

});

btnOn.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

mConnectedThread.write("1"); // Send "1" via Bluetooth

Toast.makeText(getBaseContext(), "Turn on LED", Toast.LENGTH_SHORT).show();

});*/

}
Dept of ECE page 49
Smart Asthma Meter With Internet of Things

private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {

return device.createRfcommSocketToServiceRecord(BTMODULEUUID);

//creates secure outgoing connecetion with BT device using UUID

@Override

public void onResume() {

super.onResume();

//Get MAC address from DeviceListActivity via intent

Intent intent = getIntent();

//Get the MAC address from the DeviceListActivty via EXTRA

address = intent.getStringExtra(DeviceListActivity.EXTRA_DEVICE_ADDRESS);

//create device and set the MAC address

BluetoothDevice device = btAdapter.getRemoteDevice(address);

try {

btSocket = createBluetoothSocket(device);

} catch (IOException e) {

Toast.makeText(getBaseContext(), "Socket creation failed", Toast.LENGTH_LONG).show();

// Establish the Bluetooth socket connection.

try

Dept of ECE page 50


Smart Asthma Meter With Internet of Things

btSocket.connect();

} catch (IOException e) {

try

btSocket.close();

} catch (IOException e2)

//insert code to deal with this

mConnectedThread = new ConnectedThread(btSocket);

mConnectedThread.start();

//I send a character when resuming.beginning transmission to check device is connected

//If it is not an exception will be thrown in the write method and finish() will be called

mConnectedThread.write("x");

@Override

public void onPause()

super.onPause();

try

//Don't leave Bluetooth sockets open when leaving activity

btSocket.close();

} catch (IOException e2) {

Dept of ECE page 51


Smart Asthma Meter With Internet of Things

//insert code to deal with this

//Checks that the Android device Bluetooth is available and prompts to be turned on if off

private void checkBTState() {

if(btAdapter==null) {

Toast.makeText(getBaseContext(), "Device does not support bluetooth",


Toast.LENGTH_LONG).show();

} else {

if (btAdapter.isEnabled()) {

} else {

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);

startActivityForResult(enableBtIntent, 1);

//create new class for connect thread

private class ConnectedThread extends Thread {

private final InputStream mmInStream;

private final OutputStream mmOutStream;

//creation of the connect thread

public ConnectedThread(BluetoothSocket socket) {

InputStream tmpIn = null;

OutputStream tmpOut = null;

Dept of ECE page 52


Smart Asthma Meter With Internet of Things

try {

//Create I/O streams for connection

tmpIn = socket.getInputStream();

tmpOut = socket.getOutputStream();

} catch (IOException e) { }

mmInStream = tmpIn;

mmOutStream = tmpOut;

public void run() {

byte[] buffer = new byte[256];

int bytes;

// Keep looping to listen for received messages

while (true) {

try {

bytes = mmInStream.read(buffer); //read bytes from input buffer

String readMessage = new String(buffer, 0, bytes);

// Send the obtained bytes to the UI Activity via handler

bluetoothIn.obtainMessage(handlerState, bytes, -1, readMessage).sendToTarget();

} catch (IOException e) {

break;

//write method

Dept of ECE page 53


Smart Asthma Meter With Internet of Things

public void write(String input) {

byte[] msgBuffer = input.getBytes(); //converts entered String into bytes

try {

mmOutStream.write(msgBuffer); //write bytes over BT connection via outstream

} catch (IOException e) {

//if you cannot write, close the application

Toast.makeText(getBaseContext(), "Connection Failure", Toast.LENGTH_LONG).show();

finish();

6.2.Html page for viewing the recorded values on graph using THINGSPEAK – open

source for internet of things

<html>

<head>

<title>Asthama Level Evaluation Login</title>

<script language=JavaScript> var message="Function Disabled!";

function clickIE4(){ if (event.button==2){ alert(message); return false; } }

function clickNS4(e){ if (document.layers||document.getElementById&&!document.all)

{ if (e.which==2||e.which==3){ alert(message); return false; } } }


Dept of ECE page 54
Smart Asthma Meter With Internet of Things

if (document.layers){ document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4; }

else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4; }

document.oncontextmenu=new Function("alert(message);return false")

</script>

<link rel="shortcut icon" type="image/jpg" href="images.jpg"/>

</head>

<body>

<center><br/><br/><br/><br/>

<img src="images.jpg"/>

<h1>Smart Astma Meter</h1>

<h2>Admin Login</h2>

<form name="login">

Username:<input type="text" name="userid"/>

Password:<input type="password" name="pswrd"/>

<input type="button" onclick="check(this.form)" value="Login"/>

<input type="reset" value="Cancel"/>

</form>

<script language="javascript">

function check(form) {

if(form.userid.value == "bvrit" && form.pswrd.value == "ece") {

window.open('index.html',"_self")

else {

alert("Error Password or Username")

}}

Dept of ECE page 55


Smart Asthma Meter With Internet of Things

</script><br/>

<h1> <font color="blue">ECE DEPARTMENT, BVRIT-N</h1>

<h4><font color="black">Guided by T. P Kausalya Nandan, Asst. Professor, ECE Dept. BVRIT - N


</h4>

</center>

</body>

</html>

6.3Project code/ code dumped to MSP controller.

#include <LiquidCrystal.h>

LiquidCrystal lcd(8,9,10,11,12,13);

int a[100],i=0,flag=0,count=0,temp,j=0;

void setup()

Serial.begin(9600);

pinMode(A3,INPUT);

lcd.begin(16,2);

lcd.print("ASTHMA METER");

lcd.setCursor(3,1);

lcd.print("TEST IT !!");

delay(2000);

void loop()

Dept of ECE page 56


Smart Asthma Meter With Internet of Things

lcd.clear();

lcd.print("PLEASE BLOW");

int n=analogRead(A3);

delay(200);

if(n>50)

flag=1;

if(flag==1)

a[i]=n;

i++;

j=1;

if((flag==1)&&(n==0))

count=i;

temp=a[0];

for(i=1;i<count;i++)

if(temp<a[i])

temp=a[i];

j=i;

i=0;

Dept of ECE page 57


Smart Asthma Meter With Internet of Things

flag=0;

if((temp<=1023)&&(temp>1000))

Serial.print('#');

Serial.print(600);

Serial.print('+');

Serial.print(j*100);

Serial.print('~');

lcd.clear();

lcd.print("PEAK VALUE: ");

lcd.print(600);

lcd.print(" l/min");

lcd.setCursor(0,1);

lcd.print("PEAK TIME: ");

lcd.print(j*100);

lcd.print("ms");

delay(4000);

if((temp<1000)&&(temp>900))

Serial.print('#');

Serial.print(500);

Serial.print('+');

Serial.print(j*100);

Serial.print('~');

Dept of ECE page 58


Smart Asthma Meter With Internet of Things

lcd.clear();

lcd.print("PEAK VALUE: ");

lcd.print(500);

lcd.print(" l/min");

lcd.setCursor(0,1);

lcd.print("PEAK TIME: ");

lcd.print(j*100);

lcd.print("ms");

delay(4000);

else if((temp<50)&&(temp>30))

Serial.print('#');

Serial.print("010");

Serial.print('+');

Serial.print(j*100);

Serial.print('~');

lcd.clear();

lcd.print("PEAK VALUE: ");

lcd.print(10);

lcd.print(" l/min");

lcd.setCursor(0,1);

lcd.print("PEAK TIME: ");

lcd.print(j*100);

lcd.print("ms");

delay(4000);

Dept of ECE page 59


Smart Asthma Meter With Internet of Things

CHAPTER 7
Testing and Results

Dept of ECE page 60


Smart Asthma Meter With IoT

Testing and Results


The main aim of this project is to assist the doctor for monitoring the asthma levels of the patient time to
time. Hence testing is done as follows

1. First the patient need to power on the circuit by connecting the battery to it.
2. Then start the ASTHMA METER android application which prompts to turn ON Bluetooth on
startup

Figure 13.1 Starting Application Figure 13.2 Bluetooth Prompt

3. Once the Bluetooth is turned ON the application shows us the paired devices in the mobile phone.
4. Select the Bluetooth HC 05 named Bluetooth which is the Bluetooth drive of the circuit.

Figure 13.3 Pairing the Bluetooth Drive HC 05

Dept. Of ECE 61
Smart Asthma Meter With IoT

5. Now that the kit and android mobile are connected the patient need to check the LCD DISPLAY. If
it displays a text saying PLEASE BLOW then he can proceed further

Figure 13.4 Asthma Meter On Startup Figure 13.5 Application on startup

6. Now the patient needs to blow in the pipe mechanism provided with his maximum capacity.

Figure 13.6 Blowing Mechanism for Asthma meter

Dept. Of ECE 62
Smart Asthma Meter With IoT

7. The peak voltage and peak time are recorded and displayed at the LCD DISPLAY and the android
application provided.

Figure 13.7 Values Recorded in application Figure 13.8 Values displayed in asthma meter

8. The android application updates the values to the IoT FRAME WORK using the link provided.
9. The recorded value will be plotted and will be available for viewing at the doctors end for monitoring
the asthma levels using HTML INTERFACE.

Figure 13.9: Login page for doctor

Dept. Of ECE 63
Smart Asthma Meter With IoT

Figure 13.10: Plotted Graph Of Asthma Levels

Dept. Of ECE 64
Smart Asthma Meter With IoT

CHAPTER 8
SALIENT FEATURES AND DISADVANTAGES

Dept. Of ECE 65
Smart Asthma Meter With IoT

ADVANTAGES

 Many doctors believe that people who have asthma can benefit from the use of a Asthma Meter. If
you need to adjust your daily medication for asthma, a Asthma Meter can be an important part of
your asthma management plan.

 Children as young as three years have been able to use a Meter to help manage their asthma. In
addition, some people with chronic bronchitis and emphysema may also benefit from the use of a
Asthma Meter.

 Asthma Meter can help you when your asthma is getting worse. Asthma sometimes changes
gradually. Your Peak Flow may show changes before you feel them. It can allow your doctor to
adjust your treatment to prevent urgent calls to the doctor, emergency room visits or hospitalizations.

 This Meter can also be used during an asthma episode. It can help you determine the
severity of the episode; decide when to use your rescue medication; and decide when
to seek emergency care.

 This Meter can show you that you may need to change the way you are using your medicines. For
example, Peak Flow readings may help be a signal for you to implement the medication plan you and
your doctor have developed for worsening asthma. On the other hand, if you are doing well, then
measuring your Peak Flow may be helpful as you and your doctor try to lower the level of your
medicines.

DISADVANTAGES

 These results obtained of peak flow are not as accurate as lung function measurement through
spirometry technique.

Dept. Of ECE 66
Smart Asthma Meter With IoT

CHAPTER 9
CONCLUSION AND
FUTURE SCOPE

Dept. Of ECE 67
Smart Asthma Meter With IoT

Conclusion

We have designed a circuit which helps asthma patients to monitor their asthma levels regularly without

the help of a doctor. It also helps the doctor to read the previous asthma levels of the patient and suggest a

better prescription for him. This system is checked for consistency by giving diverse inputs. It has 24

calibrations programmed to MSP controller all of which are below the normal blow levels of people hence it

has high sensitivity.

Along with peak value the system also displays the peak time which helps the doctor to reach a better

conclusion. The use of Android mobile phones has been increasing rapidly; hence interfacing the circuit with

the android device increases its scope to a large extent.

The expenditure spent the patient each time he checks his asthma level can be reduced to a large extent

resulting it to be available for people with low socio economic status. The topic to be researched in future is

to increase the sensitivity of the meter to a large extent so that it can replace the huge machines placed in

hospitals to check for asthma

Future Scope

The topic to be researched in future is to increase the sensitivity of the meter to a large extent so that

it can replace the huge machines placed in hospitals to check for asthma

Internet of things is a technology which is going to have its large impact in future hence the project

makes interfaces with new technologies which can be replaced by more newer technologies.

Dept. Of ECE 68
Smart Asthma Meter With IoT

CHAPTER 10
REFERENCES

Dept. Of ECE 69
Smart Asthma Meter With IoT

References

1. http://asthmamd.org/peak-flow-meter/#/resources/iphone_chart.jpg

2. http://www.projecthealthdesign.org/media/file/BreathEasy-Rita-Sembajwe-mHealth-Summit-Poster-
Content-120511.pdf

3. Zhou Y, Yang X, Guo X, Zhou M, Wang L. A Design of Greenhouse Monitoring & Control System
Based on ZigBee Wireless Sensor Network. Proceedings of the International Conference on
Wireless Communications, Networking and Mobile Computing; Shanghai, China. 21–25
September 2007;

4. http://www.mayoclinic.org/diseases-conditions/asthma/in-depth/asthma/art-20045198

5. The Silent Intelligence: The Internet of Things by Daniel Kellmereit & Daniel Obodovski

6. https://www.aafa.org/display/display.cfm?id=8&sub=17&cont=174

7. http://scholar.google.co.in/scholar?q=asthma+meter+literature+survey&hl=en&as

8. http://www.everybody.co.nz/page-2797f4d2-6d46.aspx

Dept. Of ECE 70
Smart Asthma Meter With IoT

Dept. Of ECE 71

Vous aimerez peut-être aussi