You are on page 1of 40

ABSTRACT

The accidents in coal mines are increased day by day. There are numerous
life losses of many skilled workers and laborers. There is no advent precaution
measure to detect the alarming cause of the coal mine accidents and provide an
alert system. Occupational accidents and occupational diseases are common in the
mining. The most common causes of accidents in coal mining are firedamp and
dust explosions, landslips, mine fires, and technical failures related to transport and
mechanization. Ananalysis of occupational accidents in the consideration of social
and economic factors reports that the real causes behind these accidents, which are
said to happen inevitably due to technical deficiencies or failures. Thus an
automated alarming coal mine accident detection system is employed to rescue and
protect the workers from the hazards. This system incorporates the combined
action of the temperature, pressure and gas sensor and IOT module to detect the
temperature, pressure and atmosphere in the coal mine and log every data onto the
cloud using data logging. Then these data are accepted by a admin controlled sever
page through data acquisition. The data processing takes place at a server page and
the alert is send to the device to glow the alarm and to to the concerned officials
and rescue stations for taking the prevention measures.
INTRODUCTION

The accident is any uncertain activity due to unavoidable circumstances and


carelessness of some people. This incident is happening continuously all arounfd
the world. A large number of workers (approximately 2.3 million) die each year
worldwide, 350,000 because of occupational accidents and approximately 2
million because of occupational diseases. Occupational health is defined as an area
of application in which the effects of work life on health are investigated. A public
health approach, using the notion of occupational health represents a partial
understanding of health, leads to defining workplace and work life as outside of
public health. The reasons for that are that citizens are seen not as workers but as
consumers and that work life is moved out of the healthcare field. This causes
occupational health to detach from public health when organizing healthcare
services . The basic area that problems arise in terms of worker’s health and safety
is the production activities phase. Production activities consist of main activities
such as excavation, ground support, and haulage as well as activities such as
electricity maintenance, establishing and managing pressurized room networks,
communication and signalization systems, and maintenance and repair of various
machines and equipment. In particular, accidents in coal mining related to
collapses, pit fires, firedamp and coal dust explosions, haulage, and mechanization
frequently occur in underground pits. Thus they end up with many complications
physically.
PROBLEM STATEMENT

The major problem identified is that there are numerous accidents occuring
in the coal mines due to improper maintanance and inadequate monitoring of the
mining activities. These led to numerous lifelosses and immeasurable resourse
loss. There is no proper early deetction of the uncertainity in the coal mines. Coal
mining has been a very dangerous activity. The principal hazards are mine wall
failures and vehicle collisions; underground mining hazards include suffocation,
gas poisoning, roof collapse and gas explosions. Chronic lung diseases, such as
pneumoconiosis (black lung) were once common in miners, leading to reduced life
expectancy. In some mining countries black lung is still common. However, in
lesser developed countries and some developing countries, many miners continue
to die annually, either through direct accidents in coal mines or through adverse
health consequences from working under poor conditions.
LITERATURE REVIEW

In the hazardous environment, industrialized accident occur. Due to which


consequence may be very serious and it causes loss of environment, property and
life. For moral, legal, & financial reasons hazardous environmental safety &
security is more important wireless sensor network in industrial site, the
deployment of distributed point source where the dangerous parameters used,
produced and stored is described seven characteristics , undamental aspects for
estimating and mission method were identified. For measurement of temperature
using Virtual Instrumentation is by Automatic Process Control in many industries.
Some project sources in WSN systems that monitors coal mines are as follows:

 ZIGBEE BASED INTELLIGENT HELMET FOR COAL MINERS


 Design of Coal Mine Intelligent Monitoring System based on ZigBee
Wireless Sensor Network, 2016
 An Event Reporting and EarlyWarning Safety System Based on the Internet
of Things for Underground Coal Mines: A Case Study, 2017
 Application of WSN Fire Monitoring System in Coal Mining, 2017
 Design Of Underground Coal Mine Monitoring System, 2013
EMBEDDED SYSTEM

INTRODUCTION

An embedded system is a computer system designed to perform one or a


few dedicated functions often with real-time computing constraints. It is embedded
as part of a complete device often including hardware and mechanical parts. By
contrast, a general-purpose computer, such as a personal computer (PC), is
designed to be flexible and to meet a wide range of end-user needs. Embedded
systems control many devices in common use today.

Since the embedded system is dedicated to specific tasks, design engineers


can optimize it reducing the size and cost of the product and increasing the
reliability and performance. Some embedded systems are mass-produced,
benefiting from economies of scale.

Physically, embedded systems range from portable devices such as digital


watches and MP3 players, to large stationary installations like traffic lights, factory
controllers, or the systems controlling nuclear power plants. Complexity varies
from low, with a single microcontroller chip, to very high with multiple units,
peripherals and networks mounted inside

Characteristics

 Embedded systems are designed to do some specific task, rather than be a


general-purpose computer for multiple tasks. Some also have real-time
performance constraints that must be met, for reasons such as safety and
usability; others may have low or no performance requirements, allowing the
system hardware to be simplified to reduce costs.
 Embedded systems are not always standalone devices. Many embedded
systems consist of small, computerized parts within a larger device that
serves a more general purpose. For example, the Gibson Robot Guitar
features an embedded system for tuning the strings, but the overall purpose
of the Robot Guitar is, of course, to play music. [5] Similarly, an embedded
system in an automobile provides a specific function as a subsystem of the
car itself.
 The program instructions written for embedded systems are referred to as
firmware, and are stored in read-only memory or Flash memory chips. They
run with limited computer hardware resources: little memory, small or non-
existent keyboard and/or screen.

Tools

As for other software, embedded system designers use compilers,


assemblers, and debuggers to develop embedded system software. However, they
may also use some more specific tools:

 In circuit debuggers or emulators (see next section).


 Utilities to add a checksum or CRC to a program, so the embedded system
can check if the program is valid.
 For systems using digital signal processing, developers may use a math
workbench such as Scilab / Scicos, MATLAB / Simulink, EICASLAB,
MathCad, or Mathematica to simulate the mathematics. They might also use
libraries for both the host and target which eliminates developing DSP
routines as done in DSPnano RTOS and Unison Operating System.
 Custom compilers and linkers may be used to improve optimisation for the
particular hardware.
 An embedded system may have its own special language or design tool, or
add enhancements to an existing language such as Forth or Basic.
 Another alternative is to add a real-time operating system or embedded
operating system, which may have DSP capabilities like DSPnano RTOS.
EXISTING SYSTEM

There are existing coal mine alert systems that is built using sensors and
WSN.The coal mine intelligent monitoring system, through the mine field of
ZigBee nodes to collect a variety of wireless data, through the switch to downhole
monitoring sites which adopts a ring network connection that can communicate
conveniently. In addition the system sets up a backup underground control and
monitoring stations. The data is transmitted using Ethernet connection. It includes
wireless data acquisition subsystem based on ZigBee network, industrial Ethernet
transmission subsystem and remote monitoring system.

Mine safety systems based on IoT seamlessly integrate gas sensing


monitoring, miner tracking, and cloud computing to create anintelligent loop of
safety through analytics. IoT utilizes BLE for transmitting data fromn Arduino
modular sensors. The cloud is helpful for determining the service state of the mine
and for sharing information. The coal mine fire monitoring system based on Zig-
bee technology, and discusses the network data transmission process in the system.
When the systemis applied to an actual coal mine, it achieves a sound fire
monitoring effect. The wireless sensor network (WSN) coal mine fire monitoring
system consists of such three subsystems as data acquisition subsystem, control
center subsystem and emergency response subsystem. With sensor nodes as the
basic unit, the WSN is divided into five parts: sensor module, treatment module,
wireless communication module, location module and power supply module. The
system can monitor the air temperature, humidity and smoke concentration of fire
inthe coal mine, and provide effective basis for monitoring department to make
decisions on fire prevention and control measures. These basic systems dont not
rely on cloud for entire data logging, data acquistion and data processing. They
completely depend on the WSN that transmits data to nodal points not the cloud.
This may make the system unreliable at emegency suitations. The data rate
transmission and governing these data is done at the faster rate during emegency
suitations.
PROPOSED SYSTEM

The planned system consists of the device modules that since all the
information around the mine setting and logs the information onto the cloud
controlled server page the IOT module. The sever page is maintained IOT module.
The logged information is processed into the common values for every entry on an
associate interval basis. These prices area unit mechanically processed employing a
predefined value maintained by the server page. Once there's associate absolute
modification within the values of the perceived information associate alert is
shipped to the IOT MODULE and also the involved authorities. The IOT module
detects the alert signal and glows the intrinsic device and alert messages to the
authorities could take precaution steps. The most advantage of this project is that
IoT detects the uncertainty within the setting beforehand victimization information
analysis reports things to the involved authority and also the miners. The system
conjointly considers the emergency things in hand to alert the miners as quickly as
attainable.
BLOCK DIAGRAM

ARDUINO UNO
BLOCK DIAGRAM DESCRIPTION

The Temperature sensor is used to measure the mine temperature and


humidity sensor measures the humidity level in mining time. The gas sensor is
using to find them gas level in mining and the LDR sensor is used to find the light
density and if any abnormal value means the microcontroller will send each second
value to IOT cloud and electrical devices upon the sensor value. all sensor value is
uploaded to the IOt cloud in this method.
HARDWARE AND SOFTWARE USED

HARDWARE

 Nodemcu esp8266
 LDR sensor
 LM35 sensor
 humidity sensor
 Gas sensor

SOFTWARE

 Arduino IDE

HARDWARE DESCRIPTION

POWER SUPPLY

The circuit uses standard power supply comprising of a step-down


tra59nsformer from 230v to 12v and 4 diodes forming a Bridge Rectifier that
delivers pulsating dc which is then filtered by an electrolytic capacitor of about
470microf to 100microF. The filtered dc being un regulated IC LM7805 is used to
get 5v constant at its pin no 3 irrespective of input dc varying from 9v to 14v. The
input dc shall be varying in the event of input ac at 230volts section varies in the
ratio of v1/v2=n1/n2.

The regulated 5volts dc is further filtered by a small electrolytic capacitor of 10


micro f for any noise so generated by the circuit. One LED is connected of this 5v
point in series with a resistor of 330ohms to the ground i.e. negative voltage to
indicate 5v power supply availability. The 5v dc is at 12v point is used for other
applications as on when required.

AVR MICROCONTROLLER :

AVR is a family of microcontrollers developed since 1996 by Atmel,


acquired by Microchip Technology in 2016. These are modified Harvard
architecture 8-bit RISC single-chip microcontrollers. AVR was one of the first
microcontroller families to use on-chip flash memory for program storage, as
opposed to one-time programmable ROM, EPROM, or EEPROM used by other
microcontrollers at the time.

AVR microcontrollers come in different packages, some designed for through-hole


mounting and some surface mount. AVRs are available with 8-pins to 100-pins,
although anything 64-pin or over is surface mount only. Most people start with a
DIL (Dual In Line) 28-pin chip like the ATmega328 or the 40-pin ATmega16 or
ATmega32.

ATmega16 is an 8-bit high performance microcontroller from the Atmel’s Mega


AVR family. Atmega16 is a 40 pin microcontroller based on enhanced RISC
(Reduced Instruction Set Computing) architecture with 131 powerful instructions.
It has a 16 KB programmable flash memory, static RAM of 1 KB and EEPROM of
512 Bytes. The endurance cycle of flash memory and EEPROM is 10,000 and
100,000, respectively. Most of the instructions execute in one machine cycle. It can
work on a maximum frequency of 16MHz. There are 32 I/O (input/output) lines
which are divided into four 8-bit ports designated as PA, PB, PC and PD.
ATmega16 has various in-built peripherals like USART, ADC, Analog
Comparator, SPI, JTAG etc. Each I/O pin has an alternative task related to in-built
peripherals.

FIGURE 4.3 AVR ATmega16 Microcontroller pin diagram

Table 4.1 Pin Configuration of ATMEGA16

Pin name Description

Pin 1 I/O , T0 ( Timer0 External Counter Input) ,XCK : USART


External Clock I/O

Pin 2 I/O, T1 (Timer1 External Counter Input)

Pin3 I/O, AIN0: Analog Comparator Positive Input , INT2: External


Interrupt 2 Input

Pin 4  I/O, AIN1: Analog Comparator Negative Input, OC0 : Timer0


Output Compare Match Output

Pin 9 Reset Pin, Active Low Reset

Pin 10 VCC=+5V

Pin 11,12 & 13 GND, XTAL1 & XTAL2

Pin 14 & 15  (RXD) ,I/O PIN 0,USART Serial Communication Interface &

(TXD) ,I/O Pin 1,USART Serial Communication Interface

Pin 15 (INT0),I/O Pin 2, External Interrupt INT0

Pin 16 (INT1),I/O Pin 3, External Interrupt INT1

Pin 17 (OC1B),I/O Pin 4, PWM Channel Outputs

Pin 18 (OC1A),I/O Pin 5, PWM Channel Outputs

Pin 19 (ICP), I/O Pin 6, Timer/Counter1 Input Capture Pin

Pin 21 (OC2),I/O Pin 7,Timer/Counter2 Output Compare Match Output

Pin 22 (SCL),I/O Pin 0,TWI Interface

Pin 23 (SDA),I/O Pin 1,TWI Interface

Pin 24-27 JTAG INTERFACE

Pin 28 (TOSC1),I/O Pin 6,Timer Oscillator Pin 1

Pin 29 (TOSC2),I/O Pin 7,Timer Oscillator Pin 2

Pin 30  AVCC (for ADC)

Pin 31  GND (for ADC)


Pin 33-40 PAx: I/O, ADCx (Where x is 7 – 0)

ATMEGA16 – Features

 It has low power CMOS 8-bit controller with AVR RISC


 Its throughput is up to 16MIPS per
 It has 32 General purpose registers directly connected to
 16 Kbytes In-System programmable flash
 512 bytes of EEPROM, 1k byte SRAM, JTAG
 Three timer/counter for comparison
 Internal and external interrupts
 Serial programmable USART+I2C protocol

Alcohol Gas Sensor

MQ3- Co2 Gas Sensor is a low-cost semiconductor sensor which, used to


detect the presence of carbon gas at concentrations from 0.05 mg/L to 10 mg/L. It
has high sensitivity to Co2 and has a good resistance to disturbances due to smoke,
vapour and gasoline. The sensitive material used for this sensor is SnO2, whose
conductivity is lower in clean air. Its conductivity increases as the concentration of
Co2 vapour gas increases. This module provides both digital and analog outputs.

This alcohol sensor is suitable for detecting Co2 concentration on your


breath. It has a high sensitivity and fast response time. The sensor provides an
analog resistive output based on Co2 concentration. The drive circuit is very
simple, all it needs is a resistor. A simple interface could be a 0-3.3V ADC.
Figure 4.7 Alcohol Gas Sensor

Features of MQ3- Alcohol Gas Sensor:

 Operating Voltage: 5V ± 0.1


 Concentration: 0.05 mg/L ~ 10 mg/L Co2
 Current Consumption: 150mA
 Output sensitivity adjustable
 Analog output 0V to 5V and Digital output 0V or 5V
 Low Cost and Fast Response
 Stable and Long Life
 Fair Sensitivity to Alcohol Gas
 Both Digital and Analog Outputs
 Operation Temperature: -10°C ~ 70°C

Vibration Sensor Module

Vibration Switch SW-420  is based on the vibration sensor SW-420 and


Comparator LM393 to detect if there is any vibration that beyond the threshold.
The threshold can be adjusted by the on-board potentiometer. When this no
vibration, this module output logic LOW the signal indicate LED light, and vice
versa.
Figure 4.8 Vibration Sensor

Features of vibration sensor:

 The comparator output, signal clean, good waveform, driving ability is


strong, for more than 15 ma
 The working voltage of 3.3V to 5V
 Output form: digital switch output (0 and 1)
 Has a fixed bolt hole, convenient installation
 Use the LM393 wide voltage comparator

LDR Sensor:

A Light Dependent Resistor is a device whose resistivity is a function of the


incident electromagnetic radiation. Hence, they are light-sensitive devices. They
are also called as photoconductors, photoconductive cells or simply photocells.
They are made up of semiconductor materials that have high resistance. There are
many different symbols used to indicate a photo resistor or LDR, one of the most
commonly used symbol is shown in the figure below. The arrow indicates light
falling on it. Photoresistors (LDRs) can be categorized into two types depending on
the materials used to construct them. The two types of photoresistors include:
1. Intrinsic photoresistors (Undoped semiconductor): These are made of pure
semiconductor materials such as silicon or germanium. Electrons get excited
from valance band to conduction band when photons of enough energy fall
on it and the number charge carriers are increased.
2. Extrinsic photoresistors: These are semiconductor materials doped with
impurities which are called dopants. These dopants create new energy bands
above the valence band which is filled with electrons. Hence this reduces the
bandgap and less energy is required in exciting them. Extrinsic
photo resistors are generally used for long wavelengths.

Figure 4.9 LDR Sensor

Features of LDR

 Can be used to sense Light.


 Easy to use on Breadboard.
 Easy to use with Microcontrollers or even with normal Digital/Analog IC.
 Small, cheap and easily available.
SOFTWARE DESCRIPTION

PROcessor for Text Easy to Use SOFTWARE

The Proteus Design Suite is a proprietary software tool suite used primarily


for electronic design automation. The software is used mainly by electronic design
engineers and technicians to create schematics and electronic prints for
manufacturing printed circuit boards. It was developed in Yorkshire, England by
Lab center Electronics Ltd and is available in English, French, Spanish and
Chinese languages.

4.5.1.1 Introduction:

The first version of what is now the Proteus Design Suite was called PC-B and was
written by the company chairman, John Jameson, for DOS in 1988. Schematic
Capture support followed in 1990, with a port to the Windows environment shortly
thereafter. Mixed mode SPICE Simulation was first integrated into Proteus in 1996
and microcontroller simulation then arrived in Proteus in 1998. Shape based auto
routing was added in 2002 and 2006 saw another major product update with 3D
Board Visualisation. More recently, a dedicated IDE for simulation was added in
2011 and MCAD import/export was included in 2015. Support for high speed
design was added in 2017. Feature led product releases are typically biannual,
while maintenance based service packs are released as it is required.
Proteus-overview

Product Modules:

The Proteus Design Suite is a Windows application for schematic


capture, simulation, and PCB (Printed Circuit Board) layout design. It can be
purchased in many configurations, depending on the size of designs being
produced and the requirements for microcontroller simulation. All PCB Design
products include an auto router and basic mixed mode SPICE simulation
capabilities.

Schematic Capture:

Schematic capture in the Proteus Design Suite is used for both the simulation of
designs and as the design phase of a PCB layout project. It is therefore a core
component and is included with all product configurations

Figure 4.15 Proteus software


Microcontroller Simulation:

The micro-controller simulation in Proteus works by applying either a hex file or a


debug file to the microcontroller part on the schematic. It is then co-simulated
along with any analog and digital electronics connected to it. This enables its use in
a broad spectrum of project prototyping in areas such as motor control, temperature
control and user interface design. It also finds use in the general hobbyist
community and, since no hardware is required, is convenient to use as a training or
teaching tool.

PCB Design:

The PCB Layout module is automatically given connectivity information in the


form of a netlist from the schematic capture module. It applies this information,
together with the user specified design rules and various design automation tools,
to assist with error free board design. PCB’s of up to 16 copper layers can be
produced with design size limited by product configuration.

3D Verification:

The 3D Viewer module allows the board under development to be viewed in 3D


together with a semi-transparent height plane that represents the boards
enclosure. STEP output can then be used to transfer to mechanical CAD software
such as Solidworks or Autodesk for accurate mounting and positioning of the
board.

The ARDUINO IDE (INTEGRATED DEVELOPMENT ENVIRONMENT)

The Arduino Integrated Development Environment (IDE) is a cross-


platform application that is written in functions from C and C++. It is used to write
and upload programs to Arduino compatible boards, but also, with the help of 3 rd
party cores, other vendor development boards.

The source code for the IDE is released under the GNU General Public License,
version 2. The Arduino IDE supports the languages C and C++ using special rules
of code structuring. The Arduino IDE supplies a software library from
the Wiring project, which provides many common input and output procedures.
User-written code only requires two basic functions, for starting the sketch and the
main program loop, that are compiled and linked with a program stub main() into
an executable cyclic executive program with the GNU toolchain, also included
with the IDE distribution. The Arduino IDE employs the program avrdude to
convert the executable code into a text file in hexadecimal encoding that is loaded
into the Arduino board by a loader program in the board’s firmware.

Figure
4.16
Arduino
IDE

4.5.3

Embedded c

Embedded c is a set of language extensions for the c programming language


by the c standards committee to address commonality issues that exist between c
extensions for different embedded systems. Historically, embedded c programming
requires nonstandard extensions to the c language in order to support exotic
features such as fixed-point arithmetic, multiple distinct memory banks, and basic
I/o operations.

Difference between C and Embedded C

C is a type of computer programming language. Dennis Ritchie at AT&T


Bell Labs originally developed c between 1969 and 1973. It has a free-format
program source code.

C is a type of computer programming language. Embedded c, on the other


hand, it is a set of language extensions for the c programming language. The c
standards committee released it. Through the embedded c extensions, the c
standards committee hoped to address the commonality issues that exist between c
extensions for different embedded systems. C is a type of computer programming
language. Dennis Ritche at AT&T Bell labs originally developed c between 1969
and 1973. It has a free format program source code. C is a general-purpose
programming language that use semicolon (;) as a statement terminator, as well as
curly braces ({}) for grouping blocks of statements. It has facilities for structured
programming and its design provides constructs that can map efficiently to typical
machine instructions. It also allows lexical variable scope and recursion and has a
static type system, which prevents many unintended operations. C is one of the
oldest currently used programming languages and is one of the most widely used
programming languages. It has been constantly used in applications that had
previously coded in assembly language. This includes the UNIX’ computer
operating system. C has directly or indirectly influenced many of the later
programming languages, such as C#, D, Go, JavaScript, Limbo, LPC, Perl, PHP,
Python and UNIX’s C shell. Despite all these new languages, C remains a popular
programming language.
Conclusion

The study on real-time monitoring of toxic gases and other parameters


present in underground mine has analyzed using wireless sensor networks. A real-
time monitoring system is developed to provide clearer and more point to point
perspective of the underground mine. This system is displaying the parameters on
the serial monitor at the underground section where sensor unit is installed as well
as on the monitoring unit; it will be helpful to all miners present inside the mine to
save their life before any casualty occurs. Alarm triggers when sensor values cross
the threshold level. This system also stores all the data in the IOT cloud.

CODING

#include <SoftwareSerial.h>

#define RX 2

#define TX 3

#include <TroykaDHT.h>

DHT dht(6, DHT11);


#include <LiquidCrystal.h>

const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

String AP = "SKYSOFT"; // CHANGE TO WIFI NAME

String PASS = "TN72BF8291"; // CHANGE TO PASSWORD

String API = "M6NJBQVKLZ97VPJF"; // CHANGE TO API KEY

String HOST = "api.thingspeak.com";

String PORT = "80";

String temp = "field1";

String carbon = "field4";

String humi = "field2";

String VIBRAT = "field3";

const int mq7pin = A0;


const int vibpin = 7;

const int ligpin = 5;

int countTrueCommand;

int countTimeCommand;

boolean found = false;

const int threshold = 35;

const int threshold1 = 50;

const int threshold2 = 250;

const int out3 = A5;

const int out2 = A4;

const int out1 = A3;

SoftwareSerial esp8266(RX,TX);

void setup()

{
pinMode(out1, OUTPUT);

pinMode(out2, OUTPUT);

pinMode(out3, OUTPUT);

lcd.begin(16, 2);

Serial.begin(9600);

lcd.setCursor(0, 0);

lcd.print(" WELCOME ");

lcd.setCursor(0, 1);

lcd.print(" TO ");

delay(2000);

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(" COAL MINE GAS ");

lcd.setCursor(0, 1);

lcd.print(" MONITORING ");

delay(2000);

lcd.clear();

dht.begin();
esp8266.begin(115200);

sendCommand("AT",5,"OK");

sendCommand("AT+CWMODE=1",5,"OK");

sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");

void loop()

lcd.setCursor(0, 0);

lcd.print(" CHECKING.. ");

lcd.setCursor(0, 1);

lcd.print(" SENSOR VALUE ");

delay(2000);

lcd.clear();

dht.read();

// проверяем состояние данных

switch(dht.getState()) {

// всё OK

case DHT_OK:

// выводим показания влажности и температуры


Serial.print("Temperature = ");

Serial.print(dht.getTemperatureC());

Serial.println(" C \t");

Serial.print("Temperature = ");

Serial.print(dht.getTemperatureK());

Serial.println(" K \t");

Serial.print("Temperature = ");

Serial.print(dht.getTemperatureF());

Serial.println(" F \t");

Serial.print("Humidity = ");

Serial.print(dht.getHumidity());

Serial.println(" %");

break;

// ошибка контрольной суммы

case DHT_ERROR_CHECKSUM:

Serial.println("Checksum error");

break;

// превышение времени ожидания

case DHT_ERROR_TIMEOUT:

Serial.println("Time out error");


break;

// данных нет, датчик не реагирует или отсутствует

case DHT_ERROR_NO_REPLY:

Serial.println("Sensor not connected");

break;

vibra();

Light();

tempe();

humid();

CO2();

void tempe()

int sens1 = dht.getTemperatureC();


lcd.setCursor(0, 0);

lcd.print("TEM: ");

lcd.setCursor(4, 0);

lcd.print(sens1);

delay(2000);

if (sens1 >= threshold)

digitalWrite(out1, HIGH);

else

digitalWrite(out1, LOW);

String getData = "GET /update?api_key="+ API +"&"+ temp +"="+String(sens1);

sendCommand("AT+CIPMUX=1",5,"OK");

sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");

sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");

esp8266.println(getData);delay(1500);countTrueCommand++;

sendCommand("AT+CIPCLOSE=0",5,"OK");

}
void humid()

lcd.setCursor(8, 0);

lcd.print("HUM: ");

lcd.setCursor(12, 0);

lcd.print(dht.getHumidity());

delay(2000);

if (dht.getHumidity() <= threshold1)

digitalWrite(out2, HIGH);

else

digitalWrite(out2, LOW);

String getData = "GET /update?api_key="+ API +"&"+ humi


+"="+String(dht.getHumidity());
sendCommand("AT+CIPMUX=1",5,"OK");

sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");

sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");

esp8266.println(getData);delay(1500);countTrueCommand++;

sendCommand("AT+CIPCLOSE=0",5,"OK");

void vibra()

int sens2 = digitalRead(vibpin);

delay(2000);

if (sens2 == LOW)

digitalWrite(out2, HIGH);

else

digitalWrite(out2, LOW);

}
String getData = "GET /update?api_key="+ API +"&"+ VIBRAT
+"="+String(sens2);

sendCommand("AT+CIPMUX=1",5,"OK");

sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");

sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");

esp8266.println(getData);delay(1500);countTrueCommand++;

sendCommand("AT+CIPCLOSE=0",5,"OK");

void Light()

int sens3 = digitalRead(ligpin);

lcd.setCursor(0, 1);

lcd.print("LIG: ");

// lcd.setCursor(4, 1);

// lcd.print(sens3);

delay(2000);

if (sens3 == HIGH)

digitalWrite(out3, HIGH);
lcd.setCursor(4, 1);

lcd.print("ON");

else

digitalWrite(out3, LOW);

lcd.setCursor(4, 1);

lcd.print("OFF");

void CO2()

int sens4 = analogRead(mq7pin);

lcd.setCursor(8, 1);

lcd.print("CO2:");

lcd.setCursor(12, 1);

lcd.print(sens4);

delay(2000);

Serial.print("CO2:");
Serial.println(sens4);

delay(2000);

if (sens4 >= threshold1)

digitalWrite(out2, HIGH);

else

digitalWrite(out2, LOW);

String getData = "GET /update?api_key="+ API +"&"+ carbon


+"="+String(sens4);

sendCommand("AT+CIPMUX=1",5,"OK");

sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");

sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");

esp8266.println(getData);delay(1500);countTrueCommand++;

sendCommand("AT+CIPCLOSE=0",5,"OK");

void sendCommand(String command, int maxTime, char readReplay[])

{
Serial.print(countTrueCommand);

Serial.print(". at command => ");

Serial.print(command);

Serial.print(" ");

while(countTimeCommand < (maxTime*1))

esp8266.println(command);//at+cipsend

if(esp8266.find(readReplay))//ok

found = true;

break;

countTimeCommand++;

if(found == true)

Serial.println("OYI");

countTrueCommand++;
countTimeCommand = 0;

if(found == false)

Serial.println("Fail");

countTrueCommand = 0;

countTimeCommand = 0;

found = false;

You might also like