You are on page 1of 50

A Coal Miner Detector Using

Arduino Mega

By

ABC
(BEES/______)

ABC
(BEES/_____)

ABC
(BEES/____)
2017

Faculty of Engineering Sciences and Tech nology


Hamdard Institute of Engineering a n d Technology
Hamdard University, Main Campus, Karachi, Pakistan
A Coal Miner Detector Using
Arduino Mega

By

ABC
(BEES/_______)

ABC
(BEES/______)

ABC
(BEES/______)

2017

Faculty of Engineering Sciences and Tech nology


Hamdard Institute of Engineering a n d Technology
Hamdard University, Main Campus, Karachi, Pakistan
A Coal Miner Detector Using
Arduino Mega
By

ABC
(BEES/_____)
ABC
(BEES/_____)
ABC
(BEES/____)

A project presented to the

Faculty of Engineering Sciences and Technology


Hamdard Institute of Engineering and Technology
In partial fulfillment of the requirements
for the degree of

Bachelors of Engineering
In
Electronics

Faculty of Engineering Sciences and Tech nology


Hamdard Institute of Engineering a n d Technology
Hamdard University, Main Campus, Karachi, Pakistan
Faculty of Engineering Sciences and Technology
Hamdard Institute of Engineering and Technology
Hamdard University, Main Campus, Karachi.

CERTIFICATE
This project “A Coal Miner Detector Using Arduino Mega” presented by Name1, Name2
and Name3 under the direction of their project advisor’s and approved by the project
examination committee, has been presented to and accepted by the Hamdard Institute of
Engineering and Technology, in partial fulfillment of the requirements for Bachelor of
Engineering (Electronics).

_____________________ ___________________
Engr. Name of Supervisor (Member)
(Project Advisor)

_________________________ _________________________
Engr. Name of Co-supervisor (Member)
(Co-Supervisor)

___________________ ___________________
Dr. Rashid Hussain Prof. Dr. Pervez Akhtar
(Chairman Electrical Engineering (Director, HIET)
Department)
ABSTRACT

The Final year project named as “A Coal Miner Detector Using Arduino Mega” proposed in the

department of electronics engineering basically defines the cheap and very efficient Assistive

system for physically impaired people who are unable to see and may lost their vision. Here we

are doing basic operations to detect some basic things including that to check that miner is Alive

or Not, depth of the miner, Pressure upon the miner, humidity and Temperature under the mine

and gas level and the location where the miner is located. In this device we have proposed an

engineering cap reshaped and redesigned by fixing some of the sensors that will be placed to

detect the parameters we required. This signal will be later on transmitted wirelessly using ESP-

8266 WiFi module to the IP of Router. The purpose of generating this Method Statement is to

define the procedure step by step to implement the a cheap but efficient device for coal

miners; moreover to ensure that the device installation work execution complies with the project

requirements and serves the intended function to satisfactory level.


ACKNOWLEDGEMENT

All praises and thanks to Al-Mighty ”ALLAH”, the most merciful, the most gracious, the
source of knowledge and wisdom endowed to mankind, who conferred us with the power of
mind and capability to take this project to the exciting ocean of knowledge. All respects are
for our most beloved Holy Prophet “Hazrat MUHAMMAD (Peace Be Upon Him)”,
whose personality will always be source of guidance for humanity.

Acknowledgement is due to ----------------------------------------------------------------- for support


of this Project, a highly appreciated achievement for us in the undergraduate level.

We wish to express our appreciation to our Name of Supervisor who served as our major
advisor. We would like to express our heartiest gratitude for their keen guidance, sincere
help and friendly manner which inspires us to do well in the project and makes it a reality.

Many people, especially our classmates and team members itself, have made valuable comment
suggestions on this proposal which gave us an inspiration to improve our project. We thank
Name of Co-supervisor & all the people for their help directly and indirectly to complete our
project.
CHAPTER 1
INTRODUCTION

In today’s world everything is temporary except change and it is obvious that firms of now days
need professionals who have command in more than one field and hence our aim was to excel in
such area where we can find amalgamation of two or more than two techniques and moreover it
may provide a community services in this regard we found an area where we may help out the
firms in many different difficulties. Having life is a blessing and in different profession there is
many risk of losing the life of employees. Like in mining there is a lot of risk of life of worker
under the mines because when the worker goes to mine for his work and in any sudden accident
under the mine with the worker cause injury and also death. In this regard we being an electronic
engineer suggest the embedded system design that may not provide life to the worker but may
remove the ambiguity and may guide them a lot in this manner.

1.1 Motivation
Being an engineer it is obvious to do something or provide something that would be an efficient
alternative to any issue or problem hence listening about the death of workers under the mines
makes us miserable and forced us to think some technological solution that may provide an ease
to that particular physically impaired people. This was the aim due to which we planned to go for
this solution of the problem. The designed system may require initial training but after becoming
used to of this particular system and its usage for finding the workers under the mine and know
about the environment of the mine and will face less difficulty in finding the workers

1.2 Problem Statement


After analyzing the area and problem we formulate our problem statement which states that the
area of establishing the cheap, precise and efficient assistive device for finding the workers under
the mines.
1.3 Aims and Objectives
Here are the major Aims and objectives of our final year project:
 Making a cheap embedded system
 Make an efficient and less power consuming system
 A system that assists the firm to find the workers under the mines.
 A System in which the signals will be transmitted wirelessly to the Esp8266 wifi module
 Transmits data to particular IP address.
And for above mentioned objectives we have to do following tasks as mentioned below:
 Interfacing of DHT11,BMP180,MQ-02,GPS,Pulse Sensor with Arduino
 Interfacing the basic program of ESP8266
 Generating signals wirelessly to the IP address

For above mentioned objectives we will require following tasks to be completed:


 Reading the data from different sensor of environment through Arduino UNO.
 When information or readings will be computed and noted they will be transmitted via
ESP8266 wifi module.

1.4 Advantages
There are often stories in the newspapers today about the detrimental effects technology is
having on our lives. From people wishing they were born in a different era to reports on how
emails are stressing us all out, it seems everyone is queuing up to point out the bad things about
modern inventions.

 Safety:
The first and the main things in coal mining is safety and this device helps the firms to
provide types of security to their miners or workers.

 Location
The main thing to provide security to the miner or worker of any industry is to get the
location under the mine. In this project using Global Positioning System(GPS) we
transmits the location as longitude and latitude to Internet Protocol Using ESP8266.

 Conditions under the mine


To measure the conditions under the mines like gases temperature humidity and pressure
help us to get the conditions under the mine because many of accidents under the mines
cause by the gases present in the mines.

1.5 Organization of Thesis


This report documents the details of “An Assistive Device for Miners” and also of its practical
Implementation, which is done by using Arduino MEGA and its Software Arduino IDE. The
primary task in general are mentioned as under:
 Interfacing DHT11, BMP180, MQ-02, GPS, Pulse Sensor sensors.
 Interfacing ESP8266
 Getting signals wirelessly to a designed Jacket
 Transmit Data to the IP address.

The report is divided into 5 chapters and the features and related to programming is also
described and lastly it is ended by conclusion and future work.

1.6 1st Evaluation Task


 Studying the Literature Review.
 Understanding the environment of Arduino UNO and Programming.
 Interfacing different Sensor and transmits data
CHAPTER 2
LITERATURE REVIEW

2.1 Background
Mining remains one of the most hazardous occupations worldwide and underground coal mines
are especially notorious for their high accident rates. In this work, we provide an overview of
the broad and multi-faceted topic of safety in the mining industry. After reviewing some
statistics of mining accidents in the United States, we focus on one pervasive and deadly failure
mode in mines, namely explosions. The repeated occurrence of mine explosions, often in
similar manner, is the loud unfinished legacy of mining accidents and their occurrence in the
21st century is inexcusable and should constitute a strong call for action for all stakeholders in
this industry to settle this problem. We analyze one such recent mine disaster in which
deficiencies in various safety barriers failed to prevent the accident initiating event from
occurring, then subsequent lines of defense failed to block this accident scenario from unfolding
and to mitigate its consequences. We identify the technical, organizational, and regulatory
deficiencies that failed to prevent the escalation of the mine hazards into an accident, and the
accident into a “disaster”. This case study provides an opportunity to illustrate several concepts
that help describe the phenomenology of accidents, such as initiating events, precursor or lead
indicator, and accident pathogen. Next, we introduce the safety principle of defense-in-depth,
which is the basis for regulations and risk-informed decisions by the US Nuclear Regulatory
Commission, and we examine its relevance and applicability to the mining system in support of
accident prevention and coordinating actions on all the safety levers, technical, organizational,
and regulatory to improve mining safety. The mining system includes the physical confines and
characteristics of the mine, the equipment in the mine, the individuals and the organization that
operate the mine, as well as the processes and regulatory constraints under which the mine
operates. We conclude this article with the proposition for the establishment of defense-in-depth
as the guiding safety principle for the mining industry and we indicate possible benefits for
adopting this structured hazard-centric system approach to mining safety.
2.2 System Overview
Using the proposed we improves diming convenience and safety for the workers who work
under the mines. The system the software flow chart is shown in Fig.2. To realize the prototype,
this study used an Arduino MEGA development board as the single-chip microcomputer, Esp
8266 to transmits data to Internet Protocol , DHT-11 to get the humidity and temperature under
the mines, BMP-180 to get the pressure upon the miner and MQ-05 to get the condition of gases
under the mines.

Figure 2.0 ( Software Flow of Coal Miner Detector)


Arduino is an open-source, single-chip microcontroller applicable to either hardware or software
tools. It is easy to access, learn, and use. Arduino provides abundant examples, and uses a
program language similar to C/C++. Users can download the Arduino integrated development
environment from the official website [5]. 3.2 DC Motor Direct current motors are advantageous
for their easier control of turning speed, which can be configured merely by adjusting voltage.
L298N is a high-voltage and high-current motor driver module. The module features high
working voltage and output current, contains a bridge circuit and voltage-stabilizing IC,
demonstrates high drive capacity and low heat emission, and can drive direct current motors and
stepper motors, as well as control their turning speed [6].

2.3 Methods
This study used a ESP8266 as the data transmitter in Internet protocol. The operation of the data
transmission to the IP address software is simple and easy to understand; moreover, to transmits
the data to the GSM because GSM didn’t get perfect signals under the mines.

DHT-11
DHT11 digital temperature and humidity sensor is a composite Sensor contains a measured
digital signal output of the temperature and humidity. Application of a dedicated digital modules
collection technology and the temperature and humidity sensing technology, to ensure that the
product has high reliability and excellent long-term stability. The sensor includes a resistive
sense of wet components and an NTC temperature measurement devices, and connected with a
high-performance 8-bit microcontroller.
Applications
HVAC, dehumidifier, testing and inspection equipment, consumer goods, automotive, automatic
control, data loggers, weather stations, home appliances, humidity regulator, medical and other
humidity measurement and control.
Features
Low cost, long-term stability, relative humidity and temperature measurement, excellent quality,
fast response, strong anti-interference ability, long distance signal transmission, digital signal
output, and precise calibration.
Product parameters Relative humidity Resolution: 16Bit
Repeatability: ±1% RH
Accuracy: At 25℃ ±5% RH
Interchangeability: fully interchangeable
Response time: 1 / e (63%) of 25℃ 6s 1m / s air 6s
Temperature Resolution: 16Bit
Repeatability: ±0.2℃
Range: At 25℃ ±2℃
Response time: 1 / e (63%) 10S
Serial communication instructions (single-wire bi-directional)
DHT11 uses a simplified single-bus communication. Single bus that only one data line, the
system of data exchange, control by a single bus to complete. Device (master or slave) through
an open-drain or tri-state port connected to the data line to allow the device does not send data to
release the bus, while other devices use the bus; single bus usually require an external one about
5.1kΩ pull-up resistor, so that when the bus is idle, its status is high. Because they are the
master-slave structure, and only when the host calls the slave, the slave can answer, the host
access devices must strictly follow the single-bus sequence, if the chaotic sequence, the device
will not respond to the host.

Single bus to transfer data defined DATA For communication and synchronization between the
microprocessor and DHT11, single-bus data format, a transmission of 40 data, the high first-out.

Data format:
The 8bit humidity integer data + 8bit the Humidity decimal data +8 bit temperature integer data
+ 8bit fractional temperature data +8 bit parity bit.
Parity bit data definition “8bit humidity integer data + 8bit humidity decimal data +8 bit
temperature integer data + 8bit temperature fractional data” 8bit checksum is equal to the results
of the last eight. Example 1: 40 data is received: 0011 0101 0000 0000 0001 1000 0000 0000
0100 1101 High humidity 8 Low humidity 8 High temp. 8 Low temp. 8 Parity bit
Calculate: 0011 0101+0000 0000+0001 1000+0000 0000= 0100 1101 Received data is correct
Humidity:0011 0101=35H=53%RH Temperature:0001 1000=18H=24℃
Example 2: 40 data is received: 0011 0101 0000 0000 0001 1000 0000 0000 0100 1001 High
humidity 8 Low humidity 8 High temp. 8 Low temp.
8 Parity bit Calculate: 0011 0101+0000 0000+0001 1000+0000 0000= 0100 1101
01001101≠0100 1001 The received data is not correct, give up, to re-receive data.
Data Timing Diagram User host (MCU) to send a signal, DHT11 converted from low-power
mode to high-speed mode, until the host began to signal the end of the DHT11 send a response
signal to send 40bit data, and trigger a letter collection.
Peripherals read steps
Communication between the master and slave can be done through the following steps
(peripherals (such as microprocessors) read DHT11 the data of steps).

Step 1:
After power on DHT11 (DHT11 on after power to wait 1S across the unstable state during this
period can not send any instruction), the test environment temperature and humidity data, and
record the data, while DHT11 the DATA data lines pulled by pull-up resistor has been to
maintain high; the DHT11 the DATA pin is in input state, the moment of detection of external
signals.

Step 2:
Microprocessor I / O set to output at the same time output low, and low hold time can not be less
than 18ms, then the microprocessor I / O is set to input state, due to the pull-up resistor, a
microprocessor/ O DHT11 the DATA data lines also will be high, waiting DHT11 to answer
signal

Step 3:
DATA pin is detected to an external signal of DHT11 low, waiting for external signal low end
the delay DHT11 DATA pin in the output state, the output low of 80 microseconds as the
response signal, followed by the output of 80 micro-seconds of high notification peripheral is
ready to receive data, the microprocessor I / O at this time in the input state is detected the I / O
low (DHT11 response signal), wait 80 microseconds high data receiving

Step 4:
Output by DHT11 the DATA pin 40, the microprocessor receives 40 data bits of data "0" format:
the low level of 50 microseconds and 26-28 microseconds according to the changes in the I / O
level, bit data "1" format: the high level of low plus, 50 microseconds to 70 microseconds. Bit
data "0", "1".
End signal:
Continue to output the low 50 microseconds after DHT11 the DATA pin output 40 data, and
changed the input state, along with pull-up resistor goes high. But DHT11 internal re-test
environmental temperature and humidity data, and record the data, waiting for the arrival of the
external signal.

Application of information
1. Work and storage conditions Outside the sensor the proposed scope of work may lead to
temporary drift of the signal up to 300%RH. Return to normal working conditions, sensor
calibration status will slowly toward recovery. To speed up the recovery process may refer to
"resume processing". Prolonged use of non-normal operating conditions, will accelerate the
aging of the product. Avoid placing the components on the long-term condensation and dry
environment, as well as the following environment. A, salt spray B, acidic or oxidizing gases
such as sulfur dioxide, hydrochloric acid Recommended storage environment Temperature: 10 ~
40 ℃ Humidity: 60% RH or less

2. The impact of exposure to chemicals The capacitive humidity sensor has a layer by chemical
vapor interference, the proliferation of chemicals in the sensing layer may lead to drift and
decreased sensitivity of the measured values. In a pure environment, contaminants will slowly be
released. Resume processing as described below will accelerate this process. The high
concentration of chemical pollution (such as ethanol) will lead to the complete damage of the
sensitive layer of the sensor.

3. The temperature influence Relative humidity of the gas to a large extent dependent on
temperature. Therefore, in the measurement of humidity, should be to ensure that the work of the
humidity sensor at the same temperature. With the release of heat of electronic components share
a printed circuit board, the installation should be as far as possible the sensor away from the
electronic components and mounted below the heat source, while maintaining good ventilation
of the enclosure. To reduce the thermal conductivity sensor and printed circuit board copper
plating should be the smallest possible, and leaving a gap between the two.
4. Light impact Prolonged exposure to sunlight or strong ultraviolet radiation, and degrade
performance
5. Resume processing Placed under extreme working conditions or chemical vapor sensor, which
allows it to return to the status of calibration by the following handler. Maintain two hours in the
humidity conditions of 45℃ and 70% RH humidity conditions to maintain more than five hours.

6. Wiring precautions The quality of the signal wire will affect the quality of the voltage output,
it is recommended to use high quality shielded cable.

7. Welding information Manual welding, in the maximum temperature of 300℃ under the
conditions of contact time shall be less than 3 seconds. 8. Product upgrades Details, please the
consultation Aosong electronics department.

MQ-05
The Grove - Gas Sensor(MQ5) module is useful for gas leakage detecting(in home and industry).
It can detect H2, LPG, CH4, CO, Alcohol. Based on its fast response time. Measurements can be
taken as soon as possible. Also the sensitivity can be adjusted by the potentiometer.
Features
 Wide detecting scope
 Stable and long life
 Fast response and High sensitivity

Application Ideas
 Gas leakage detecting
 Toys

Hardware Installation
Grove products have a eco system and all have a same connector which can plug onto the Base
Shield. Connect this module to the A0 port of Base Shield, however, you can also connect Gas
sensor to Arduino without Base Shield by jumper wires.
How To Use
There're two steps you need to do before getting the concentration of gas. First, connect the
module with Grove Shield using A0 like the picture above. And put the sensor in a clear air and
use the program below.

void setup()
{
Serial.begin(9600);
}
void loop()
{
float sensor_volt;
float RS_air; // Get the value of RS via in a clear air
float R0; // Get the value of R0 via in H2
float sensorValue;

/*--- Get a average data by testing 100 times ---*/


for(int x = 0 ; x < 100 ; x++)
{
sensorValue = sensorValue + analogRead(A0);
}
sensorValue = sensorValue/100.0;
/*-----------------------------------------------*/
sensor_volt = sensorValue/1024*5.0;
RS_air = (5.0-sensor_volt)/sensor_volt; // omit *RL
R0 = RS_air/6.5; // The ratio of RS/R0 is 6.5 in a clear air

Serial.print("sensor_volt = ");
Serial.print(sensor_volt);
Serial.println("V");
Serial.print("R0 = ");
Serial.println(R0);
delay(1000);
}

Then, open the monitor of Arduino IDE, you can see some data are printed, write down the
value of R0 and you need to use it in the following program. During this step, you may pay a
while time to test the value of R0. Second, put the sensor in one gas where the environment you
want to test in. However, don't forget to replace the R0 below with value of R0 tested above

void setup() {
Serial.begin(9600);
}
void loop()
{
float sensor_volt;
float RS_gas; // Get value of RS in a GAS
float ratio; // Get ratio RS_GAS/RS_air
int sensorValue = analogRead(A0);
sensor_volt=(float)sensorValue/1024*5.0;
RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL

/*-Replace the name "R0" with the value of R0 in the demo of First Test -*/
ratio = RS_gas/R0; // ratio = RS/R0
/*-----------------------------------------------------------------------*/
Serial.print("sensor_volt = ");
Serial.println(sensor_volt);
Serial.print("RS_ratio = ");
Serial.println(RS_gas);
Serial.print("Rs/R0 = ");
Serial.println(ratio);
Serial.print("\n\n");

delay(1000);
}
We, we can see that the minimum concentration we can test is 200ppm and the maximum is
10000ppm, in a other word, we can get a concentration of gas between 0.02% and 1%. However,
we can't provide a formula because the relation between ratio and concentration is nonlinear.

PULSE SENSOR:
Pulse Sensor is a well-designed plug-and-play heart-rate sensor for Arduino. It can be used by
students, artists, athletes, makers, and game & mobile developers who want to easily incorporate
live heartrate data into their projects. The sensor clips onto a fingertip or earlobe and plugs right
into Arduino. It also includes an open-source monitoring app that graphs your pulse in real time.
The Pulse Sensor Kit includes:
1) A 24-inch Color-Coded Cable, with (male) header connectors. You'll find this makes it
easy to embed the sensor into your project, and connect to an Arduino. No soldering is
required.
2) An Ear Clip, perfectly sized to the sensor. We searched many places to find just the right
clip. It can be hot glued to the back of the sensor and easily worn on the earlobe.
3) 2 Velcro Dots. These are 'hook' side and are also perfectly sized to the sensor. You'll find
these velcro dots very useful if you want to make a velcro (or fabric) strap to wrap around
a finger tip.
4) Velcro strap to wrap the Pulse Sensor around your finger.
5) 3 Transparent Stickers. These are used on the front of the Pulse Sensor to protect it from
oily fingers and sweaty earlobes.
6) The Pulse Sensor has 3 holes around the outside edge which make it easy to sew it into
almost anything.

Let’s get started with Pulse Sensor Anatomy


The front of the sensor is the pretty side with the Heart logo. This is the side that makes
contact with the skin. On the front you see a small round hole, which is where the LED
shines through from the back, and there is also a little square just under the LED. The square
is an ambient light sensor, exactly like the one used in cellphones, tablets, and laptops, to
adjust the screen brightness in different light conditions. The LED shines light into the
fingertip or earlobe, or other capillary tissue, and sensor reads the amount of light that
bounces back. The other side of the sensor is where the rest of the parts are mounted. We put
them there so they would not get in the way of the of the sensor on the front. Even the LED
we are using is a reverse mount LED. For more about the circuit functionality.

The Pulse Sensor can be connected to arduino, or plugged into a breadboard. Before we get it
up and running, we need to protect the exposed circuitry so you can get a reliable heartbeat
signal.
Preparing the Pulse Sensor
Before you really start using the sensor you want to insulate the board from your (naturally)
sweaty/oily fingers. The Pulse Sensor is an exposed circuit board, and if you touch the solder
points, you could short the board, or introduce unwanted signal noise. We will use a thin film
of vinyl to seal the sensor side. Find the small card with four clear round stickers in your kit,
and peel one off. Then center it on the Pulse Sensor. It should fit perfectly.
When you are happy with the way it’s lined up, squeeze it onto the face all at once! The
sticker (made of vinyl) will kind of stretch over the sensor and give it a nice close fit. If you
get a wrinkle, don’t worry, just press it down really hard and it should stick. We gave you 4,
so you can replace it if necessary. That takes care of the front side. The vinyl sticker offers
very good protection for the underlying circuit, and we rate it ‘water resistant’. meaning: it
can stand to get splashed on, but don’t wear it in the pool! If this is your first time working
with Pulse Sensor, you’re probably eager to get started, and not sure if you want to use the
ear-clip or finger-strap (or other thing of your design). The back of the Pulse Sensor has even
more exposed contacts than the front, so you need to make sure that you don’t let it touch
anything conductive or wet. The easiest and quickest way to protect the back side from
undesirable shorts or noise is to simply stick a velcro dot there for now. The dot will keep
your parts away from the Pulse Sensor parts enough for you to get a good feel for the sensor
and decide how you want to mount it. You’ll find that the velcro dot comes off easily, and
stores back on the little strip of plastic next to the other one we gave you.

Running The Pulse Sensor Code


We strongly advise that you DO NOT connect the Pulse Sensor to your body while your
computer or arduino is being powered from the mains AC line. That goes for charging
laptops and DC power supplies. Please be safe and isolate yourself from from the power grid,
or work under battery power. Connect the Pulse Sensor to: +V (red), Ground (black), and
Analog Pin 0 (purple) on your favorite Arduino, or Arduino compatible device, and upload
the ‘PulseSensoAmped_Arduino-xx’ sketch.
After it’s done uploading, you should see Arduino pin 13 blink in time with your heartbeat
when you hold the sensor on your fingertip. If you grip the sensor too hard, you will squeeze
all the blood out of your fingertip and there will be no signal! If you hold it too lightly, you
will invite noise from movement and ambient light. Sweet Spot pressure on the Pulse Sensor
will give a nice clean signal. You may need to play around and try different parts of your
body and pressures. If you see an intermittent blink, or no blink, you might be a zombie or a
robot. To view the heartbeat waveform and check your heart rate, you can use the Processing
sketch that we made. Start up Processing on your computer and run the
‘PulseSensorAmped_Processing-xx’ sketch. This is our data visualization software, and it
looks like this.
The large main window shows a graph of raw sensor data over time. The Pulse Sensor Data
Window can be scaled using the scrollbar at the bottom if you have a very large or very small
signal. At the right of the screen, a smaller data window graphs heart rate over time. This
graph advances every pulse, and the Beats Per Minute is updated every pulse as a running
average of the last ten pulses. The big red heart in the upper right also pulses to the time of
your heartbeat. When you hold the Pulse Sensor to your fingertip or earlobe or (fill in body
part here) you should see a nice heartbeat waveform like the one above. If you don’t, and
you’re sure you’re not a zombie, try the sensor on different parts of your body that have
capillary tissue. We’ve had good results on the side of the nose, middle of the forehead,
palm, and lower lip. We’re all different, original organisms. Play around and find the best
spot on you and your friends. As you are testing and getting used to the sensor. You may find
that some fingers or parts of fingers are better than others. For example, I find that when I
position the sensor so that the edge of the PCB is at the bottom edge of my earlobe I get an
awesome signal. Also, people with cold hands or poor circulation may have a harder time
reading the pulse. Run your hands under warm water, or do some jumping-jacks! The Pulse
Sensor signal will settle at the midpoint of the Pulse window when there is no heartbeat, or if
it’s just sitting still on your desk. If you are still seeing only a small pulse waveform, check
the troubleshooting section below for more tips and tricks.

Sealing the Back Side of Pulse Sensor


It’s really important to protect the exposed Pulse Sensor circuitry so the sweat of your
fingertips or earlobe (or wherever) doesn’t cause signal noise or a short circuit. This How-To
uses hot glue, which can be removed easily or re-worked if you want to change where you’ve
stuck your Pulse Sensor. We love hot glue! The other things you’ll need are: Hot Glue Gun
Blue Tape (any tape should do ok) Nail Trimmers (or your favorite trimming device. Flush-
cut wire snips work well too) Read these instructions all the way through before you start!
First, attach the clear vinyl sticker to the front of your Pulse Sensor, as shown above. Then
put a blob of hot glue on the back, right over the circuit. Size can be difficult to judge
sometimes. What I meant was put a hot glue blob about the size of a kidney bean on the back
side of the Pulse Sensor.
Then, while the glue is still very hot, press the Pulse Sensor glue-side-down onto the sticky
side of a piece of blue tape (I believe that blue tape has magical properties, but if you don’t
have blue tape other kinds of tape will work just as well).

note: The tallest thing on the back of the Pulse Sensor is the green LED housing right in the
middle. Use it to make the hot-glue seal thin and strong. When you press evenly until the
back of the LED touches, all the conductive parts will be covered with hot glue. If the glue
doesn’t ooze out all around, let it cool down, then peel if from the Pulse Sensor and try again.
Once the glue has cooled down and has some body, you can peel it off easily. Here’s some
pics of hot glue ‘impressions’ that I took during the making of this guide.
Next put a small dab of hot glue on the front of the cables, where they attach to the Pulse
Sensor circuit board. This will bond to the other glue that’s there and act as a strain-relief for
the cable connection. This is important because the cable connection can wear out over time.
Once the hot glue has cooled (wait for it!) the blue tape will peel off very easily. Check your
work to make sure that there are not exposed electrical connections! Next is trimming. I find
the easiest way is to use nail clippers. Flush cutting wire snips work too. Take care not to clip
the wires!!! And leave enough around the cable to act as a good strain-relief. This is the basic
Pulse Sensor Hot Glue Seal, It’s also got the clear vinyl sticker on the front face. We’re
calling this ‘Water Resistant’, ready to be handled and passed around from fingers to
earlobes or whatever. It is not advised to submerge or soak the Pulse Sensor with this basic
seal. Now you can stick on the velcro dot (included) and make a finger strap with the velcro
tape (included)!
ATTACHING THE EAR CLIP
We looked all over, and were lucky enough to find an ear clip that fits the Pulse Sensor
perfectly. The earlobe is a great place to attach Pulse Sensor. Here’s some instruction on how
to do it. It is important to apply some strain relief to the cable connection where it meets the
Pulse Sensor PCB. The little wire connections can wear out and break (or short on
something) over time. We can do this with hot glue, like we did in the previous example.
First, attach a clear vinyl sticker to the front of the Pulse Sensor if you have not already.
Then, put a small dab of hot glue on the front of the cables right where they meet the PCB.
Get some on the edge of the PCB too, that will help. Remember, if you don’t like the blob
you’ve made for any reason, it’s easy to remove once it cools down. Next place the Pulse
Sensor face down, and put a dab of glue about the size of a kidney bean on the back as
illustrated above. Center the round part of the ear clip on the sensor and press it into the hot
glue. The tallest component on the back is the plastic body of the reverse mount LED, and if
you press it evenly it will help keep the metal of the ear clip from contacting any of the
component connections. Allow the hot glue to ooze out around the ear clip. That will ensure
good coverage. Take care not to let the hot glue cover around the ear clip hinge, as that could
get in the way of it working. Trimming is easy with nail clippers (as above) or your trimming
tool of choice. Don’t trim the wires by mistake!!!

Take a good look at your work with a magnifying glass to be sure that you haven't made
contact with any of the solder joints, then plug it in and test it. Hot glue is also great because
it is easy to remove or re-work if you need to.

Troubleshooting:
 Processing Sketch gives me a COM port error at startup.
Make sure you are plugged into an Arduino board, that it is working correctly, and
running our firmware. Check to see if you have the right serial port. The code underlined
in red should match the correct port number in the terminal window at the bottom of
Processing IDE.
 Processing gives an RXTX mismatch warning, then nothing happens.
The RXTX mismatch problem can be resolved by making sure you are running the latest
version of Processing and Arduino.
You are running the Pulse Sensor at 5V and only get a very small pulse waveform, even
though you know you’re not a zombie last time you checked.

Make sure you have all your connections correct, and that you’re not squeezing too hard
on the Pulse Sensor. If you see a waveform that looks something like this, then you may
get better results by powering the Pulse Sensor with 3.3V. Here’s a simple test and fix to
get you on your way. First, unplug the RED wire from the 5V pin, and plug it into the
3.3V pin as shown here. Then, run the processing sketch and see if you get a better wave
shape.If you see a nice bright pulse waveform, then hooray! this is your fix! Notice,
however that the pulse wave is in the lower portion of the pulse window. That’s because
of the difference in voltage between the power to the Pulse Sensor (3.3V) and the voltage
reference to the Arduino (5V) In order to make the Pulse Sensor work at 3.3V, we have
to adjust either the hardware or the software to get the waveform up to the middle of the
pulse window.

Adjust the Hardware for 3.3V powered Pulse Sensor with Arduino running at 5V

The full range of the Arduino analog input is from 0 to 1023. The range of output from
the Pulse Sensor running at 3.3V is only 0 to 675. We have to scale the Pulse Sensor
signal so that it is sized for the larger expected range. Luckily, there’s a handy-dandy
function in the Arduino language called map(). Change the Pulse Sensor code in the
Interrupt tab so that it looks like this:
// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE.
// Timer 2 makes sure that we take a reading every 2 miliseconds
ISR(TIMER2_COMPA_vect){ // triggered when Timer2 counts to 124
cli(); // disable interrupts while we do this Signal = analogRead(pulsePin);
// read the Pulse Sensor Signal = map(Signal,0,675,0,1023);
// THIS WILL MAP A 3.3V SIGNAL TO 5V ANALOG RANGE sampleCounter += 2;
// keep track of the time in mS with this variable int N = sampleCounter - lastBeatTime;
// monitor the time since the last beat to avoid noise ….....
And there you go. Now you’re happy as a clam. A clam with a big thumping heartbeat!
The BPM values you are seeing seem to be way too high, or way too low. You may need
to change the interrupt settings in the Arduino code. Our Pulse Sensor Amped Arduino
code is based on the Arduino UNO, which uses the ATmega328, and has a system clock
that runs at 16MHz. We set up Timer2, an 8 bit hardware timer, so that it throws an
interrupt every other millisecond. That gives us a sample rate of 500Hz, and beat-to-beat
timing resolution of 2mS. This will disable PWM output on pin 3 and 11. Also, it will
disable the tone() command. This code works with Arduino UNO or Arduino PRO or
Arduino Pro Mini 5V or any Arduino running with an ATmega328 and 16MHz clock.

void interruptSetup()
{
TCCR2A = 0x02;
TCCR2B = 0x06;
OCR2A = 0x7C;
TIMSK2 = 0x02;
sei();
}
The register settings above tell Timer2 to go into CTC mode, and to count up to 124
(0x7C) over and over and over again. A prescaler of 256 is used to get the timing right so
that it takes 2 milliseconds to count to 124. An interrupt flag is set every time Timer2
reaches 124, and a special function called an Interrupt Service Routine (ISR) that we
wrote is run at the very next possible moment, no matter what the rest of the program is
doing. sei() ensures that global interrupts are enabled. Timing is important! If you are
using a different Arduino or Arduino compatible device, you may eed to change this
function. If you are using a FIO or LillyPad Arduino or Arduino Pro Mini 3V or Arduino
SimpleSnap or other Arduino that has ATmega168 or ATmega328 with 8MHz oscillator,
change the line TCCR2B = 0x06 to TCCR2B = 0x05. That will cut the prescaler in half
to 128. If you are using Arduino Leonardo or Adafruit's Flora or Arduino Micro or other
Arduino that has ATmega32u4 running at 16MHz, you need to replace the
interruptSetup() with the following.
void interruptSetup()
{
TCCR0A = 0x02;
TCCR0B = 0x04;
OCR0A = 0x7C;
TIMSK0 = 0x02;
sei();
}
Other devices that use a 32u4 and run under an 8MHz system clock, like the LilyPad
Arduino USB, will need further correction to these settings. Change TCCR0B = 0x04; to
TCCR0B = 0x03; Then change OCR0A = 0x7C; to OCR0A = 0xF9; The only other thing
you will need is the correct ISR vector that gets called. To do this change the line
ISR(TIMER2_COMPA_vect){ to ISR(TIMER0_COMPA_vect) Yes, we know this is
tedious, and we’re working on a Pulse Sensor Library that will handle all of these issues
for you. ;]
You’re trying to use the tone() command to make a sound when your heartbeats, and no
sound comes out of your speaker even though you have it wired correctly. We use the
hardware Timer2 in our code, and so does the tone() command. That’s a conflict. You
will need to change the hardware timer that you’re using. Here’s how to use Timer2
instead of Timer1. In the Interrupt tab, comment out or remove the existing
interruptSetup() routine, and paste in the following code.
void interruptSetup()
{
// Initializes Timer1 to throw an interrupt every 2mS. TCCR1A = 0x00;
// DISABLE OUTPUTS AND PWM ON DIGITAL PINS 9 & 10 TCCR1B = 0x11;
// GO INTO 'PHASE AND FREQUENCY CORRECT' MODE, NO PRESCALER
TCCR1C = 0x00;
// DON'T FORCE COMPARE TIMSK1 = 0x01;
// ENABLE OVERFLOW INTERRUPT (TOIE1) ICR1 = 16000;
// TRIGGER TIMER INTERRUPT EVERY 2mS sei();
// MAKE SURE GLOBAL INTERRUPTS ARE ENABLED
}
Next, change the name of the Interrupt Service Routine function from
ISR(TIMER2_COMPA_vect) to ISR(TIMER1_OVF_vect).
Note: this will disable PWM on pins 9 and 10, and also conflict with the Servo library. There’s
always trade-offs!

BMP180
The new digital barometric pressure sensor of Bosch Sensortec is BMP180, with a very high
performance, which enables applications in advanced mobile devices, such as smart phones,
tablet PCs and sports devices. It follows the BMP085 and brings many improvements, like the
smaller size and the expansion of digital interfaces. The ultra-low power consumption down to
3 µA makes the BMP180 the leader in power saving for your mobile devices. BMP180 is also
distinguished by its very stable behavior (performance) with regard to the independency of the
supply voltage
Through its high relative accuracy of ±0.12 hPa (±1m) the BMP180 has become the most
reliable sensor for precise applications, like indoor-navigation. The small size of 3.6 x 3.8 mm2
and the height of only 0.93 mm makes it very suitable for the implementation in small mobile
devices. The high absolute accuracy (please see parameter sheet beside) and a noise level down
to 0.02 hPa (altitude of 17 cm) open new perspectives for applications in the sport devices. The
BMP180 is a sensor based on piezo-resistive MEMS technology for EMC robustness and high
quality standards. The dies of the BMP180 are protected by a stable and thin LGA package with
a metal lid. The package has seven optimized pins. The BMP180 can communicate directly
with a microcontroller in the device through I2C or SPI as a variant.
BMP180 target applications:
 Indoor navigation
 GPS-enhancement for dead-reckoning, slope detection, etc.
 Sport devices, e.g. altitude profile

Sensor Operation:
The BMP180 comes as a fully calibrated, ready-to-use sensor module without the need for
additional external circuitry. Pressure and temperature data are provided as 16 bit values, which,
together with the stored calibration data, are used for temperature compensation on the external
microcontroller. Data transfer can be performed via I2C or SPI interfaces.
CHAPTER 3
EXPERIMENTAL SETUP AND PROCEDURE
The Internet of Things:
The Internet of Things (IoT) and Internet of Objects both are the same thing, will change
everything—related to our lifes. This may seem like a bold statement, as it can be consider the
impact the Internet already has had on business, science, government, and humanity. The main
thing is that the Internet is one of the most important and powerful creations in the history of the
all over the world.Now we have to agree with that IoT represents the next evolution of the
Internet in the world, it takes huge leap to gather and distribute data that we can turn into
information through internet, knowledge, ultimately, wisdom are also be distributed into data. In
this context,IoT becomes really important. IoT projects are under the way that to precise the
difference between the rich and the poor, improve the world’s progress and resources to those
who need them most, and help us to apprehend our planet so we can be more aggressive and less
compassionate. Even so, several barricade exist that menace to slow IoT development, including
the transition to IPv6, having a common set of definitive, and growing energy sources for
millions—even billions—of minute sensors. However, as businesses, governments, standards
bodies, and academia work together to solve these tasks, IoT will endure to progress. The goal of
this paper, therefore, is to educate you in plain and simple terms so you can be well versed in IoT
and understand its potential to change everything we know to be true today.

IoT Today
As by the new thinking, Massachusetts Institute of Technology (MIT) traced back the root of
IoT, from the work at the auto ID center. Founded in 1999, this group was working in the field of
networked emerging sensing technologies and radio frequency identification (RFID). There are
seven research universities across four continents containg labs for the work IoT. These
institutions were chosen by the Auto-ID Center to design the architecture for IoT. Before we talk
about the current state of IoT, it is important to agree on a definition. According to the Cisco
Internet Business Solutions Group (IBSG), IoT is simply the point in time when more “things or
objects” were connected to the Internet than people. In 2003, there were approximately 6.3
billion people living on the planet and 500 million devices connected to the Internet. By dividing
the number of connected devices by the world population, we find that there was less than one
(0.08) device for every person. Based on Cisco IBSG’s definition, IoT didn’t yet exist in 2003
because the number of connected things was relatively small given that ubiquitous devices such
as smartphones were just being introduced. For example, Steve Jobs, Apple’s CEO, didn’t unveil
the iPhone until January 9, 2007 at the Macworld conference.
Explosive growth of smartphones and tablet PCs brought the number of devices connected to the
Internet to 12.5 billion in 2010, while the world’s human population increased to 6.8 billion,
making the number of connected devices per person more than 1 (1.84 to be exact) for the first
time in history.

Methodology
In January 2009, a team of analyst’s in China studied Internet routing data in six-month of
breathing space, from December 2001 to December 2006. Akin to the properties of Moore’s
Law, their findings showed that the Internet doubles in size every 5.32 years. Using this figure in
combination with the number of devices connected to the Internet in 2003 (500 million, as
determined by Forrester Research), and the world population according to the U.S. Census
Bureau, Cisco IBSG estimated the number of connected devices per person.

Why Is IoT Important?


Before we can begin to see the importance of IoT, it is first necessary to understand the
differences between the Internet and the World Wide Web (or web)—terms that are often used
interchangeably. The Internet is the physical layer or network made up of switches, routers, and
other equipment. Its primary function is to transport information from one point to another
quickly, reliably, and securely. The web, on the other hand, is an application layer that operates
on top of the Internet. Its primary role is to provide an interface that makes the information
flowing across the Internet usable.

Evolution of the Web Versus the Internet


The web has gone through several distinct evolutionary stages:
Stage 1. First was the research phase, when the web was called the Advanced Research Projects
Agency Network (ARPANET). During this time, the web was primarily used by academia for
research purposes.
Stage 2. The second phase of the web can be coined “brochureware.” Characterized by the
domain name “gold rush,” this stage focused on the need for almost every company to share
information on the Internet so that people could learn about products and services.
Stage 3. The third evolution moved the web from static data to transactional information, where
products and services could be bought and sold, and services could be delivered. During this
phase, companies like eBay and Amazon.com exploded on the scene. This phase also will be
infamously remembered as the “dot-com” boom and bust.
Stage 4. The fourth stage, where we are now, is the “social” or “experience” web, where
companies like Facebook, Twitter, and Groupon have become immensely popular and
profitable (a notable distinction from the third stage of the web) by allowing people to
communicate, connect, and share information (text, photos, and video) about themselves with
friends, family, and colleagues.

IoT: First Evolution of the Internet


Before we discuss the evolution of the “Internet of Things” – A.K.A. IoT – let’s start by
defining what the term means exactly. network of devices, buildings, vehicles and other physical
objects embedded with sensors that transmit data between a company and the consumer. The
purpose of all this communicating between the two is to provide consumers smarter products and
services, a better customer experience, and for businesses a competitive edge and ability to build
revenue. By the year 2020, the Internet of Things is predicted to consist of close to 50 billion
objects. In the beginning, a British technology pioneer by the name of Kevin Ashton invented the
term Internet of Things. The term was used to describe exactly what it means today; a system of
connected ubiquitous devices communicating data over the Internet. By comparison, the Internet
has been on a steady path of development and improvement, but arguably hasn’t changed much.
It essentially does the same thing that it was designed to do during the ARPANET era.
CHAPTER 4
SIMULATIONS AND RESULTS
4.2 Main Graphical User Interface
4.3 RESULTS
CHAPTER 5
CONCLUSION AND FUTURE WORK
5.1 Conclusion
In this project report we tried to present the quality Coal miner detector for industrial purpose.
Keeping all necessary parameters in view. For this we use concept of industrial electronics and
instrumentation to set up the experimental prototype and did the professional course needed on
Arduino Mega module and learn internet of things(IOT) execute the project in efficient manner.

Acknowledgement

It gives me immense pleasure to express my deepest sense of gratitude and sincere thanks to my
highly respected and esteemed guide for their valuable guidance, encouragement, and help for
completing this work. Their useful suggestions for this whole work and co-operative behavior
are sincerely acknowledged. I also wish to express my gratitude to _______________ HOD
(Electrical & Electronics Engineering) for his kind-hearted support. I am grateful to my teachers
for their constant support and guidance. I also wish to express my indebtedness to my parents as
well as my family member whose blessings and support always helped me to face the challenges
ahead. At the end, I would like to express my sincere thanks to all my friends and others who
helped me directly or indirectly during this project work.

5.2 Commercial Usage


Being an electronic engineer we always go for an idea that can later be marketed in society and
can advance the human life. Hence in the same regard we will make it in product form and will
try to portray at different exhibitions so that the commercially people may buy it and in this
manner an employment source can be generated

5.2 Recommendations for future work


As in today’s market Arduino has its own software, we being project partners of this project
willing to suggest that one may go for Internet of Things(IOT) because it is the new one
technology which is changing the world so fast and rapidly and which means it will be beneficial
for vendor to maintain the product.

CHAPTER 6
6.1 Appendix
A) CODE
#include "SoftwareSerial.h"

// include the GSM library


#include <GSM.h>

// PIN Number for the SIM


#define PINNUMBER ""

// initialize the library instances


GSM gsmAccess;
GSM_SMS sms;

#include "Arduino.h"
#if !defined(SERIAL_PORT_MONITOR)
#error "Arduino version not supported. Please update your IDE to the latest version."
#endif

#if defined(SERIAL_PORT_USBVIRTUAL)
// Shield Jumper on HW (for Leonardo and Due)
#define port SERIAL_PORT_HARDWARE
#define pcSerial SERIAL_PORT_USBVIRTUAL
#else
// Shield Jumper on SW (using pins 12/13 or 8/9 as RX/TX)

SoftwareSerial port(12, 13);


#define pcSerial SERIAL_PORT_MONITOR
#endif

#include "EasyVR.h"

EasyVR easyvr(port);
enum Group1
{
G1_KNOCK_OPEN = 0,
G1_CLOSE = 1,
};

int8_t group, idx;

#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);

// Array to hold the number a SMS is retreived from


char senderNumber[20];

int EnA = 8;
int EnB = 9;
char c= ' ';

void setup()
{
pinMode(EnA, OUTPUT);
pinMode(EnB, OUTPUT);

// setup PC serial port


pcSerial.begin(9600);

lcd.begin(16, 2);

lcd.setCursor(2, 0);
lcd.print("Secret door");
lcd.setCursor(2, 1);
lcd.print("Knock System");
// GSMserial.begin(9600);
delay(2000);
//Set SMS format to ASCII
GSMserial.write("AT+CMGF=1\r\n");
delay(1000);

//Send new SMS command and message number


GSMserial.write("AT+CMGS=\"03312736902\"\r\n");
delay(1000);

//Send SMS content


GSMserial.write("SYSTEM IS TURNING ON");
delay(1000);

//Send Ctrl+Z / ESC to denote SMS message is complete


GSMserial.write((char)26);
delay(1000);

lcd.clear();

lcd.setCursor(1, 0);
lcd.print("Initializing.");
lcd.setCursor(4, 1);
lcd.print("I2C Bus");
delay(2000);
lcd.clear();

lcd.setCursor(1, 0);
lcd.print("Initializing..");
lcd.setCursor(4, 1);
lcd.print("I2C Bus");
delay(2000);
lcd.clear();

lcd.setCursor(1, 0);
lcd.print("Initializing...");
lcd.setCursor(4, 1);
lcd.print("I2C Bus");
delay(2000);
lcd.clear();

lcd.setCursor(1, 0);
lcd.print("Connecting to");
lcd.setCursor(3, 1);
lcd.print("Data Base");
delay(4000);
lcd.clear();

lcd.setCursor(3, 0);
lcd.print("Connected!");
delay(2000);
lcd.clear();
*/

// bridge mode?
int mode = easyvr.bridgeRequested(pcSerial);
switch (mode)
{
case EasyVR::BRIDGE_NONE:
// setup EasyVR serial port
port.begin(9600);
// run normally
pcSerial.println(F("---"));
pcSerial.println(F("Bridge not started!"));
break;

case EasyVR::BRIDGE_NORMAL:
// setup EasyVR serial port (low speed)
port.begin(9600);
// soft-connect the two serial ports (PC and EasyVR)
easyvr.bridgeLoop(pcSerial);
// resume normally if aborted
pcSerial.println(F("---"));
pcSerial.println(F("Bridge connection aborted!"));
break;

case EasyVR::BRIDGE_BOOT:
// setup EasyVR serial port (high speed)
port.begin(115200);
// soft-connect the two serial ports (PC and EasyVR)
easyvr.bridgeLoop(pcSerial);
// resume normally if aborted
pcSerial.println(F("---"));
pcSerial.println(F("Bridge connection aborted!"));
break;
}

while (!easyvr.detect())
{
Serial.println("EasyVR not detected!");
delay(1000);
}

easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println("EasyVR detected!");
easyvr.setTimeout(5);
easyvr.setLanguage(0);

group = EasyVR::TRIGGER; //<-- start group (customize)


}

//void action();
void RecieveMessage();

void loop()
{

RecieveMessage();

/* GSMserial.write("AT+CMGF=1\r\n");
delay(1000);
c = Gc.write("AT+CMGR=3\r\n");

Serial.println("MSG");
Serial.print(c);
Serial.println("MSG2");*/

if (easyvr.getID() < EasyVR::EASYVR3)


easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)

Serial.print("Say a command in Group ");


Serial.println(group);

lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Say Command...");

easyvr.recognizeCommand(group);

do
{
// can do some processing while waiting for a spoken command
}
while (!easyvr.hasFinished());

if (easyvr.getID() < EasyVR::EASYVR3)


easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off

idx = easyvr.getWord();
if (idx >= 0)
{
// built-in trigger (ROBOT)
// group = GROUP_X; <-- jump to another group X
return;
}
idx = easyvr.getCommand();
if (idx >= 0)
{
// print debug message
uint8_t train = 0;
char name[32];
Serial.print("Command: ");
Serial.print(idx);
if (easyvr.dumpCommand(group, idx, name, train))
{
Serial.print(" = ");
Serial.println(name);
}
else
Serial.println();
// beep
easyvr.playSound(0, EasyVR::VOL_FULL);
// perform some action
// action();
}
else // errors or timeout
{
if (easyvr.isTimeout())
Serial.println("Timed out, try again...");
int16_t err = easyvr.getError();

lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Timed out");
lcd.setCursor(3, 1);
lcd.print("Try Again!");
delay(2000);
//readsms ();

if (err >= 0)
{
Serial.print("Error ");
Serial.println(err, HEX);
}
}

void RecieveMessage()
{
// If there are any SMSs available()
if (sms.available()) {
Serial.println("Message received from:");

// Get remote number


sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);

// An example of message disposal


// Any messages starting with # should be discarded
if (sms.peek() == '#') {
Serial.println("Discarded SMS");
sms.flush();
}

// Read message bytes and print them


while (c = sms.read()) {
Serial.print(c);
}

Serial.println("\nEND OF MESSAGE");

// Delete message from modem memory


sms.flush();
Serial.println("MESSAGE DELETED");
}

delay(1000);
if(c=='y' || c=='Y'){
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000);
}
if(c=='n' || c=='N'){
digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the voltage level)
delay(1000);
}

void action()
{

switch (group)
{
case GROUP_0:
switch (idx)
{
case G0_START:
group = GROUP_1;
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Setup Complete");
delay(2000);
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_KNOCK_OPEN:

digitalWrite(EnA, HIGH);
digitalWrite(EnB, LOW);
delay(200);
digitalWrite(EnA, LOW);
digitalWrite(EnB, LOW);

lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Door Open");

//Send new SMS command and message number


GSMserial.write("AT+CMGF=1\r\n");
delay(1000);

GSMserial.write("AT+CMGS=\"03312736902\"\r\n");
delay(1000);

//Send SMS content


GSMserial.write("DOOR IS OPEN");
delay(1000);

//Send Ctrl+Z / ESC to denote SMS message is complete


GSMserial.write((char)26);
delay(1000);
lcd.clear();

break;

case G1_CLOSE:
digitalWrite(EnA, LOW);
digitalWrite(EnB, HIGH);
delay(200);
digitalWrite(EnA, LOW);
digitalWrite(EnB, LOW);

lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Door Closed");

//Send new SMS command and message number

GSMserial.write("AT+CMGF=1\r\n");
delay(1000);

GSMserial.write("AT+CMGS=\"03312736902\"\r\n");
delay(1000);

//Send SMS content


GSMserial.write("DOOR IS CLOSED");
delay(1000);

//Send Ctrl+Z / ESC to denote SMS message is complete


GSMserial.write((char)26);
delay(1000);

lcd.clear();

break;
}
break;
}
}

You might also like