Railway Track Crack Detection
Railway Track Crack Detection
           BACHELOR OF TECHNOLOGY
                      in
   ELECTRONICS AND COMUNICATION ENGINEERING
         Indian Railroad is one of the biggest railroad systems on earth. Despite the fact that there is
enormous development in the Indian railroads, some of the accidents occur due to cracks which occur in
the railway track. In this paper we are thinking about the serious issues that result in accidents. To
overcome this major problem, we have proposed another monitoring train that uses an infrared sensor
which is used to detect the crack in the railway track and used to send the data and call via IOT and
GPRS module with the help of Arduino NODEMCU. During different seasons the track is expanded or
contracted due to which splits may happen. This testing train is used to detect the crack, when it detects,
the train stops and sends the signals to the nearest station. This intelligent system provides protection
and an online monitoring system.
       Index Terms: Arduino NODEMCU, IOT , INFRARED Sensor, Intelligent Systems, online
monitoring, protection
         The automation of Railway gates at intersections crossing is very important to avoid accidents
near it. At present, railway crossing gates are operated manually by gate operators. When a train leaves
the station, the in-charge person of the station sends the signal/information to the gate operator about the
departure and arrival of the train. The involvement of humans is avoided by automating the process. If a
train's arrival is delayed for any reason, the care is taken that gates are not opened for a long period of
time due to this it leads to the traffic jam and also wastage of time. The system uses two Infrared (IR)
sensors in order to sense the arrival and going movement of the railway engine. Train’s advent when
detected, signal in the form of sound and warning light signal indication is given to the commuters to
warn about the advent of the train towards me. Sensor I sense the advent of the train the warning is given
in the form of red color light and the driving agent attached to the gate will start to shut the opened gate.
In order to control the gate motor has been used. The gates are made to shut unless and until the train
passes completely and moves away from the railway gate. The motor helps in lifting and shutting the
gate based on coming and going of the train which is done with the help of sensors. Sensors will play a
vital role in automating the things along with the help of motor and arduino as a controller.
                                                     ii
                            TABLE OF CONTENTS
ACKNOWLEDGMENT Iii
ABSTRACT Iv
1.2 Characteristics 2
1.3 Microprocessor(MPU) 2
1.4 Microcontroller 3
1.5 Comparison 4
2.1 Introduction 5
          2.4     Flowchart                             9
          2.5     Description                          10
                    Bibliography                                40
                    Appendix-A Source code                     41-46
                 LIST OF FIGURES
3.3.1 Convert AC to DC 17
1. INTRODUCTION
      Personal digital assistants (PDAs) or handheld computers are generally considered embedded devices
     because of the nature of their hardware design, even though they are more expandable in software terms.
     This line of definition continues to blur as devices expand. With the introduction of the OQO Model 2
     with the Windows XP operating system and ports such as a USB port — both features usually belong to
     "general purpose computers", — the line of nomenclature blurs even more.
     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.
      In terms of complexity embedded systems can range from very simple with a single microcontroller
     chip, to very complex with multiple units, peripherals and networks mounted inside a large chassis or
     enclosure.
        •   Avionics, such as inertial guidance systems, flight control hardware/software and other
            integrated systems in aircraft and missiles.
        •   Cellular telephones and telephone switches.
        •   Engine controllers and antilock brake controllers for automobiles.
     Pragati Engineering College                                                                       Page 1
   •   Home automation products, such as thermostats, air conditioners, sprinklers, and security
       monitoring systems.
   •   Handheld calculators.
   •   Handheld computers.
   •   Household appliances, including microwave ovens, washing machines, television sets,
       DVD players and recorders.
   •   Medical equipment.
   •   Personal digital assistant.
   •   Video Game consoles.
   •   Computer peripherals such as routers and printers.
1.2 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. Similarly, an embedded system in an automobile provides a specific
function as a subsystem of the car itself.
     The software written for embedded systems is often called firmware, and is usually stored in read-
only memory or Flash memory chips rather than a disk drive. It often runs with limited computer
hardware resources: small or no keyboard, screen, and little memory.
      The microprocessor must have many additional parts to be operational as a computer whereas a
microcontroller requires no additional external digital parts.
The prime use of microprocessors is to read data, perform extensive calculations on that data and store
them in the mass storage device or display it. The prime function of a microcontroller is to read data,
perform limited calculations on it, control its environment based on these data. Thus the microprocessor
is said to be general-purpose digital computers whereas the microcontroller is intended to be a special
purpose digital controller.
Microprocessors need many opcodes for moving data from the external memory to the CPU,
microcontrollers may require just one or two, also microprocessors may have one or two types of bit
handling instructions whereas microcontrollers have many.
Peripherals:
Embedded Systems talk Serial Communication Interfaces (SCI): RS-232, RS-422,RS-485 etc
   •   Synchronous Serial Communication Interface: I2C, JTAG, SPI, SSC and ESSI
   •   Universal Serial Bus (USB)
   •   Networks: Ethernet, Controller Area Network, LAN networks,etc
   •   Timers: PLL(s), Capture/Compare and Time Processing Units
   •   Discrete IO: aka General Purpose Input/output (GPIO)
   •   Analog to Digital/Digital to Analog (ADC/DAC)
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:
   •   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
       MATLAB, Simulink, MathCAD, or Mathematic 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 optimization 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
                                          CHAPTER-2
                            OVERVIEW OF THE PROJECT
2.1 INTRODUCTION
  The Indian Railways has one of the largest railway networks in the world, criss- crossing over 1,15,000
km in distance, all over India. However, with regard to reliability and passenger safety Indian Railways
is not up to global standards. Among other factors, cracks developed on the rails due to absence of
timely detection and the associated maintenance pose serious questions on the security of operation of
rail transport. A recent study revealed that over 25% of the track length is in need of replacement due to
the development of cracks on it. Manual detection of tracks is cumbersome and not fully effective owing
to much time consumption and requirement of skilled technicians. This project work is aimed towards
addressing the issue by developing an automatic railway track crack detection system.
       Railways are one of the most common used modes of transportation in India. Error free railway
operations are very rare these days due to human negligence and miscommunications which leads to
accidents and delay in advent of the train; the path or the area where roadway and rail lines meet is
known as railway cross. A gate is placed for controlling the movement of the vehicles which requires
human effort and coordination, mistiming in this leads to accidents. Gates are manually operated, errors
which may give rise while closing and opening, the technique suggested here paper introduces a whole
new way of automating the things. These are usually handled by a concerned person and he/she will be
communicated by some way of communication from the station's controlling department. Percentages of
incorrectness are high at Railway crosses are at the peak because of the human errors and also due to the
lack of the knowledge of train timings. If detainment happens in lifting and shutting gates and
irresponsibility may cause big disasters. Current proposed work here tries to develop a mechanism which
does the automation of gate operations (opening and closing) using Arduino, Raspberry Pi, IR sensor
and using Motor for closing and opening of a gate.
Some of the challenges faced by the Railway Department with regard to this is the increase in percentage
of accidents near crossing. Present mechanism consists of human operations which happen based on
communication messages obtained from the Railway station. Mistakes in sending the information/signal
to the gate operator regarding train’s arrival, some delay or problem with respect to the closing and
opening of the gate or regarding anything which might have got between the tracks which in turn cause
the mishap near the crossing. Our system helps in dealing with some issues i.e. Lessens the overall
waiting duration spent by people near crossing and it guarantees protection of the humans near crossing
during the passing of the train when near crossing. As the human involvement is present in operation of
gate which will be reduced which reduces probability
of mishap and colliding of trains coming at the same time from opposite directions near crossing.
Sensors play a major role in automating the process of gate lifting and closing. This paper shows an
automated Smart way of controlling the gates at crossing which provides reliability, security when
compared to the current system.
         This system involves the design of a crack finding robot for finding cracks in railway tracks.
 This system uses a controller for interfacing the robotic vehicle and crack detection sensor. The sensing
 device senses the voltage variations from the crank sensor and then it gives the signal to the
 microcontroller. The microcontroller checks the voltage variations between measured value and
 threshold value and controls the robot according to it. The robotic model is interfaced with the
 microcontroller with the help of a motor driver circuit. If any crack occurs in the rail, the robot will be
 stopped and then a DATA will be sent.
       Objectives of the paper
     ● To detect the cracks present on the railway tracks.
     ● In the proposed system we have suggested using a new rage in the field Computer Science
        and interdisciplinary fields, known as M2M (Machine 2 Machine)/ IoT (Internet of Things)
        where things communicate with each other and based on this the decision is taken. In the
        proposed system, an onboard device is installed in trains enabled with GPRS sensors and is
        able to communicate using the internet of GSM-R standard. This onboard device will
        communicate with the server using MQTT protocol which is the standard for communication
        in the IoT field. With the help of this protocol we can communicate with sensors as well
        as servers and hence making the communication much simpler [6]. Once this message is
        received to the server, the server will first send the location of the next location to the train
        device and once the location of the level crossing arrives it will update the location of the train
        and speed. Based on these the distance between the level crossing and train is determined
        and if the distance is at safety minimum it will ask the track device to update the status.
                                                                  LCD
                                       NODE MCU
            POWER SUPLY                ESP8266
                                                                  RELAY
               IR SENSORS                                         IOT
2.3.2 Hardware components are:-
   ●   Power supply.
   ●   ARDUINO NODE MCU (ESP8266)
   ●   IR SENSORS
   ●   LCD
   ●   BIBO MOTORS.
   ●   RELAY
   ●   BUZZER
   ●   L293D
   ●   MOTORS
   ● ARDUINO IDE
   ● Proteus
   ● Code develops through Embedded C
● IOT technology
2.5 DESCRIPTION:
In our project, there are two sets of IR sensor units fitted to the two sides of the vehicle. This unit is used
to activate/deactivate the IOT transmitter unit when there are any cracks in the track. The IR transmitter
and IR receiver circuit is used to sense the cracks. It is fixed to the front sides of the vehicle with a
suitable arrangement.
When the vehicle is Powered On, it moves along the model track. The IR sensors monitor the condition
of the tracks. In normal condition the motor, Serial transmission is in the initial stage. When the battery
power supply supplies the microcontroller then its starting the motor in forward direction and serial
transmission is used to send the messages to the microcontroller.
When a crack is detected by the IR sensor the vehicle stops at once, and the IOT side receiver
triangulates the position of the vehicle to receive the Latitude and Longitude coordinates of the vehicle
position, from satellites. The Latitude and Longitude coordinates received by GPS are converted into a
text message which is done by microcontroller. The WI-FI module sends the DATA to the predefined
number with the help of ANDROID APP that is interfacing into the IOT.
At Normal Condition:
The IR transmitter sensor is transmitting the infrared rays. These infrared rays are received by the IR
receiver sensor. The Transistors are used as an amplifier section. At normal condition Transistor is OFF.
At that time the relay is OFF, so that the vehicle runs continuously.
At Crack Condition:
At crack detection conditions the IR transmitter and IR receiver, the resistance across the Transmitter
and receiver is high due to the non-conductivity of the IR waves. When the track is continuous without
any cracks then output of IR LED and Photodiode will be high. As soon as the crack detected by the
system the TSOP sensor reflection will be equal to zero and the robot will be stopped automatically.
Another TSOP sensor is used to monitor the pit on the way of the railway track. When this output is high
then it is concluded that there is no pit in the track.
But if any pit is detected by the sensor the output of the sensor given to the microcontroller will be zero
and again the microcontroller will stop the robot. When a crack is detected by the IR sensor the vehicle
stops at once, and the GPS receiver triangulates the position of the vehicle to receive the
Latitude and Longitude coordinates of the vehicle position, from satellites. The Latitude and Longitude
coordinates received by GPS are converted into a text message which is done by microcontroller. The
WI-FI module sends the DATA to the predefined number with the help of ANDROID APP that is
interfacing into the IOT.
Practically, the two IR sensors are placed at the left and right side of the railway gate. The distance
between the two IR sensors is dependent on the length of the train. In general we have to consider the
longest train in that route. Now we’ll see how this circuit actually works in real time. In this image, we
can see the real time representation of this project.
If sensor 1 detects the arrival of the train, the microcontroller starts the motor with the help of the
motor driver in order to close the gate.
The gate remains closed as the train passes the crossing. When the train crosses the gate and
reaches the second sensor, it detects the train and the microcontroller will open the gate.
                                              CHAPTER 3
SYSTEM
DESIGN
                                                                   LCD
                                          NODE
      POWER SUPLY
                                          MCU
                                                                   RELAY
      IR SENSORS                       ESP8266
                                                                   IOT
When the vehicle is Powered On, it moves along the model track. The IR sensors monitor the condition
of the tracks. In normal condition the motor, Serial transmission is in the initial stage. When the battery
power supply supplies the microcontroller then its starting the motor in forward direction and serial
transmission is used to send the messages to the microcontroller.
When a crack is detected by the IR sensor the vehicle stops at once, and the IOT side receiver
triangulates the position of the vehicle to receive the Latitude and Longitude coordinates of the vehicle
position, from satellites. The Latitude and Longitude coordinates received by GPS are converted into a
text message which is done by microcontroller. The WI-FI module sends the DATA to the predefined
number with the help of ANDROID APP that is interfacing into the IOT.
At Normal Condition:
The IR transmitter sensor is transmitting the infrared rays. These infrared rays are received by the IR
receiver sensor. The Transistors are used as an amplifier section. At normal condition Transistor is OFF.
At that time the relay is OFF, so that the vehicle runs continuously.
At Crack Condition:
At crack detection conditions the IR transmitter and IR receiver, the resistance across the Transmitter
and receiver is high due to the non-conductivity of the IR waves. When the track is continuous without
any cracks then output of IR LED and Photodiode will be high. As soon as the crack detected by the
system the TSOP sensor reflection will be equal to zero and the robot will be stopped automatically.
Another TSOP sensor is used to monitor the pit on the way of the railway track. When this output is high
then it is concluded that there is no pit in the track. But if any pit is detected by the sensor the output of
the sensor given to the microcontroller will be zero and again the microcontroller will stop the robot.
When a crack is detected by the IR sensor the vehicle stops at once, and the GPS receiver triangulates
the position of the vehicle to receive the
Latitude and Longitude coordinates of the vehicle position, from satellites. The Latitude and Longitude
coordinates received by GPS are converted into a text message which is done by microcontroller. The
WI-FI module sends the DATA to the predefined number with the help of ANDROID APP that is
interfacing into the IOT.
Servo Buzzer
NodeMCU
IR Sensor 1 IR Sensor 2
 DESCRIPTION:
The working of the project is very simple and is explained here. Practically, the two IR sensors are
placed at the left and right side of the railway gate. The distance between the two IR sensors is
dependent on the length of the train. In general we have to consider the longest train in that route. Now
we’ll see how this circuit actually works in real time. In this image, we can see the real time
representation of this project.
      If sensor 1 detects the arrival of the train, microcontroller starts the motor with the help of motor
      driver in order to close the gate.
The gate remains closed as the train passes the crossing. When the train crosses the gate and reaches the
second sensor, it detects the train and the microcontroller will open the gate.
  3.3SYSTEM
  REQUIREMENTS Hardware
  Requirements:
  Hardware components are
             ●   Power supply.
             ●   ARDUINO NODE MCU (ESP8266)
             ●   IR SENSORS
             ●   LCD
             ●   SERVO MOTORS.
             ●   RELAY
             ●   BUZZER
             ●   L293D
             ●   MOTORS
  Convert AC to DC:-
          230V AC power is converted into 12V AC (12V RMS value where in the peak value is around
  17V), but the required power is 5V DC; for this purpose, 17V AC power must be primarily converted
  into DC power then it can be stepped down to the 5V DC. But first and foremost, We must know how to
  convert AC to DC? AC power can be converted into DC using one of the power electronic converters
  called a Rectifier. There are different types of rectifiers, such as half-wave rectifier, full-wave rectifier,
full-wave rectifier and Bridge rectifier. Due to the advantages of the bridge rectifier over the half and
full wave rectifier, the bridge rectifier is frequently used for converting AC to DC
Fig3.3.1 Convert AC to DC
         Bridge rectifiers consist of four diodes which are connected in the form of a bridge .We know
that the diode is an uncontrolled rectifier which will conduct only forward bias and will not conduct
during the reverse bias. If the diode anode voltage is greater than the cathode voltage then the diode is
said to be in forward bias. During positive half cycle, diodes D2 and D4 will conduct and during
negative half cycle diodes D1 and D3 will conduct. Thus, AC is converted into DC ; here they obtained
is not a pure DC as it consists of pulses .Hence ,it is called as pulsating DC power. But voltage drop
across the diodes is (2*0.7V) 1.4V; Therefore, the peak voltage at the voltage at the output of this
rectifier circuit is 15V (17-1.4) approx.
In this article, We will try to present useful details related to this WiFi Development Kit, its main
features, pin out and everything we need to know about this module and the application domain.
Introduction toNodeMCU V3
NodeMCU V3 is an open-source firmware and development kit that plays a vital role in designing an
IoT product using a few script lines.
Multiple GPIO pins on the board allow us to connect the board with other peripherals and are capable of
generating PWM, I2C, SPI, and UART serial communications.
   The interface of the module is mainly divided into two parts including both Firmware and Hardware
where former runs on the ESP8266 Wi-Fi SoC and later is based on the ESP-12 module. The firmware is
based on Lua – A scripting language that is easy to learn, giving a simple programming environment
layered with a fast scripting language that connects you with a well-known developer community.
And open source firmware gives you the flexibility to edit, modify and rebuilt the existing module and
keep changing the entire interface until you succeed in optimizing the module as per your requirements.
   ● USB to UART converter is added on the module that helps in converting USB data to UART
     data which mainly understands the language of serial communication. Instead of the regular USB
     port, MicroUSB port is included in the module that connects it with the computer for dual
     purposes: programming and powering up the board.
   ● The board incorporates a status LED that blinks and turns off immediately, giving you the current
     status of the module if it is running properly when connected with the computer. The ability of
       the module to establish a flawless WiFi connection between two channels makes it an ideal
       choice for incorporating it with other embedded devices like Raspberry Pi.
NodeMCU V3 Pinout
NodeMCU V3 comes with a number of GPIO Pins. Following figure shows the Pinout of the board.
There is a candid difference between Vin and VU where former is the regulated voltage that may stand
somewhere between 7 to 12 V while later is the power voltage for USB that must be kept around 5 V.
Features
1. Open-source
2. Arduino-like hardware
3. Status LED 4. MicroUSB port
5. Reset/Flash buttons
6. Interactive and Programmable
7. Low cost
8. ESP8266 with inbuilt wifi
15. Event-driven API for network applications, which facilitates developers writing code running on a
5mm*5mm sized MCU in Nodejs style.
16. Greatly speed up your IOT application developing process.
19. We provide the best platform for IOT application development at the lowest cost.
 As mentioned above, a cable supporting a micro USB port is used to connect the board. As you connect
the board with a computer, the LED will flash. You may need some drivers to be installed on your
computer if it fails to detect the NodeMCU board. You can download the driver from this page.
 Note: We use Arduino IDE software for programming this module. It is important to note that the pin
configuration appearing on the board is different from the configuration we use to program the board on
the software i.e. when we write code for targeting pin 16 on the Arduino IDE, it will actually help is
laying out the communication with the D0 pin on the module. Following figure shows the pin
configuration to use in Arduino IDE.
      Technically known as "infrared radiation", infrared light is part of the electromagnetic spectrum located just
below the red portion of normal visible light – the opposite end to ultraviolet. Although invisible, infrared follows the
same principles as regular light and can be reflected or pass through transparent objects, such as glass. Infrared remote
controls use this invisible light as a form of communications between themselves and home theater equipment, all of
which have infrared receivers positioned on the front. Essentially, each time you press a button on a remote, a small
infrared diode at the front of the remote beams out pulses of light at high speed to all of your equipment. When the
equipment recognizes the signal as its own, it responds to the command.
     But much like a flashlight, infrared light can be focused or diffused, weak or strong. The type and
number of emitters can affect the possible angles and range your remote control can be used from. Better
remotes can be used up to thirty feet away and from almost any angle, while poorer remotes must be
aimed carefully at the device being controlled.
      The light our eyes see is but a small part of a broad spectrum of electromagnetic radiation. On the
immediate high energy side of the visible spectrum lies the ultraviolet, and on the low energy side is the
infrared. The portion of the infrared region most useful for analysis of organic compounds is not
immediately adjacent to the visible spectrum, but is that having a wavelength range from 2,500 to 16,000
nm, with a corresponding frequency range from 1.9*10 13 to 1.2*1014 Hz.( From http://hyperphysics.phy-
astr.gsu.edu/hbase/ems3.html : the frequency of infrared ranges from 0.003 - 4 x 10 14 Hz or about 300
gigahertz to 400 terahertz.).
 Infrared imaging is used extensively for both military and civilian purposes. Military applications
include target acquisition, surveillance, night vision, homing and tracking. Non-military uses include
thermal efficiency analysis, remote temperature sensing, short-ranged wireless communication,
spectroscopy, and weather forecasting. Infrared astronomy uses sensor-equipped telescopes to penetrate
dusty regions of space, such as molecular clouds; detect cool objects such as planets, and to view highly
red-shifted objects from the early days of the universe
FEATURES:
3.3.4 LCD:-
      LCD (liquid crystal display) is the technology used for displays in notebook and other smaller
computers. Like light-emitting diode (LED) and gas-plasma technologies, LCDs allow displays to be
much thinner than cathode ray tube (CRT) technology. LCDs consume much less power than LED and
gas-display displays because they work on the principle of blocking light rather than emitting it.
Servo motors control position and speed very precisely. Now a potentiometer can sense the mechanical
position of the shaft. Hence it couples with the motor shaft through gears. The current position of the
shaft is converted into electrical signal by potentiometer, and is compared with the command input
signal. In modern servo motors, electronic encoders or sensors sense the position of the shaft .We give
command input according to the position of the shaft. If the feedback signal differs from the given input,
an error signal alerts the user. We amplify this error signal and apply it as the input to the motor, hence
the motor rotates. And when the shaft reaches the required position, error signals become zero, and
hence the motor stays standstill holding the position.
● Has 5-10 times more rated torque for short periods.IOT Based Trash Management In
3.3.6 RELAY
Introduction:
      A relay is an electrical switch that opens and closes under the control of another electrical circuit.
In the original form, the switch is operated by an electromagnet to open or close one or many sets of
contacts. A relay is able to control an output circuit of higher power than the input circuit, it can be
considered to be, in a broad sense, a form of an electrical amplifier.
       Relays are usually SPDT (single pole double through switch)or DPDT (double pole double
through switch) but they can have many more sets of switch contacts, for example relays with 4 sets of
changeover contacts are readily available.
3.3.6.1 Basic operation of a relay:
An electric current through a conductor will produce a magnetic field at right angles to the direction of
electron flow. If that conductor is wrapped into a coil shape, the magnetic field produced will be oriented
along the length of the coil. The greater the current, the greater the strength of the magnetic field, all
other factors being equal.
                 Inductors react against changes in current because of the energy stored in this magnetic field.
         When we construct a transformer from two inductor coils around a common iron core, we use this field
         to transfer energy from one coil to the other. However, there are simpler and more direct uses for
         electromagnetic fields than the applications we've seen with inductors and transformers. The magnetic
         field produced by a coil of current-carrying wire can be used to exert a mechanical force on any
         magnetic object, just as we can use a permanent magnet to attract magnetic objects, except that this
         magnet (formed by the coil) can be turned on or off by switching the current on or off through the coil.
                 If we place a magnetic object near such a coil for the purpose of making that object move when
         we energize the coil with electric current, we have what is called a solenoid. The movable magnetic
         object is called an armature, and most armatures can be moved with either direct current (DC) or
         alternating current (AC) energizing the coil. The polarity of the magnetic field is irrelevant for the
         purpose of attracting an iron armature. Solenoids can be used to electrically open door latches, open or
         shut valves, move robotic limbs, and even actuate electric switch mechanisms and are used to actuate a
         set of switch contacts.
Neutral Relays:
                 This is the most elementary type of relay. The neutral relays have a magnetic coil, which operates
         the relay at a specified current, regardless of the polarity of the voltage applied.
Biased Relays:
                Biased relays have a permanent magnet above the armature. The relay operates if the current
         through the coil winding establishes a magneto-motive force that opposes the flux by the permanent
         magnet. If the fluxes are in the same direction, the relay will not operate, even for a greater current
         through the coil.
Polarized Relays:
                 Like the biased relays, the polarized relays operate only when the current through the coil in one
         direction. But there the principle is different. The relay coil has a diode connected in series with it. This
         blocks the current in the reverse direction.
                 The major difference between biased relays and polarized relays is that the former allows the
         current to pass through in the reverse direction, but does not operate the relay and the later blocks the
         current in reverse direction. You can imagine how critical these properties when relays are connected in
         series to form logic circuits.
                These relays have a magnetic circuit with high permanence. Two coils, one to operate (pick up)
         and one to release (drop) are present. The relay is activated by a current in the operating coil. On the
         interruption of the current the armature remains in picked up position by the residual magnetism. The
         relay is released by a current through the release coil.
                 These relays have a capacitor connected in parallel to their coil. When the operating current is
         interrupted the release of relay is delayed by the stored charge in the capacitor. The relay releases as the
         capacitor discharges through the coil.
                 These are neutral relays and picked up for a.c. current through their coil. These are very fast in
         action and used on power circuits of the point motors, where high current flows through the contacts. A
         normal relay would be slow and make sparks which in turn may weld the contacts together.
                All relays have two operating values (voltages), one pick-up and the other drop away. The pick-
         up value is higher than the drop away value.
Applications:
            ● To control a high-voltage circuit with a low-voltage signal, as in some types of modems or audio
              amplifiers,
            ● To control a high-current circuit with a low-current signal, as in the starter solenoid of an
              automobile,
            ● To detect and isolate faults on transmission and distribution lines by opening and closing circuit
              breakers (protection relays),
            ● To isolate the controlling circuit from the controlled circuit when the two are at different
              potentials, for example when controlling a mains-powered device from a low-voltage switch. The
              latter is often applied to control office lighting as the low voltage wires are easily installed in
              partitions, which may be often moved as needs change. They may also be controlled by room
              occupancy detectors in an effort to conserve energy,
            ● To perform logic functions. For example, the Boolean AND function is realised by connecting
              NO relay contacts in series, the OR function by connecting NO contacts in parallel. The change-
              over or Form C contacts perform the XOR (exclusive or) function. Similar functions for NAND
              and NOR are accomplished using NC contacts. The Ladder programming language is often used
              for designing relay logic networks.
            ● Early computing. Before vacuum tubes and transistors, relays were used as logical elements in
              digital computers. See ARRA (computer), Harvard Mark II, Zuse Z2, and Zuse Z3.
            ● Safety-critical logic. Because relays are much more resistant than semiconductors to nuclear
              radiation, they are widely used in safety-critical logic, such as the control panels of radioactive
              waste-handling machinery.
            ● To perform time delay functions. Relays can be modified to delay opening or delay closing a set
              of contacts. A very short (a fraction of a second) delay would use a copper disk between the
              armature and moving blade assembly. Current flowing in the disk maintains the magnetic field
        for a short time, lengthening release time. For a slightly longer (up to a minute) delay, a dashpot
        is used. A dashpot is a piston filled with fluid that is allowed to escape slowly. The time period
        can be varied by increasing or decreasing the flow rate. For longer time periods, a mechanical
        clockwork timer is installed
3.3.7 BUZZER
A buzzer is a small yet efficient component to add sound features to our project/system. It is a very
small and compact 2-pin structure hence can be easily used on breadboard, Perf Board and even on
PCBs which maes this a widely used component in most electronic applications.
There are two types of buzzers that are commonly available. The one shown here is a simple buzzer
which when powered will make a Continuous Beeeeeep sound, the other type is called a readymade
buzzer which will look bulkier than this and will produce a Beep. Beep. Beep. Sound due to the internal
oscillating circuit present inside it. But, the one shown here is most widely used because it can be
customized with help of other circuits to fit easily in our application.
This buzzer can be used by simply powering it using a DC power supply ranging from 4V to 9V. A
simple 9V battery can also be used, but it is recommended to use a regulated +5V or +6V DC supply.
The buzzer is normally associated with a switching circuit to turn ON or turn OFF the buzzer at required
time and require interval.
FEATURES
● Rated Voltage: 6V DC.
● Operating Voltage: 4-8V DC.
Pin diagram:
Applications:
   ●    Audio
   ●    Automotive
   ●    Broadband
   ●    Digital control
   ●    Military
   ●    Optical networking
   ●    Security
   ●    Telephony
   ●    Video & Imaging
   ●    Wire less
3.3.9 DC MOTOR
Introduction:
A DC motor is designed to run on DC electric power. Two examples of pure DC designs are Michael
Faraday's homopolar motor (which is uncommon), and the ball bearing motor, which is (so far) a
novelty. By far the most common DC motor types are the brushed and brushless types, which use
internal and external commutation respectively to create an oscillating AC current from the DC source
so they are not purely DC machines in a strict sense.
   ● Brushed DC Motors
   ● Brushless DC motors
   ● Coreless DC motors
Brushed DC motors:
    The classic DC motor design generates an oscillating current in a wound rotor with a split ring
commutator, and either a wound or permanent magnet stator. A rotor consists of a coil wound around a
rotor which is then powered by any type of battery.
Many of the limitations of the classic commutator DC motor are due to the need for brushes to press
against the commutator. This creates friction. At higher speeds, brushes have increasing difficulty in
maintaining contact. Brushes may bounce off the irregularities in the commutator surface, creating
sparks. This limits the maximum speed of the machine. The current density per unit area of the brushes
limits the output of the motor. The imperfect electric contact also causes electrical noise. Brushes
eventually wear out and require replacement, and the commutator itself is subject to wear and
maintenance. The commutator assembly on a large machine is a costly element, requiring precision
assembly of many parts. There are three types of dc motor 1. dc series motor 2. dc shunt motor 3. dc
compound motor these are also two types of. cumulative compound b. differential compound
Brushless DC motors:
Some of the problems of the brushed DC motor are eliminated in the brushless design. In this motor, the
mechanical "rotating switch" or commutator/brush gear assembly is replaced by an external electronic
switch synchronized to the rotor's position. Brushless motors are typically 85-90% efficient, whereas DC
motors with brush gear are typically 75-80% efficient.
Midway between ordinary DC motors and stepper motors lies the realm of the brushless DC motor. Built
in a fashion very similar to stepper motors, these often use a permanent magnet external rotor, three
phases of driving coils, one or more Hall effect sensors to sense the position of the rotor, and the
associated drive electronics. The coils are activated, one phase after the other, by the drive electronics as
cued by the signals from the Hall effect sensors. In effect, they act as three-phase synchronous motors
containing their own variable-frequency drive electronics. A specialized class of brushless DC motor
controllers utilize EMF feedback through the main phase connections instead of Hall effect sensors to
determine position and velocity. These motors are used extensively in electric radio-controlled vehicles.
When configured with the magnets on the outside, these are referred to by mode lists as out runner
motors.
Brushless DC motors are commonly used where precise speed control is necessary, as in computer disk
drives or in video cassette recorders, the spindles within CD, CD-ROM (etc.) drives, and mechanisms
within office products such as fans, laser printers and photocopiers. They have several advantages over
conventional motors: Compared to AC fans using shaded-pole motors, they are very efficient, running
much cooler than the equivalent AC motors. This cool operation leads to a much-improved life of the
fan's bearings.
Without a commutator to wear out, the life of a DC brushless motor can be significantly longer
compared to a DC motor using brushes and a commutator. Commutation also tends to cause a great deal
of electrical and RF noise; without a commutator or brushes, a brushless motor may be used in
electrically sensitive devices like audio equipment or computers.
The same Hall effect sensors that provide the commutation can also provide a convenient tachometer
signal for closed-loop control (servo-controlled) applications. In fans, the tachometer signal can be used
to derive a "fan OK" signal.
The motor can be easily synchronized to an internal or external clock, leading to precise speed control.
Brushless motors have no chance of sparking, unlike brushed motors, making them better suited to
environments with volatile chemicals and fuels. Also, sparking generates ozone which can accumulate in
poorly ventilated buildings risking harm to occupants' health.
Brushless motors are usually used in small equipment such as computers and are generally used to get
rid of unwanted heat.
They are also very quiet motors which is an advantage if being used in equipment that is affected by
vibrations.
Modern DC brushless motors range in power from a fraction of a watt to many kilowatts. Larger
brushless motors up to about 100 kW rating are used in electric vehicles. They also find significant use
in high-performance electric model aircraft.
Coreless DC motors:
Nothing in the design of any of the motors described above requires that the iron (steel) portions of the
rotor actually rotate; torque is exerted only on the windings of the electromagnets. Taking advantage of
this fact is the coreless DC motor, a specialized form of a brush or brushless DC motor. Optimized for
rapid acceleration, these motors have a rotor that is constructed without any iron core. The rotor can take
the form of a winding-filled cylinder inside the stator magnets, a basket surrounding the stator magnets,
or a flat pancake (possibly formed on a printed wiring board) running between upper and lower stator
magnets. The windings are typically stabilized by being impregnated with Electrical epoxy potting
systems. Filled epoxies that have moderate mixed viscosity and a long gel time. These systems are
highlighted by low shrinkage and low exothermic. Typically UL 1446 is recognized as a potting
compound for use up to 180C (Class H) UL File No. E 210549.
Because the rotor is much lighter in weight (mass) than a conventional rotor formed from copper
windings on steel laminations, the rotor can accelerate much more rapidly, often achieving a mechanical
time constant under 1 ms.This is especially true if the windings use aluminum rather than the heavier
copper. But because there is no metal mass in the rotor to act as a heat sink, even small coreless motors
must often be cooled by forced air.
These motors were commonly used to drive the capstan(s) of magnetic tape drives and are still widely
used in high-performance servo-controlled systems, like radio-controlled vehicles/aircraft, humanoid
robotic systems, industrial automation, medical devices, etc.
Software:ArduinoIDE
Language:C
CloudStorage:Firebase
InourprojectwehaveusedClanguageforourcode,ArduinoIDEsoftwarefortheimplementationofoursoftwa
re,andFirebasecloudforstoragepurposes.WiththehelpofAppInventorwecreatedanappforourproject.
MITAppInventor
AppInventorisanonlineplatformdesignedtoteachcomputationalthinkingconceptsthroughdevelopmentof
mobileapplications.Studentscreateapplicationsbydragginganddroppingcomponentsintoadesignviewand
usingavisualblockslanguagetoprogramapplicationbehavior.Thesmartphoneisaninformationnexusintoda
y’sdigitalage,withaccesstoanearlyinfinitesupplyofcontentontheweb,coupledwithrichsensorsandperson
aldata.However,peoplehavedifficultyharnessingthefullpowerof
theseubiquitousdevicesforthemselvesandtheircommunities.Mostsmartphoneusersconsumetechnology
withoutbeingabletoproduceit,eventhoughlocalproblemscanoftenbesolvedwithmobiledevices.Howthen
mighttheylearntoleveragesmartphonecapabilitiestosolvereal- world,everydayproblems?
MITAppInventorisdesignedtodemocratizethistechnologyandisusedasatoolfo
rlearningcomputationalthinkinginavarietyofeducationalcontexts,teachingpeopletobuildappstosolvepro
blemsintheircommunities.AppInventorisanonlinedevelopmentplatformthatanyonecanleveragetosolver
eal-worldproblems.Itprovidesaweb-
based“Whatyouseeiswhatyouget”(WYSIWYG)editorforbuildingmobilephoneapplicationstargetingthe
AndroidandIOSoperatingsystems.Weforeseethedevelopmentofextensionsrelatedtoartificialintelligence
technologies,includingdeeplearning,devicesupportforimagerecognition,sentimentanalysis,naturallangu
ageprocessing,andmore.Ideally,thesecomplextechnologiescouldbeleveragedbyanyonelookingtosolvea
problemwiththesmartphoneasaplatform.TheAppInventorprojectcontinuestopushtheboundariesofeduca
tionwithinthecontextofmobileappdevelopment.Itsabstractionofhardware
capabilitiesandthereductionofcomplexlogicintocompactrepresentationsallowuserstoquicklyanditerativ
elydevelopprojectsthataddressreal-
worldproblems.Thesetechnologiesoffernewwaysofengagingwiththeworldandcoulddramaticallyaffectth
efutureoftechnologyandsociety.Tosupporteducatingyouthinthisfamilyoftechnologies,weareactivelydev
elopingartificialintelligenceandmachinelearningcomponents.
        ● Arduino IDE
    The Arduino Integrated Development Environment (IDE) is a cross-platform application (for
    Windows, macOS, Linux) 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 3rd party cores, other
    vendor development boards.
    ThesourcecodefortheIDEisreleasedundertheGNUGeneralPublicLicense.TheArduinoIDE supports
    the languages C and C++ using special rules of code structuring. The Arduino IDE supplies a
    software library from the writing project, which provides many common input and
    outputprocedures.User-writtencodeonlyrequirestwobasicfunctions,forstartingthesketchand
    themainprogramloop,thatarecompiledandlinkedwithaprogramstubmain()intoanexecutable
    cyclicexecutiveprogramprogramwiththeGNUtoolchain,alsoincludedwiththeIDEdistribution. The
    Arduino IDE employs the program avrdudeto 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. By default, avrdudeis used as the uploading tool to flash the user code onto official
    Arduinoboards.
                                    Fig 3.4.1ArduinoIDESoftware
3.13 Firebase
CloudStorageisbuiltforappdeveloperswhoneedtostoreandserveuser-
generatedcontent,suchasphotosorvideos.CloudStorageforFirebaseisapowerful,simple,andcost-
effectiveobjectstorageservicebuiltforGooglescale.TheFirebaseSDKsforCloudStorageaddGooglesecurit
ytofileuploadsanddownloadsforyourFirebaseapps,regardlessofnetworkquality.YoucanuseourSDKstosto
reimages,audio,video,orotheruser-
generatedcontent.DevelopersusetheFirebaseSDKsforCloudStoragetouploadanddownloadfilesdirectlyo
mclients.Ifthenetworkconnectionispoor,theclientisabletoretrytheoperationrightwhereitleftoff,savingyou
rusertimeandbandwidth.CloudStoragestoresyourfilesinaGoogleCloudStoragebucket,makingthemaccess
iblethroughbothFirebaseandGoogleCloud.Thisallowsyoutheflexibilitytouploadanddownloadfilesfromm
obileclientsviatheFirebaseSDKs,anddoserver-
sideprocessingsuchasimagefilteringorvideotranscodingusingGoogleCloudPlatform.CloudStoragescales
automatically,meaningthatthere'snoneedtomigratetoanyotherprovider.Learnmoreaboutallthebenefitsofo
urintegrationwithGoogleCloudPlatform.TheFirebaseSDKsforCloudStorageintegrateseamlesslywithFir
ebaseAuthenticationtoidentifyusers,andweprovideadeclarative.securitylanguagethatletsyousetaccessco
ntrolsonindividualfilesorgroupsoffiles,soyoucanmakefilesaspublicorprivateasyouwant.
                                CHAPTER 4
                          RESULTS AND DISCUSSIONS
4.1 INPUT
       In this paper we have designed a cost effective, low-power embedded system, which
facilitate better safety standards for rail tracks for preventing railway accidents due to cracks and
obstacles on railway tracks. The Prototype of testing vehicle can efficiently detect cracks and
obstacles on railway tracks. The result shows that this new innovative technology will increase
the reliability of safety systems in railway transport. By implementing these features in real time
application, we can avoid accidents up to approximately 70%.
Automation of the railway gate control system is implemented in order to reduce interaction of
lifting and shutting the crossing gate which allows and avoids vehicles and people from passing
the crossing. Rail crossing has been the root cause for of mishap and many fatal issues.
Automation of the crossing gates makes easy and secure to control the gates. Humans may make
incorrect or mishaps which may be very dangerous, automation of whole thing will shorten
possibilities of the mishaps and incorrectness. Automation of the lifting and shutting of the
railway crossing gate with the usage of Arduino using sensor and using motors will help in
controlling the gates. This can be implemented in the remote area where it is difficult for humans
to work in like in the places of extreme weather. As everything in this world has a limitation our
put forth system poses some limitations which usage of Infra-Red sensors are. Irrespective of
train or any other object in its coverage area it will detect as an object is detected which is
inaccurate. Second limitation happens to be while lifting and shutting of crossing gate but this
fails in avoiding the movements of the vehicles trespassing. We only control crossing gate here.
In order to resolve this issue, we take help of pressure that acts as an add on to the put forth
work. Along with Infra-Red sensors it would be good to use load sensors. Here the load sensor
usage is limited as it is not economically feasible for small area but when implemented in a
larger extent this will provide a huge impact. Future implementation can be made by resolving
the current issues using the above said suggestions and incorporating them in the system.
5.2 Future Scope:
               Although work can be done in order to provide a better speed to the automated
vehicle robot. Also enhancement can be done to get better accuracy about the location of the
place where the fault had occurred. Also the robot can be made large so that by using its weight
track shiftiness i.e. stress and strain parameters of the track can be determined so as to make this
system more effective. A zigbee module can also be incorporated for low cost short distance
scrutinizing mechanism in order to provide good connectivity at a low input cost
                                     BIBLIOGRAPHY
[2] Prof Rijoy Paul , Nima Varghese, UnniMenon , Shyam Krishna K, “Railway Track Crack
Detection”, International Journal of Advance Research and Development Vol. 3, Issue 3.
[3] Prof Elanangai, “Implementation Of Railway Crack Detection And Monitoring System”,
International Journal of Scientific & Engineering Research Volume 9, Issue 11, November-
2018.
[4] Prof    C.   R.   Balamurugan,    P.Vijayshankarganth,    R.Alagarraja,    V.E.Subramanian,
R.Ragupathy “Automatic Railway Gate Control System Using 8051 micro Controller”,
International Journal of ChemTech Research ISSN: 0974-4290, Volume-11, Issue-04.
[5] Prof HninNgwe Yee Pwint, ZawMyoTun, HlaMyoTun, “Automatic Railway Gate Control
System Using Microcontroller”, International Journal of Science, Engineering and Technology
Research (IJSETR), Volume 3, Issue 5, May 2014.
[6] Prof Acy M. Kottali, Abhijith S , Ajmal M M , Abhilash L J, AjithBabu. ,“Automatic
Railway Gate Control System'', International Journal of Advanced Research in Electrical,
Electronics and Instrumentation Engineering, Vol. 3, Issue 2, February 2014.
                                       APPENDIX-A
#include<ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include<Servo.h>
#include<SoftwareSerial.h>
#define FIREBASE_HOST "traincrack.firebaseio.com"
#define FIREBASE_AUTH "MxWb32egX7pcZ12ppKbIQKqcBTnodjiAq0zoa4i8"
#define WIFI_SSID "crackiot"
#define WIFI_PASSWORD "crackiot01"
Servo myservo1;
int relay=D6;
intbuz=D4;
intZ,W,wet_v,dry_v;
void setup()
{
Serial.begin(9600);
Serial.println("welcome");
myservo1.attach(D5);
pinMode(ir1_b,INPUT);
pinMode(relay,OUTPUT);
pinMode(ir2_b,INPUT);
pinMode(buz,OUTPUT);
digitalWrite(relay,HIGH);
digitalWrite(buz,LOW);
myservo1.write(90);
WiFi.begin(WIFI_SSID,WIFI_PASSWORD);
Serial.print("Connecting");
while(WiFi.status() != WL_CONNECTED)
   {
Serial.print(".");
delay(500);
     }
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
void loop()
{
//Serial.print("IR1_G:");
//Serial.println(digitalRead(ir1_g));
//Serial.print("IR2_G:");
//Serial.println(digitalRead(ir2_g));
//Serial.print("IR1_b:");
//Serial.println(digitalRead(ir1_b));
//Serial.print("IR2_b:");
//Serial.println(digitalRead(ir2_b));
//Serial.println();
//Serial.println();
//delay(1000);
if(digitalRead(ir1_b) || digitalRead(ir2_b) )
 {
Firebase.setFloat ("TRAINCRACK/YES",Z);
Z++;
digitalWrite(buz,HIGH);
Serial.print(" CRACK DETECTED");
digitalWrite(relay,LOW);
while(digitalRead(ir1_b) || digitalRead(ir2_b) )
{
delay(50);
Serial.println(" STUCK IN CRACK DETECTED");
}
digitalWrite(buz,LOW);
Firebase.setFloat ("TRAINCRACK/NO",Z);
Z++;
digitalWrite(relay,HIGH);
 }
// myservo2.write(0);
//
//if(!digitalRead(ir_dry))
// myservo2.write(90);
//
//if(digitalRead(ir_wet))
// myservo1.write(0);
//
//if(!digitalRead(ir_wet))
// myservo1.write(90);
////SonarSensor_wet(trigPin1,echoPin1);
////SonarSensor_wet(trigPin1,echoPin1);
////
////SonarSensor_d(trigPin0,echoPin0);
////SonarSensor_d(trigPin0,echoPin0);
////
////SonarSensor_dry(trigPin2,echoPin2);
////SonarSensor_dry(trigPin2,echoPin2);
//
//Serial.print("WET_DUST_BIN:");
//Serial.println(SonarSensor_wet(trigPin1,echoPin1)); ///////// WET DUST BIN
//
////Serial.print("DRY_DUST_BIN:");
////Serial.println(SonarSensor_dry(trigPin2,echoPin2)); ///////// DRY DUST BIN
//Serial.print("DRY_DUST_BIN:");
//Serial.println(SonarSensor_d(trigPin0,echoPin0)); ///////// distance
//
//Serial.print("wet_sensor:");
//Serial.println(analogRead(sen_wet)); ///////// SENSOR MOISTURE
//
////Serial.println();
////Serial.println();
////Serial.println();
//
//////////////****** DRY DUST BIN **********////////////
//
//if( (SonarSensor_d(trigPin0,echoPin0)<8)&& (dry_v==0) )
//{
////digitalWrite(buz,HIGH);
//Serial.print("A");
// Firebase.setFloat ("NDUSTBINIOT/A",Z);
//Z++;
//dry_v=1;
//}
//if((SonarSensor_d(trigPin0,echoPin0)<15)&&(SonarSensor_d(trigPin0,echoPin0)>8))
//{
//dry_v=0;
//digitalWrite(buz,LOW);
//Serial.print("B");
//     Firebase.setFloat ("NDUSTBINIOT/B",Z);
//Z++;
//}
//if((SonarSensor_d(trigPin0,echoPin0)<25)&&(SonarSensor_d(trigPin0,echoPin0)>15))
//{
// dry_v=0;
//digitalWrite(buz,LOW);
//Serial.print("C");
// Firebase.setFloat ("NDUSTBINIOT/C",Z);
//Z++;
//}
//if((SonarSensor_d(trigPin0,echoPin0)<35)&&(SonarSensor_d(trigPin0,echoPin0)>25))
//{
// dry_v=0;
//digitalWrite(buz,LOW);
//Serial.print("D");
// Firebase.setFloat ("dustbin/D",Z);
//Z++;
//}
//if((SonarSensor_d(trigPin0,echoPin0)<40)&&(SonarSensor_d(trigPin0,echoPin0)>35))
//{
// dry_v=0;
//digitalWrite(buz,LOW);
//Serial.print("E");
// Firebase.setFloat ("NDUSTBINIOT/E",Z);
//Z++;
//}
//if((SonarSensor_d(trigPin0,echoPin0)<45)&&(SonarSensor_d(trigPin0,echoPin0)>40))
//{
// dry_v=0;
//digitalWrite(buz,LOW);
//Serial.print("F");
// Firebase.setFloat ("NDUSTBINIOT/F",Z);
//Z++;
//}
//if((SonarSensor_d(trigPin0,echoPin0)>45))
//{
// dry_v=0;
//digitalWrite(buz,LOW);
//Serial.print("G");
// Firebase.setFloat ("NDUSTBINIOT/G",Z);
//Z++;
//}
//
//
/////////////////////// *************WET DUSTBIN ********/////////////////////
//if( (SonarSensor_wet(trigPin1,echoPin1)<8)&& (wet_v==0 ) )
//{
////digitalWrite(buz,HIGH);
//Serial.print("A");
// Firebase.setFloat ("NDUSTBINIOT/A1",W);
//W++;
//wet_v++;
//}
//if((SonarSensor_wet(trigPin1,echoPin1)<15)&&(SonarSensor_wet(trigPin1,echoPin1)>8))
//{
// wet_v=0;
//digitalWrite(buz,LOW);
//Serial.print("B");
//     Firebase.setFloat ("NDUSTBINIOT/B1",W);
//W++;
//}
//if((SonarSensor_wet(trigPin1,echoPin1)<25)&&(SonarSensor_wet(trigPin1,echoPin1)>15))
//{
//    wet_v=0;
//digitalWrite(buz,LOW);
//Serial.print("C");
// Firebase.setFloat ("NDUSTBINIOT/C1",W);
//W++;
//}
//if((SonarSensor_wet(trigPin1,echoPin1)<35)&&(SonarSensor_wet(trigPin1,echoPin1)>25))
//{
//    wet_v=0;
//digitalWrite(buz,LOW);
//Serial.print("D");
// Firebase.setFloat ("NDUSTBINIOT/D1",W);
//W++;
//}
//if((SonarSensor_wet(trigPin1,echoPin1)<40)&&(SonarSensor_wet(trigPin1,echoPin1)>35))
//{
//    wet_v=0;
//digitalWrite(buz,LOW);
//Serial.print("E");
// Firebase.setFloat ("NDUSTBINIOT/E1",W);
//W++;
//}
//if((SonarSensor_wet(trigPin1,echoPin1)<45)&&(SonarSensor_wet(trigPin1,echoPin1)>40))
//{
//    wet_v=0;
//digitalWrite(buz,LOW);
//Serial.print("F");
// Firebase.setFloat ("NDUSTBINIOT/F1",W);
//W++;
//}
//if((SonarSensor_wet(trigPin1,echoPin1)>45))
//{
//    wet_v=0;
//digitalWrite(buz,LOW);
//Serial.print("G");
// Firebase.setFloat ("NDUSTBINIOT/G1",W);
//W++;
//}
//
//if(analogRead(sen_wet)<1000)
//{
//digitalWrite(buz,HIGH);
//delay(500);
//digitalWrite(buz,LOW);
//delay(500);
//}
//
//}
//
//intSonarSensor_d(inttrigPin,intechoPin)
//{
//digitalWrite(trigPin, LOW);
//delayMicroseconds(2);
//digitalWrite(trigPin, HIGH);
//delayMicroseconds(10);
//digitalWrite(trigPin, LOW);
//duration = pulseIn(echoPin, HIGH);
//distance = (duration/2) / 29.1;
//return distance;
//}
//
//intSonarSensor_wet(inttrigPin,intechoPin)
//{
//
//digitalWrite(trigPin, LOW);
//delayMicroseconds(2);
//digitalWrite(trigPin, HIGH);
//delayMicroseconds(10);
//digitalWrite(trigPin, LOW);
//duration = pulseIn(echoPin, HIGH);
//distance = (duration/2) / 29.1;
//return distance;
//}