WATER LEVEL TRACKING SYSTEM BY USING ONLINE

A THESIS SUBMITTED TO THE GRADUTE SCHOOL OF APPLIED SCIENCES OF NEAR EAST UNIVERSITY

By ÇAĞRI ÖZKAN

In Partial Fulfillment of the Reguirements for The Degree of Master of Science in Information Systems Engineering

NICOSIA, 2017 WATER LEVEL TRACKING SYSTEM BY USING ONLINE ARDUINO

A THESIS SUBMITTED TO THE GRADUTE SCHOOL OF APPLIED SCIENCES OF NEAR EAST UNIVERSITY

By

ÇAĞRI ÖZKAN

In Partial Fulfillment of the Reguirements for The Degree of Master of Science in Information Systems Engineering

NICOSIA, 2017

I hereby declare that all information in this document has been obtained and presented in accordance with academic rules and ethical conduct. I also declare that, as required by these rules and conduct, I have fully cited and referenced all material and results that are not original to this work.

Name, Last name : Çağrı Özkan Signature : Date:

ACKNOWLEDGMENTS

I would like to express my deepest gratitude to my supervisor Assistant Professor Dr. Boran Sekeroglu for his great support and open-minded mentorship, without whom this study would not have been completed. Special thanks go to Mr. Murat Ozturk, Mr. Süleyman Pasa, Mr. Emrah Bebek, Mr. Abdullah Sarı, Mr. Cengiz Barcın, and Ms. Aria Toprak for their technical assistance on firefighting reservoirs and project itself. I am grateful to Assistant Prof. Dr. Sertan Kaymak, Dr. Perihan Aysal Adun and Ms. Kezban Alpan for their invaluable recommendations. I would like to thank all the chairs in my jury for their scholarly recommendations. I am deeply grateful to my parents for their long-life support. Finally, I am thankful to all my colleagues and friends.

i

ABSTRACT

Water has still vital importance to extinguish forest fire. In large, contiguous, hilly forest areas with medium to high fire risk, it is necessary to build and maintain artificial reservoirs besides natural water sources. Artificial ponds, dams, underground water tanks can be used as fire fighting reservoirs. These water extraction points should be sufficiently identified regularly controlled and easily accesible by fre engines.

In this study, an online tracking system was developed to control water depth, water temprature in water reservoirs and weather temprature around these reservoirs. This android based-online tracking system will provide information about not only the situation of fire fighting water reservoirs but also about the environment and increase success in forest fire protection.

Online tracking system can also be used for many similar purposes. For example almost all the houses in Cyprus have water tanks in different parts of the houses because of water shortage. These reservoirs have no any control unit. Users can only be aware when water has finished. It would be useful to be able to control and have information on the capacity of these reservoirs beforehand.

It is also possible to design android based-online tracking system to collect environmental data.

KeyWords: Measurement of water level, Heat control, Wireless, Modem, Device control, Arduino, Android, Remote control, Intelligence systems engineering

ii

ÖZET

Orman yangınını söndürmek için su hayati öneme sahiptir. Orta ila yüksek yangın riski olan geniş, bitişik, engebeli ormanlık alanlarda doğal su kaynaklarının yanı sıra yapay rezervuarların yapılması ve sürdürülmesi gerekmektedir. Yapay göletler, barajlar, yeraltı su depoları yangınla mücadele rezervuarları olarak kullanılabilir. Bu su çekme noktaları, düzenli kontrol edilen ve itfaiye tarafından kolaylıkla erişilebilecek şekilde tanımlanmalıdır.

Bu çalışmada, su derinliği, su rezervuarlarındaki su sıcaklığı ve bu rezervuarların etrafındaki hava sıcaklıklarını kontrol etmek için bir çevrimiçi takip sistemi geliştirilmiştir. Android tabanlı çevrimiçi takip sistemi, sadece yangınla mücadele eden su depolarının durumu hakkında bilgi vermekle kalmayacak, aynı zamanda çevre hakkında bilgi sağlayacak ve orman yangınları ile mücadelede başarıyı artıracaktır.

Çevrimiçi izleme sistemi birçok benzer amaç için kullanılabilir. Örneğin, Kıbrıs'ta evlerin neredeyse tamamı, su sıkıntısı nedeniyle evlerin farklı yerlerinde su depoları bulundurmaktadır. Bu rezervuarların herhangi bir kontrol birimi yoktur. Kullanıcılar, depodaki suyun bittiğinden ancak su bittiği anda haberdar olabilmektedirler. Bu rezervuarların kapasitelerini önceden kontrol edebilmek ve bilgi sahibi olabilmek kullanıcılar için son derece faydalı olacaktır.

Çeşitli çevre verilerinin toplanması amacıyla da android tabanlı çevrimiçi takip sistemi tasarlamak mümkündür.

Anahtar Kelimeler: Seviye ölçme, Isı kontrolü, Wireless, Modem, Cihaz kontrölü, Arduino, Android, Uzaktan control, Bilşim sistemleri mühendisliği

iii

TABLE OF CONTENTS

ACKNOWLEDGMENTS ………………………………………………...…………………… i

ABSTRACT…………………………………………………………………………………….. ii

ÖZET……………………….…………………………………………………………………… iii

TABLE OF CONTENTS ……………………………………………..……………………...... iv

LIST OF FIGURES……………………………………………….……………………………. viii

LIST OF TABLES……………………………………………………………………………… ix

LIST OF SYMBOLS AND ABBREVIATIONS …………………………………………...... x

CHAPTER 1: INTRODUCTION

Introduction…….………………….…………………………………………………………...... 1

1.1 Explanation of Purpose and Usage Areas of Water Level Control Used in the System……. 3

1.2 Purpose of Water Tanks for Forest Fires……………………………………………………. 4

1.3 Forest fire pools……………………………………………………………………………… 5

1.4 How to create forest fire pools procedure…………………………………………………… 5

1.5 What control “The control of forest fire pools” which department and procedure………….. 6

1.6 The materials used in the current system and the filling system…………………………….. 6

1.7 Purpose of Water Storages in TRNC……………………………………………………...... 6

1.8 Current filling system in TRNC……………………………………………………………... 6

CHAPTER 2: PREVIOUS PROJECTS AND ARDUINO DESCRIPTION

2.1 Introducing Arduino…………………………………………………………………………. 7

2.2 Arduino’s Software………………………………………………………………………….. 7

2.3 Project Information Designed with Arduino ………………………………………………... 7

2.4 Arduino usage areas and features……………………………………………………………. 8

iv

2.5 Arduino Card Types………………………………………………………………………… 8

2.6 Arduino circuit board and features…………………………………………………………... 9

2.7 Arduino Memory…………………………………………………………………………….. 13

2.8 Basic Concepts of Arduino…………………………………………………………………... 16

2.8.1 Microprocessor (ΜP)………………………………………………………………….. 13

2.8.2 Input Voltage…………………………………………………………………………... 13

2.8.3 System Voltage.……………………………….……………………………………….. 14

2.8.4 Clock Speed……………………………………………………………………………. 14

2.8.5 Digital I / O…………………………………………………………………………….. 14

2.8.6 Analog Input…………………………………………………………………………… 14

2.8.7 PWM (Pulse Width Modulation)……………………………………………………… 14

2.8.8 Universal Asynchronous Receiver and Transmitter (UART)…………………………. 15

2.8.9 ………………………………………………………………………….. 15

2.8.10 Bootloader……………………………………………………………………………. 15

2.8.11 Programming Interface……………………………………………………………….. 15

2.9 Arduino Language…………………………………………………………………………… 16

2.10 Previous projects with Arduino……………………………………………………………. 16

2.11 Robot Hand Performing that Copy Finger Motion………………………..…………...... 16

2.12 Wireless Sensor for Forest Fire Detection………………………………………………… 17

2.13 Development of Rotating Wing Control and Control Software with Arduino Development Card……………………………………….. 17

2.14 Fuel cell-powered electric power of a vehicle, temperature, Relative humidity, and speed of Instant monitoring and control…………………………………………………… 17

2.15 Wireles Fidelty (Wifi)…………………………………………………………………...... 17

2.15.1 How does it work………………………………………………………………….. 18

2.16 Android……………………………………………………………………………………... 18

v

2.17 Remote Control System……………………………………………………………………. 19

2.18 Solar Energy……………………………………………………………………………...... 19

2.19 3G Modem…………………………………………………………………………………. 19

2.20 Cloud System……………………………………………………………………………… 20

CHAPTER 3: METHODOLOGY

3.1 System Design……………………………………………………………………………….. 21

3.1.1 System Features……………………………………………………………………... 22

3.1.2 How The System Works…………………………………...... 23

3.1.3 Materials and Programs Used in the Lower System of Our System…………….. 25

3.2 Materials used in electronic infrastructure of the timeshare………………………………… 25

3.3 Arduino Nano………………………………………………………………………………... 28

3.3.1 Power…………………………………………………………………………………... 28

3.3.2 Inputs and outputs……………………………………………………………………... 28

3.3.3 Arduino Nano Memory………………………………………………………………... 29

3.4 Heat Sensor…………………………………………………………………………………... 29

3.4.1 Features………………………………………………………………………………... 30

3.5 Relay…………………………………………………………………………………………. 31

3.6 Ultrasonic Sensors…………………………………………………………………………… 32

3.7 Wi-Fi Esp8266………………………………………………………………………………. 33

3.8 Solar panel…………………………………………………………………………………… 33

3.9 Battery……………………………………………………………………………………….. 34

vi

CHAPTER 4: DESIGNED DEVICE CIRCUIT INFORMATION

4.1 Overview…………………………………………………………………………………...... 35

4.2 Working Principle…………………………………………………………………………… 35

CHAPTER 5: CONCLUSION………………………………………………………………… 40

REFERENCES…………………………………………………………………………………. 41

APPENDICES

Appendix 1 : Hardware Compound…………………………………………………………….. 46

Appendix 2 : Source Codes…………………………………………………………………….. 47

vii

LIST OF FIGURES

Figure 2.1: ……………………………………...……………………….. 10

Figure 2.2: Arduino Uno Schematic…………………………………………………... 11

Figure 2.3: Arduino Uno Pin Diagramı………………………………………………... 12

Figure 3.1: Water storage system……………………………………………………… 22

Figure 3.2: Fire pool working syste…………………………………………………… 23

Figure 3.3: Flow Chart of Application Simple Module……………………………….. 24

Figure 3.4: Android user screen……………………………………………………….. 25

Figure 3.5: View of the front and back of the Arduino Nano card……………………. 26

Figure 3.6: Atmega 328 pin diagram………………………………………………….. 26

Figure 3.7: Arduino Nano ATmega 328 Pin Diagram……………………………….. 28

Figure 3.8: Heat Sensor and its Diagram……………………………………………… 30

Figure 3.9: Arduino Relay Module……………………………………………………. 31

Figure 3.10: View of the front and back of the Hc-rs04 ultrasonic card……………….. 32

Figure 3.11: Water storage and fire pool………………………………………………... 32

Figure 3.12: Arduino 5 Wi-Fi esp8266…………………………………………………. 33

Figure 3.13: Solar Panel………………………………………………………………… 34

Figure 3.14: Battery…………………………………………………………………….. 34

Figure 4.1: Online Role Control Module……………………………………………… 36

Figure 4.2: Online Temperature Meter Module……………………………………….. 37

Figure 4.3: Online ultra sensor module……………………………………………..... 37

viii

LIST OF TABLES

Table 2.1: Technical specifications of Arduino Uno…………………………………. 12

Tablo 3.1: General Features of Arduino Nano ATmega328 Micro Controller……….. 27

ix

LIST OF SYMBOLS AND ABBREVIATIONS

TRNC: Turkish Republic of Northern Cyprus Wi-Fi: Wireless Fidelity RF: Radio Frequency SMS: Short Message Service GSM: Global System for Mobile Communications SCADA: Supervisory Control And Data Acquisition LCD : Liquid Crystal Display PC: Personal Computer TV: Television LED: Light Emitting Diode RGB: “Red” “Green” “Blue” 3D: Three Dimension USB: Universal Serial Bus PWM: Pulse Width Modulation ICSP: In-Circuit Serial Programming SDA: Serial Data SCL: Serial Clock AREF: Analog Reference KHz: Kilohertz MHz: Megahertz GHz: Gigahertz KB: Kilobayte MBİT: Megabit RAM : Random Access Memory ROM: Read-Only Memory SRAM: Static Random Access Memory EEPROM: Electronically Erasable Programmable Read-Only Memory

x

AVR: Automatic Voltage Regulation Lİ-PO: Lithium-Polymer V: Voltage I/O: Input / Output ADC: Analog Digital Converter UART: Universal Asynchronous Receiver and Transmitter IDE: Integrated Drive Electronics WSN: Wireless Sensor Network WLAN: Wireless Local Area Network PCMCIA: Personal Computer Memory Card International Association 3G: Third Generation GPRS: General Packet Radio Service EDGE: Enhanced Data Rate for GSM Evolution RISC: Reduced Instruction Set Computer SPI: Serial Peripheral Interface TTL: Time to Live CRC: Cyclic Redundancy Check TCP: Tranmission Control Protocol IP: Internet Protocol

xi

CHAPTER 1 INTRODUCTION

It is a known fact that there is a water cut problem in Cyprus and many people suffer from it. With this project we aim stopping this suffering and cutting back workforce, cost and time. Another aim of this system is to take the fire pits under control which are used widely around the world and hard to control because of their position. The motivation here is to take this under control to spend only in times of need and to use it efficiently since it is the source of life and we can observe that there have been many natural disasters resulting in diminishing of our water resources. In many great forest fires there are many parts of the forests which are not near a water resource. In these regions we can say that water tanks are vital for firefight. In such regions the watertanks should be always under control and the geographical features of the region should be well known so that in a natural disaster (like big forest fire) the water tanks can be full and helps us to protect the environment. This system will both check the water level of the tank and will give information on the features of the region to the fire fighters. Since the team who will intervene with the fire will go to the region with this information a waste of time will be prevented also, money and material will not be unnecessarily spent. The study will prevent serious dangers by supplying a regular check of the water level hence eliminating the possibility of water tank’s being empty. It is a well-known fact water tanks requires regular checks and it leads a workforce loss. With this system we can check the water level and if needed we can get a warning when the level is low. The system is open to renovations and adaptation to use in automatization systems in city water tanks. Our aim is to use this system in water tanks for fire fight, water storage, and agricultural irrigation or for any kind of water tank that needs remote controls and checks. This system works on a Wi-Fi base and it is adapted to android operating system; it works via internet with wireless connection. The software that is used in the system is software specific to android. Our system can be controlled wherever we are with its technological android interface; by looking at the screen we can check any kinds of liquids or certain kinds of concrete’s level.

1

The applications which allow wireless communication devices for a safe access to information are very common. With wireless access to information we can achieve work safety, flexible control and lower prices. In this study we aim at saving of power, higher work safety, flexible control and lower prices by providing wireless remote control of water pumps. There is not enough study on this subject in national literature. The most important difference of this study from the others is that a new code has been developed for giving and receiving parts. In 2010, Başarslan et al. conducted a study by using an Rf sensor with a telemetry application; and a Short Distance RF Sensor and Telemetry Application Work that is mostly used in long distances. These RF systems uses RF data modems which provide communication with transmitting radio vibes through internet when in the harder situations like on high mountains or in noisy places. By this way, communication was made possible between distance places. Fidan and Karasekreter, 2011 In this study an SMS control was used which is one of the remote controlling systems that is used in Gsm/Sms based irrigation automatization. It was a system which checks the water level in the tank according to arranged date and hour and gives a notification by SMS. Çakır and Çalış carried out a study in 2008 on Remote Controlled Automatic Irrigation System and Application. A remote irrigation system was built by using one of the old control mechanism, PIC 16F877. In this system you can do a remote irrigation automatically of manually via GSM. When on automatic, the system compares the given value and the value that the plant needs and does the irrigation accordingly. This leads to saving of the water. While working on the manual mode the same control was achieved by SCADA interface via internet. In this way a saving on workforce, price and time was achieved. In a study on Scada System Design for Liquid Level, the liquid control system was developed depending on the resistance by processing the information taken from the water gauge. By using the interface program, the values can be seen on the screen (Adiyan 2012). Özeden and Dursun (2010) have intended to develope a system with radio frequency control of the water in the water tank with the centrifugal pump. Two sensors were used for the float buoy in which the pump has flooded. With the help of these sensors the water level of the reservoir is controlled and the pump floods water. UFM-A12 WPA module of 868 MHz UDEA with 10 km distance is used in the open area in the radio frequency communication system. The data sheet of the RF module is provided by Microchip's PIC18F452 . In this project, which is made with a low cost, the control of the water pump at 1600m distance is achieved by wireless communication with no problem.

2

Altın and Bulut (2016), in their work on Bluetooth-linked Ultrasonic Liquid Level Meter Design and Industrial Process Applications, developed a device that aims to control the level of substances in liquid tanks in factories with ultrasonic sensors. The data obtained with the help of the sensors reflect the LCD panel connected to the system, while the Bluetooth transmitter can also send data to another PC and phone. In this way you can also control how the system works from different places. In this device, the system tanks were measured at certain intervals and error rates were found with the data of the existing device. As a result, this device has been designed to be used in areas such as chemistry, automotive, textile, paint factories at a lower cost compared to the other systems that were made. Korkmaz and Kormaz (2007), have aimed to control the current usage and security systems of screen devices with mobile communication systems in the work called remote control of electrical devices and security systems with mobile phones. They have been involved in research to bring the life criterions that existed throughout the lives of human beings to the top so the final state of electronic systems used for home and commercial purposes has now entered into life as automation. Since cellular network and communication are very efficient, they offer use and preference options. The remote access operation is performed by giving energy to the devices. Therefore, it is possible to control the system and devices (mobile system) and electronic devices such as TV, PC, audio. It is the process of using the systems used in the home or commercial areas by combining the mobile devices of the electric devices and using the network as the automation channel.

1.1 Explanation of Purpose and Usage Areas of Water Level Control Used in the System

Our system has a remote control and check of heath and level. Instantaneous heat and water level control can be done outside of the set levels and we are notified through Android phones. Notifications are repeated at regular intervals until the set level returns to normal. With this, we aimed t notify the user certainly. After the alarm is activated, the user has the opportunity to silence the alarm as soon as the user notifies the required locations or as he goes to the system to complete his own checks. The aim of this system is to control the wells that are ready to be used during the fire and to make them continuously informed.

3

We intend to avoid situations such as the possibility of empty tanks at the time of need, such as the freezing of water in cold regions or the possibility of water evaporation in very hot regions. So there is always as much water as you need. Because the main purpose of the fire wells to save life and nature when there are big fires. These wells which have such an important task should be under constant control and should not be overlooked since any accidents that may occur. We wanted to make sure that it was easy to get access to it by taking into account the mountainous areas where the wells are located. In this case, the condition of the wells and the ambient air temperature will be informed and the regional studies and analyzes will be made so that the wells can be used continuously and regularly at the time of need. By controlling the water levels, the evaporation rates or the probability of freezing according to the ambient conditions can be done in the risk analysis. Through remote access, it is possible to make reinforcement plans for wells in required periods.

1.2 Purpose of Water Tanks for Forest Fires

Water is usually used to extinguish forest fires. Fires in risky areas generally in tend to grow bigger. Therefore, there is a great need for water resources to extinguish the growing forest fires. However, in the forests and in the hilly area, it is difficult to find water supply. Before the water tanks for forest fires were built, the dams, the lakes or the rivers in the forests were utilized. However, the fire does not always come out where the water source is. Therefore, make it easy to access the water source in the risky forested areas in terms of fire water sources were constructed since it is the number one material for fire fight (there are water tanks in every 5 kilometers). Even if a fire broke out in any of these risky areas, it was possible to renew the water that we used to extinguish the fire and water tankers and even the helicopters repeatedly because there were many local fire pools. If we assume that there is no water source or water sources are distant on, the fire will not be able to be intervened because the water is over and the fire will grow bigger because we lose time by filling up water tankers and planes with water again and again. These pools for fire extinguishing provide a great deal of time for vehicles to refill their water. We want to make our system compatible and useful for many places and situation in order to observe problems in the regions we have lived and to find solutions to them. That's why we added control of the water tanks on the houses.

4

Thanks to the water storage system in the houses, the storage and filling systems that meet the water needs of all the households are controlled and the faults are minimized. So we built an online follow-up platform so that people in these areas could benefit from their cleaning and water needs, and not be thirsty in the face of water engine, buoyage failures. The level of water in the reservoir can be monitored by operating the motor remotely when measuring the water levels online and observing that the level has decreased in any case and that the reservoir has not been filled even though it is on the day of filling. This will make it possible to observe whether there is a problem in the system. If the level gets not any higher even when the when the motor is activated remotely, there will be options such as electricity, water interruption or engine malfunction, and the solution will be easy to reach after the user has checked it. Further water detection of the water level sensor at the bottom of the tank means that the float is continuing and the engine is still pumping water, so that the engine that is still trying to press when the tank is full will be shut down remotely. Thanks to all these features, it is aimed to contribute to the budget of the families by planning to prevent the people from being deprived of water as well as preventing any defects that may arise. The water level in the reservoir can be seen instantly and monitored, and at this point we can instantly monitor how much water there is in our depot from our mobile phone.

1.3 Forest fire pools

Forest fire pools are selected according to the conditions. It is vulnerable to fire and is installed in areas that may be at risk when the fire breaks out. As these areas are wide, the distance between these pools is established at intervals of 5 km. They are usually installed in areas where the waters of the air vehicles can comfortably reach their backs. The selection of pools is an important criterion to be a source of water while locating locations. It is important for the fire season to ensure the continuity of water in the pool.

1.4 How to create forest fire pools procedure

Once the appropriate location is determined, it is installed in the area according to the scored project. Which materials are to be decided on (Concrete pools, mebran pools)

5

1.5 What control “The control of forest fire pools” (which department and procedure)

The water of the fire pools, pool problems which are within the boundaries of each forest management concession is followed at certain intervals during the fire season (by going to the pool and observing).

1.6 The materials used in the current system and the filling system

Pool filling is usually provided directly from the water supply. The water flows from the water source to the pool with the help of the pipes pulled to the pool, so the filling takes place. In the pools where there is no water source, it is filled and monitored by the water tankers. Filling and malfunctioning of the pool is controlled by observing the point where the pool is located

1.7 Purpose of Water Storages in TRNC

Water reservoirs are very long years, and when water is cut from incoming water source, it provides water where it is located, and water is the vital source of human life. In case water is cut off, water reserves stored as spare reserves and prevent people from being a victim. In this respect, it determines how long the water will remain in the depot and whether the resource will last until the water supply is reached.

1.8 Current filling system in TRNC

The municipal water given by the municipalities filling the water reservoir is provided directly from the place where the water source is located and filling of the water reservoirs takes place. When the water is turned off by the municipality or due to any problem, it can be carried out by the private water companies outside with special tools. It protects people from a great victimization and allows them to continue their lives.

6

CHAPTER 2 PREVIOUS PROJECTS AND ARDUINO DESCRIPTION

2.1 Introducing Arduino

Arduino is an electronic and software based development platform designed to develop interactive projects. The reason Arduino is preferred is that it is easy to use and open source. Individuals and institutions can design and build their Arduino in their own projects. Arduino's projects are easy to use and projects are faster, more stable, advanced technology can be easily integrated into the board and it is cheaper in terms of cost(Hochenbaum et al., 2013).

2.2 Arduino’s Software

The open source Arduino Software is software that is completely free to users. The most important reason for choosing Arduino is Arduino libraries, which allow anyone to program without having to be knowledgeable about the microcontroller. You can see how the program is written by looking at the library part of the written program. Also, the programming codes in the Library section offers the opportunity to develop the way we want to be able to change them(Oxer and Blemings, 2011).

2.3 Project Information Designed with Arduino

With Arduino, computer controlled circuits can be made. It's not just the computer, the HC-05 and HC-06 Bluetooth Module with the Bluetooth card that contains each device, thanks to our management we provide. If you give an example of this, you can make cubes that can make your home decorations beautiful with LED lights. Write articles, with RGB LEDs you can play with the colors, you can give colors according to the temperature of the environment. The Arduino board using, for example, depending on obstacles, the interference noticed with the help of sensors and robots that change the direction of your plants getting enough water and watering systems, he noticed a certain color and follow the car who drew pictures of robots, 3D printers, such as several programming projects that you can imagine with these cards you can perform. If you want to imagine more advanced technologies, advanced processor devices that can connect to the Internet with the Arduino is also open to the world by making target. In this way, we have removed control limits. Thanks to Robotics and

7

Arduino in control of the machinery that is used in the industry made it easier. One of the most striking parts about Arduino is a fun educational material for children, but it can turn into a genius when it comes to the hands of advanced technology programmers.

2.4 Arduino usage areas and features

With Arduino, systems that can easily interact with the environment can be designed. By processing the signals from the sensors, systems, and robots that interact with the environment can be designed. The most important feature of Arduino is open source development platform, so we can design and use our own software as we want. Since the codes are not hidden in the works, these works can be easily accessed by the users and you can easily program with Arduino libraries. Thanks to its analog and digital inputs; Analog and digital data can be processed with this data thanks to observations can do a lot of work. For example; we can feed the fish we feed in the aquarium automatically at the desired time intervals, we can turn the light on and off, Or when we enter the parking lot of a shopping mall to park our car, it can help us find the vacant parking areas by giving a light warning. In short, we can easily build the system we want with Arduino UNO according to the power of thought all over our lives. With Arduino, many more things can be done. Bluetooth scales, Line following robots, intelligent home systems, agricultural technology etc. can be realized. Originally designed to work on the outside world; Reactions such as temperature, sound, motion, light can be created. Arduino also has various modules and cards designed to solve different needs.

2.5 Arduino Card Types

Today, new Arduino cards are emerging day by day. Arduino cards in general are:

 Arduino Uno  Arduino Leonardo  Arduino Due  Arduino Yun  Arduino Tre  Arduino Micro  Arduino Robot  Arduino Esplora

8

 Arduino Mega ADK  Arduino Ethernet  Arduino Mega 2560  Arduino Mini  LilyPad Arduino USB  LilyPad Arduino Simpl  LilyPad Arduino SimpleSnap  LilyPad Arduino  Arduino Nano  Arduino Pro Mini  Arduino Pro  Arduino Fio

Arduino Uno is the most widely used card among these cards. Arduino Uno will examine; ATMega328 is a microcontroller based card. It has 14 digital input / output pins (6 can be used as PWM output pin), 6 analog inputs, 16Mhz crystal, USB socket, power socket, ICSP connector and reset key(Website Arduino, 2016).

It contains all of the required for the operation of the microcontroller on the card. It can be connected to the computer via USB cable easily. It can be operated with adapter or battery.

2.6 Arduino circuit board and features

The Arduino Uno model described in this example has the most basic functions. The price is also more convenient. This card is therefore used as a tutorial model. In this respect, both Arduino Uno models are favored by both project developers and programmers who are entering programming. See Figure 2.1 Arduino Uno card below.

9

Figure 2.1: Arduino Uno

The material layout of the Arduino Uno card is as follows. The following diagram clearly shows the placement and interconnection of the materials. With this diagram, if there is a fault in our card, it can help me to resolve the faults by following the connections. We can examine the structure of Figure 2.2 and Figure 2.3 below in detail.

10

Figure 2.2: Arduino Uno Schematic

11

Figure 2.3: Arduino Uno Pin Diagramı

The technical specifications are shown in detail in Table 2.1(Susanto et al., 2011).

Table 2.1: Technical specifications of Arduino Uno

Microcontroller Atmega328 Working Voltage +5V DC Recommended Feed 7-12 V DC Voltage Supply Voltage Limits 6-20 V Analog Input Pin 6 piece Maximum for I / O Units 40 mA DC Output Current Clock Frequency 16 MHZ EEPROM 1 KB I/O Number 14 piece (6 PWM)

Arduino Uno microcontroller is a card with ATMega328. Arduino Uno; There is a USB input and an external power supply as in the nano card. In addition, the special pins and other pins on the Uno card are the same as the nano card. Arduino Uno cards; Arduino Uno SMD,

12

Arduino Uno R2 and finally Arduino Uno R3 Some changes have been made between these cards. Only new arrangements have been made on the Arduino Uno R3 card. Arduino Uno R3 along with some new additions(Badamasi, 2014).

 SDA and SCL pins are added next to an extra AREF pin.  Added pins to support the reset button and to further strengthen this button. When there is any problem, the negative risk is used to reduce minimum.  The ATMega16U2 chip is used instead of FTDI and ATMega8U2 to enable communication and programming to transfer data faster via USB.

2.7 Arduino Memory

The Arduino Uno microcontroller ATMega328 has 32 KB of flash memory. But the Arduino bootloader uses a field memory 32 KB 0.5 KB. The Arduino Uno card has 2 KB of RAM and 1 KB of EEPROM memory space(Margolis, 2011).

2.8 Basic Concepts of Arduino

2.8.1 Microprocessor (ΜP)

The center of the Arduino is the microprocessor unit. Arduino is an important concept for. Arduino development cards are based on different AVR microprocessors. Each AVR microcontroller has its own functionality and feature(Barrett, 2013).

2.8.2 Input Voltage

The most healthy voltage range for the card. The development board is fed with voltage value slightly higher than the highest voltage range. There is no trouble in feeding it is trustworthy. But there is a trick we need to know. This trick is supported by a Li-Po battery with a voltage of 3.7V. To explain this Li-Po type of battery, it is the battery that houses Lithium and Polymer chemicals in the structure. Arduino varieties already available in the market support this voltage value. Arduino variants can, therefore, be fed directly to 3.7V Li-Po batteries(Barrett, 2013).

13

2.8.3 System Voltage

The working voltage of the microprocessor is inside the card value. The compatibility of this card (especially the moment of passing a value from 5V to 3.3 V) is an important factor to be considered(Barrett, 2013).

2.8.4 Clock Speed

It is the speed at which microprocessors are connected. The microprocessors depend on the speed at which the instructions run. But a few rare cases can happen. Many ATMega microprocessors support a clock speed of 8 MHz while the voltage value is 3V, while the voltage value supports 16MHz at 5V(Ramankrishnan and Condrad, 2011).

2.8.5 Digital I / O

The total number of digital inputs and outputs are on the Arduino board. These are called input or output, while others are designed to be PWM(Barrett, 2013).

2.8.6 Analog Input

The sum of the available analog inputs are on the Arduino card. When naming analog pins, first write "A" followed by the numbers next to it. This allows us to read the analog values through the Analog-to-Digital Converter (ADC) in the ATMEGA chip. If we need the analog inputs, more output/input as we can use it(Barrett, 2013).

2.8.7 PWM (Pulse Width Modulation)

It is the total number of Digital Inputs / Outputs that have the capability of generating signals. The operating logic of the analog outputs the PWM signal as the logic works. The analog voltage 0V system voltage of the Arduino board with a value of the value range provides the possibility of deception(Barrett, 2013).

14

2.8.8 Universal Asynchronous Receiver and Transmitter (UART)

Provided by the Arduino board, the serial connection is the total number of lines different from each other. A lot on the Arduino board digital input/output pins 0 and 1 is twice that of the series. The pins obtained are shared with serial programming port. Some cards have more than one Arduino Universal Asynchronous Receiver Transmitter (UART). All serial ports at a time can support. The Arduino Board has at least one UART for programming all. But some of the pins in the Arduino board are not accessible(Nguyen, 2014).

2.8.9 Flash Memory

Flash Memory is a type of memory that can be rewritten and erased without losing the information it contains even during power failure. Information and data are referred to as the maximum memory that can be stored. The structure of flash memory is similar to that of RAM, and its use is similar to that of Hard Disks. The structure of flash memories is not mechanical; Electronic. But we cannot use all of the memory. Because a certain portion is reserved to be used by the bootloader (usually between 0.5 and 2 KB) (Barrett, 2013).

2.8.10 Bootloader

If we describe the microprocessor as Arduino's brain, we can qualify it as a bootloader personality. The bootloader is located inside the ATMega processor and allows us to load for hardware programming via the serial port. The reason is that different cards have more than one Arduino, microcontrollers and programming interfaces uses different from each other. Each microprocessor and program interface has a different bootloader program. The source codes for the bootloader can also be found for Arduino distribution. All Arduino bootloaders allow you to load code from the Arduino IDE software(Evans, 2011).

2.8.11 Programming Interface

To program the Arduino Development Board allows establishing a connection with the computer. Some Arduino cards include USB Jack. We can easily connect them to a computer via USB cable. Some Arduino cards have USB jacks and some have Headers. Arduino cards of this type are possible with our FTDI Basic breakout or FTDI cable connection. The serial pins to the Arduino Mini cards like to schedule. But it does not support FTDI header.

15

Each carrying embedded Arduino USB jack, USB includes various additional equipment for conversions. Some do not require additional hardware on the Arduino board ready. Because microprocessors have embedded USB support(Evans, 2011)

2.9 Arduino Language

C is a general-purpose programming language. When the Arduino is programmed in the C language, as well as our library is written in C language is also fed the actual place. The language of any programming language and this language is the source of many of today's a- team characters. C# as a language derived from the language that they use and nowadays it is quite common(Bayle, 2013).

2.10 Previous projects with Arduino

Depending on the developing technology, has been a rapid increase in smart home systems and provides great convenience for people with studies in this direction. Developed to make people's lives easier, these systems they offer us comfort and peace. In the studies, the room lighting smart home system in the car, closing the garage door opening to provide control in tasks such as the Arduino UNO were used. Depending on these, the smart system control can be provided in a format convenient and useful for the home(Koçak and Kırbaş, 2016).

2.11 Robot Hand Performing that Copy Finger Motion

In the present study, the movements of the operator's hand, the fingers a glove that is worn on a robotic arm has been realized with technology designed and repetitive. The hand model was prepared via a 3D printer. Thanks to flexible sensors that is placed normal gloves, finger movements and converts them into electrical signals, and then these values are processed by the microController, the Arduino Uno with the system undergoes the action of the fingertips. (Korkmaz and Kasapbaşi, 2016).

16

2.12 Wireless Sensor for Forest Fire Detection

Early detection of the fire disaster that may occur incident to be able to intervene quickly in this direction and developed early detection system. The Wireless Sensor Network (WSN) detects information such as temperature and humidity in real time quickly by placing it in a large number of forests and provides information to the fire intervention center and attempts are made to prevent fires. The infrastructure of this system, the Arduino Uno system is used (Dönmez et al., 2013).

2.13 Development of Rotating Wing Control and Control Software with Arduino development card

Unmanned aerial vehicles can be considered as indispensable intelligence defense or even attack vehicles in today's conditions. These tools act according to a specific plan. A weapons system of moving non-uniform and in off-road conditions the percentage of strokes of the barrel towards the target region must remain constant as high for shots. For this reason, the position of the weapon system must be determined. The changes in the position of this weapon system are identified when the detected change in position of the guiding barrel, the barrel engines via Arduino using the system to move in the opposite direction is provided (Kıyak and Göl, 2015).

2.14 Fuel cell-powered electric power of a vehicle, temperature, Relative humidity, and speed of Instant monitoring and control

Fuel cell-powered electric power of a vehicle, temperature, Relative humidity and speed control with Arduino UNO and card design and check instant monitoring of the samples was carried out. Obtained here temperature, Relative humidity, such as the basic function of the vehicle speed data. The data are easily obtained and available by the Arduino(Aydın et al., 2013).

2.15 Wireles Fidelty (Wifi)

WiFi 'Wireless Fidelity' emerged as an abbreviation of the words. (Wireless Fidelity) is a term used to describe high-speed wireless network connections over short distances between Wi- Fi, mobile computing devices such as laptop computers, and the Internet. Them sometimes referred to as WLANs or wireless local area networks. It is a technology unit that enables the connection of a personal computer, mobile phone, camera, audio player, tablet, game console

17 and even internet from TV. Portable devices such as laptops are connected to the wireless access point by means of nearby wireless access points, enabling the connection of the device to the local network, that is, the entry of the internet. For example, your wireless access point, your wireless box, the machine that will be connected to your computer connected to this box, and your mobile phone connected to the Wi-Fi network of Wireless can connect to this network and can be schematized as an incoming client(Molisch, 2012).

2.15.1 How does it work

Wireless network ports are actually systems that operate in the same way as router modems we know and produce small radio waves. WiFi standards are classified as 802.11a, b, g and n according to the types and characteristics. The most widely used is 802.11b and has a spreading range of 2.4 GHz. However, it is possible to connect up to 11 megabits with 802.11b. However, with 802.11g, it is possible to reach speeds of 54 Mbit / sec and 802.11n / 140 Mbit / sec. Today, almost all laptop computers integrated Wi-Fi receivers contain. Those who are not available can easily acquire this feature with PCMCIA cards. Also, wireless network systems work with radio frequencies(Molisch, 2012).

2.16 Android

Android, a mobile operating system being developed by the Open Handset Alliance for mobile devices.The Android app has reached and is still reaching widespread proportions with google. Android is Linux based, open source free and free software that can be written and designed by both users and programmers, but Linux is open source, but Google only allows a certain portion of this code structure to be accessed. Android operating systems are used in mobile phones and tablets and are a useful application for devices that are rooted android. One of the best advantages of the use of tablets Android and most applications to be provided to users free of charge and user-developed applications thanks to the Google store, free and paid, allows to provide a way to people in this way, are used by millions of people (Developers, 2011)

18

2.17 Remote Control System

Remote Control system; It is a control system that works with Gsm infrastructure that can instantly transmit the data of the whole working time of the device to the authorized person in order to provide control such as water pools and fire pools in the TRNC and intervene if necessary. In addition, with this system, without going to the device that made the breakdown; Learn what the problem is and have preliminary knowledge of the solution, take precautions. What are the benefits of the remote control system(Feher K, 2011).

 Savings from workload  Save time  Point determination of the solution

2.18 Solar Energy

Since the formation of the sun and the earth, endless energy source. This energy source has made the man more useful with a renewable energy source ie solar cell. The ultraviolet rays from the sun with solar cells on the solar cell converts into electrical energy. The fact that there is no other cost after the system is installed economically contributes to the country and the individuals. Solar energy is now widely used. The fields of solar energy use, for example, traffic lights, garden lighting, hot water supply, calculator, solar powered cars are used in street lighting (Duffie and Beckman, 1974).

2.19 3G Modem

3G speed mobile broadband internet connection can provide the use of technology. 3G in English is the Third Generation and the Turkish term stands for Third Generation. It is a connection technology that can provide mobile broadband internet usage. 3G is the Third Generation in English and stands for Third Generation in Turkish. One of the 3G mobile modem wireless modems that are available today. 3G mobile Internet with GPRS/EDGE supported mobile 3G modem wireless 3G compatible, you can connect to the internet from anywhere in the world you want fast and easy.

19

With the 3G mobile modem, it is possible to easily perform banking transactions, send SMS messages while on the move, wirelessly, easily and quickly without interrupting your phone, you can connect anywhere you want(Urien, 2011).

2.20 Cloud System

Capacities of the devices are insufficient due to the large size of the stored data. The cloud system is used as a solution to this. Cloud system; Is an online storage service that allows us to access the data we have uploaded from the internet through any medium with internet. It is used in two ways as an application(Wang et al., 2010).

1. Providing access through the network, management and trading software and the use of the cloud system,

2. Implementation of the cloud system with the management of each user site separately from the central locations.

20

CHAPTER 3 METHODOLOGY

3.1 System Design

The existing systems are designed using the theme of Arduino processors for developing mobile and other systems. Advanced technologies and also an infrastructure and technology gives us a great chance to receive and intervene in many areas. In order to benefit from these systems and to take samples from these studies, the water reservoirs, and forest fire pools are detailed by focusing on the solutions required to reduce the workload of the people. All the results are considered and a system design is needed in the following way.

3.1.1 System Features

 Weather measurement (ambient temperature)  Measuring the water temperature of fire pools and water tanks  Control of fire pools and lower and upper limits of water in water tanks  Two-way communication to receive information and receive remotely based on the information received  Easy management panel via Android system  Many users access at the same time  Instant alarm system for all users  User-specific identification of alarm levels  Addable module design  Easy adaptation to different modules and system identification  Water motor and perimeter device controls (on-off) in headlight well systems  Low energy consumption  Working with Wi-Fi modem  Easy installation and installation

21

3.1.2 How The System Works

It can be connected to the internet via the Wi-Fi sensor located on the timescale. Thanks to the sensors connected to it, the data related to the environmental conditions are recorded on the internet.

This allows me to reach the desired data from the medium. Even if it is desired to intervene in any system considering the ambient conditions, it can have remote control ability thanks to the relays added to the exit of the device.

The important thing here is that the cloud system is reachable by multiple users at the same time. It can be controlled by many people at the same time. The design of the system in this way is to extract the highest levels of safety in the environment, such as environmental disasters (fires, etc.), which may arise from the main user or control element.

In order to provide the control of the water reservoirs in the TRNC region, the example scheme flow of the water reservoir operating system is explained in Figure 3.1, As seen in Figure 3.1, the Arduino is circulated in the water tank, then the data is transferred via the internet (modem) and the information is transmitted through the android program on the users' phones.

Figure 3.1: Water storage system

22

In Figure 3.2: the fire pool operating system is described by the example scheme flow. As you can see on the picture, the data from the fire pool thanks to the depot and arduino cycle, the internet information with the help of the Wi-Fi sensor, and afterwards the information can be reached through the android program on the users' phones.

Figure 3.2: Fire pool working system

23

System operations Flow Chat and Illustration

Database

Cloud

Real Time

Arduino Critical Minumum

Minumum level critical level Minimum Water level Double =%20

Mobile

Maximum water level Double =%90 Open water Close water

Sensors : moisture,water level,temperature, internet

Current water level

Minumum Maximum current m current NO NO water level water level

Max critical level Max critical level

YES YES

Figure 3.3: Flow Chart of Application Simple Module

24

3.1.3 Materials and Programs Used in the Lower System of Our System

It is possible to write applications using different programs. We have created the software in our project by using different sources. We have created the software in our project by using different sources. Thanks to the ai2.appinventor program we could easily work with our examples and work, so we preferred to work on it. The program is running online and you can sample it through many ready-made templates. The desired android programs can be written on the program supported by the training videos.

Figure 3.4: Android user screen

Figure 3.4 shows the application screen of the android application that will be used to access information for the user in our work. The user can conveniently view the desired operation and use the desired information with this application.

3.2 Materials used in electronic infrastructure of the timeshare

ATmega328 Microcontroller Our Arduino Nano card, which is used in our work, is manufactured by the Atmel Company. The ATmega328 (on the 3.X version cards) or the ATmega168 (on the 2.X version cards) are small development cards that plug into the breadboards. Although it appears as an Arduino Uno card development card in the shape, the

25

Arduino Nano card has an integrated look. The Arduino Nano card is similar in character to Arduino Uno features. There is a mini USB entry on the Arduino Nano card. With this input, we can program and perform serial communication. In Figure 3.5 below, we can look at the front view and back view of the Arduino Nano card(Tudor,et al., 2015).

Figure 3.5: View of the front and back of the Arduino Nano card

Microcontroller ATmega328 Nano card; The FTDI FT232 USB-serial converter must be installed in order to be able to download programs and provide computer communication. Figure 3.6 below shows the ATmega 328 pin diagram in detail(Tudor,et al., 2015).

Figure 3.6: Atmega 328 pin diagram

The ATmega we use in our work is faster than other traditional microcontrollers because the program and the data can be accessed at the same time. Other features of Arduino Nano ATmega328 are shown in detail in Table 3.1(Wilcher, 2012).

26

Tablo 3.1: General Features of Arduino Nano ATmega328 Micro Controller

High performance Microcontroller, low power spending 8 bit RISC processor, 131 units assembly commends,generally single cycle. 32 units 8 bitlik general recorder Full static operation support Wroking speed max20 MHZ 32 KB Flash Memory, 1 KB EEPROM, 2 KB internal static RAM, Flash memory read/write number: 10.000 (ten thousand), EEPROM read/write number: 100.000 (a hunderd thousand), Data recording time: in 85 temperature, 20years,in 25 temperature, 100 years, 2 units 8 bit counter/timer, 1 unit 16 bit counter/timer, 6 units 10 bit ADC, Programmable sequence USART, SPI connection support, I2C connection support, Programmable Watchdog Timer, Internal and external interrupiton properties, Stand-by mode and when signal entering, properties of wake up, 23 unitsprogrammable input/output ports, Supply, between 1.8V and 5.5V, Working between In -40 degree and +85 degree,

27

3.3 Arduino Nano

Figure 3.7: Arduino Nano ATmega 328 Pin Diagram

3.3.1 Power

Arduino Nano requires a USB or external power supply when the power supply is running. The input voltage limits for the external power supply must be between 6 and 20 volts. But the recommended level is between 7 and 12 volts. Because the external power supply may not operate regularly under 7 volts. VIN is used as the voltage input pin between 7-12V. GND pins are used for ground pins(Hughes J, 2016).

3.3.2 Inputs and outputs

Arduino Nano microcontroller has 14 digital input / output pin, 6 of them are used as PWM output. The input codes of pins are used as PinMode (PinNo, INPUT) and the output codes are as PinMode (PinNo, OUTPUT); and digitalRed. Pins work with + 5V. Apart from these pins, there are also some special function pins. (Hughes J, 2016).

Serial Communication, 0 (RX) and 1 (TX) Pin: Serial communication pin TTL serial receive data (receive-RX) and transmit data (transmit-TX).

• External Interrupt, 2 (Interrupt 0) and 3 (Interrupt 1) Pin: The cylinder that triggers the ability to perform the interrupt.

• PWM Pin: It cannot reach to voltage voltages using PWM pin (5/256 Volt). PWM can be used as an output pin with 8 bit resolution.

28

• SPI 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK) Pin: These pins provide the SPI communication and access to the library.

• LED 13: This pin is used to connect to digital Led 13. It goes on when the value is high (High) and goes out when it is low (Low).

• Analog Pin: Used as input pin. It is preceded by the letter A (such as A0, A1 ...). These pins communicate with the intended sensors.

• TWI: uses A5 or SCL and A4 or SDA pin Wire library to provide TWI communication.

• Analog Reference (AREF): Analog input is used as the reference voltage. This is to ensure that our pinpoint precision analogue measurements can be accurately measured. It is used as function analog Reference ().

• Reset: Arduino and the codes we have installed reboot when the reset button is pressed.

• VIN Pin: Voltage input pin from 7-12V to which we connect the external power supply.

• GND Pin: Grounding pins that provide neutralization on the card.

• 5V: This pin output from regulator gives 5V output. If only a card working via usb 5V, it gives 5V value from USB directly as output from this pin. However, simultaneous entry with a 5V pin is possible. If power is supplied to the board via VIN (7-12V), the 5V output from the regulator is output directly from this pin. It can output maximum 450mA as output pin.

• 3.3V: The output pin of the regulator on the Arduino nano card is 3.3V. It can give maximum 50mA as output pin.

3.3.3 Arduino Nano Memory

The Arduino Nano ATMega328 type microcontroller has 32 KB of flash memory. However, it can use 30 KB of memory. The remaining 2 KB of memory is used by the bootloader. There is also 2KB SRAM and 1KB EEPROM memory area(Success, 2016).

29

3.4 Heat Sensor

We preferred a sensor that is capable of digital temperature measurements. Since this sensor is also a feature that has digital data transmission, it can perform in many temperature measurements in different ways over a single line. Figure 3.8: The temperature sensor and diagram are shown in detail(Varcha et al., 2012).

Figure 3.8: Heat Sensor and its Diagram

3.4.1 Features

 It can communicate over a single line using the interface with the microcontroller.  Each device has 64 bits of serial code, which is specified and unique in ROM memory during production. This code communicates with multiple devices over the same line.  No external hardware is required.  The supply voltage can be supplied via the data line (the voltage value is between 3.0V and 5.5V)  Temperature gradients ranging from -49 ° C to +126 ° C may be measured.  Sensitivity to -8 ° C to +84 ° C is ± 0.5 ° C.  Has user defined sensitivity between 9-12 bits.  Conversion of the temperature value to a 12-bit code is a maximum of 750ms.  User has defined and permanent alarm setting.

30

 Have 8-pin SO (150 mil), 8-pin _SOP, and 3-pin TO-92 package types as shown(Resolution, 2008).

The DS18B20 is a 12-bit temperature sensor that uses the 1Wire protocol. Because of the need for only one port to communicate, it is an advanced temperature sensor that can be used in many applications with low energy requirement and high resolution. Each DS18B20 integration has a unique serial code of 48 bits (8 bit CRC code + 48 bit serial number + 8 bit family code), which is determined during production and stored in the ROM memory. This makes it possible to communicate with multiple DS18B20 integrations on the same line (Gökcegöz, 2011).

3.5 Relay

An electromagnetic system is a switch that is used to provide electrical control over the circuit. It is an element operated by the electromagnet to operate a high-power receiver (load) with a low-value current passing through the relay. As long as there is no load on the relay, it is passive. The relays are also capable of operating with both the AC and DC voltage types. Relays with multiple contact structures in a single device can simultaneously open and close multiple loads simultaneously. Thanks to these features, the relays are more advantageous than thyristors and triacs. The disadvantage of the relays is that they can frequently break down because they are working mechanically. It needs to be able to operate with an effect (magnetic field, current, voltage, temperature, etc.) in areas where relay circuits cannot enter. Figure 3.9: Arduino relay picture is visible(Electroblogs, 2011).

Figure 3.9: Arduino Relay

31

3.6 Ultrasonic Sensors

Figure 3.10 :View of the front and back of the Hc-rs04 ultrasonic card

It is one of the most common sensor types used with Arduino. Ultrasonic sound waves can be measured by sensors. It consists of a receiver and a transmitter. Ultrasonic sound waves have sound waves that the human ear cannot hear. It is defined as sound waves ranging from 20 Khz to 1 Ghz. In our work, we will use ultrasonic sensor Hc-rs04 ultrasonic sound wave at the frequency of 40 Khz produces. These sensors cause the ultrasonic sound wave generated by the trig pin to be emitted at a frequency of 40 Khz. The emitted sound waves are multiplied by any object and the sensor returns, in which case the echo pie is activated. This time the time between the two signals is calculated and the distance from the cismin sensor is found. Figure 3.10 shows the measurement of fluid with Arduino Hc-RS04 ultrasonic sensor.

Figure 3.11: Water storage and fire pool

32

3.7 Wi-Fi esp8266

An electronic wireless communication chip that communicates with wireless electronic devices using the TCP / IP internet protocol, performs programming for individual unique uses, and houses microprocessors. The Wi-Fi module receives its own private IP as any device connected to the network after joining the internet network.

Figure 3.12: Arduino 5 Wi-Fi esp8266

With this feature, we can send signals to this device wirelessly from the local area. If you want to control this device from anywhere connected to the internet then we can do it by making the necessary prompts. Figure 3.12 shows Arduino Wi-Fi 5 esp8266(Başer, 2015).

3.8 Solar panel

On solar panels, an energy source, there are many solar cells that absorb solar energy. Solar panels are a kind of system that converts sunlight into electricity. When sunlight falls on working panels, direct current begins to be produced in the panel. Solar energy panels are connected in series or parallel according to the preferred power. Where there is a need the panels can meet all your electricity needs. The energy of a solar cell is measured by its efficiency. The solar panels change their direction according to the seasons, allowing for adequate yield in all seasons.

33

Figure 3.13: Solar Panel

In places where there is no electricity, it is widely used in fields where there is a lot of sunlight and in feeding of electronic materials in fields and mountainous areas. Figure 3.6: There is a solar panel(Duffie and Beckman, 1974).

3.9 Battery

It is a device that stores electrical energy by converting it into chemical energy. The energy that the device stores chemically can be converted back to electricity when it is connected to any electrical circuit(Website Upset, 2015).

Figure 3.14: Battery

34

CHAPTER 4 DESIGNED DEVICE CIRCUIT INFORMATION

4.1 Overview

In the current project, we have been able to access remote fire pool data and intervene in the system. We have designed our design so that it can be integrated into older systems, taking into account the old devices. The system has 2 remote controls. It is the screen that the device entered by the service officer primarily in setting parameters and remote fault interventions. The other is the screen where the parameter controls set by the user are made. The control checks the staff parameters from here. In the system, the temperature sensor and the humidity sensor enable the physical quantities to be converted into signals and to be monitored from far away points. You also have information about the environmental conditions in the environment. This information can assist in the analysis of different areas or intervention times and planning arrangements at the point of implementation. The planning process emerges as a result of prepared and planned data analyses, without being aware of the situations to be addressed when the area to be reached and the places to be visited are known, and providing assistance and facilities for a better, prepared and easily accessible team.

4.2 Working Principle

The system at work can be operated from mains voltage or 9-volt sources. The voltage from the supply source together with the voltage integrals on the Arduino Nano card makes the necessary voltage adjustments for the cycling operating conditions. In this way, our processor is working stably with the required voltage. Thanks to the Wi-Fi module we have added to our Arduino mega card, it can be connected to the internet internally wirelessly and has the ability to control it online. This gives us the ability to access and control information remotely. Thanks to the heat sensor which is used at times, the temperature values in the fire pools are taken and the effect of the water inside the fire pools can be monitored from the weather conditions.

Thanks to the humidity sensor, it senses the humidity in the environment and thus provides humidity control in the environment.

35

Measurements of all parameters have the ability to control another module. The average value of the received heat can be monitored from the internet. For example, when a sensor fails, the device automatically interrogates the failed sensor and records the time of the last received data. Then, thanks to the non-renewable temperature watch, it helps to understand whether it is defective or not. As a result, we can find out whether the electronics and plug-ins of the cycle are working. According to this result, a preliminary feasibility is achieved in order to get ready in case of a failure in case of any failure, and important information is obtained in order to be able to take precautions focused on the solution. Controlling large loads for environmental controls that may be needed in fire pools with rollover rolls is possible. Thanks to these roles, remote access is provided to enable and accommodate many of the required system controls. The materials used in the timescale system allow for long time usage with the battery. Our materials with low power consumption and low operating voltages are offered for use with a small solar panel for many years to work. This ensures that we are constantly aware of remote-centered fire pools and that we can easily plan by conducting a pre-feasibility study of environmental issues.

Modular Circuit Diagram Impressions

Figure 4.1 : Online Role Control Module

36

Figure 4.2 : Online Temperature Meter Module

Figure 4.3 : Online ultra sensor module

The system at the time of departure first checks the internet connection after opening in basic order. Then he makes the internet connection and transfers the data from the sensors connected to the circuit to the cloud and then inquires if there are any commands from the find. By comparing the sensor information transmitted to the cloud with the information set by the user, it can check the alarm conditions and inform the user accordingly.

As mentioned in the circuit diagram, the necessary connections have been made. The Rx and tx ends of the Esp8266 Wi-Fi sensor are connected to the d10 and d11 pins to communicate with the Arduino Nano. The reason for this is that the PC control is then designed to be used separately at the Rx and tx ends of the Arduino nanowire at the required moments. Thanks to the setting made in the program, digital pins are defined for communication with wifi and it is

37 left idle so that the reading and writing unit of the army can use it at the same time. The heat sensor uses a digital sensor and is connected to one of the set digital pins and the temperature values of the environment are read by the necessary algorithm. Moreover, thanks to the float, which is placed at the level of the depot, a diagram has been created to perceive the changes at that level. The data received from these sensors are on-line for device controls (on-off) which may be needed later. With relays, it is possible to cut off or switch on the power of more powerful devices. The relays connected to the Arduino operate independently of the received sensor data and can be controlled by anyone authorized to program the phone.

The feedback feature of the relays makes information conversion about the controlled device.

By means of this distorted sensor data, a recognized mechanism can be deactivated and a mechanism can be introduced again. In order to reduce the costs and prevent the growth of this damage, it is also possible to control the mechanics instead of the human power by opening the remotely opened mechanics at certain times. People can benefit from time, labor, money, security in difficult conditions. Generally speaking, if we were to talk about the operation of the cycle, every five seconds after the necessary settings were turned on, an internet connection is being questioned. On this page, we can observe whether or not the internet connection is disconnected with the program on the phone. As long as our device is not corrupted or the internet connection is not broken, the internet connection control data is sent and the operation data can be checked at this address. Once the internet connection is complete, the connected sensor data is processed and checked with the sequence. You can see the sensor data transferred to the cloud by our phone.

The greatest development in our timeshare is that we have measured values from the circuits as anticipation. In the past, the systems measured within themselves and controlled the alarm levels and provided alarms through the algorithm in it. The requested changes can only be made through the device and the device must be serviced on-site or moved to the manufacturer's office. In order to remove this problem, all the algorithms in the circuit were removed from the center and only the sensor data was edited to retrieve the sensor information, and only the transferred data was recorded. Later, the data obtained from the bullet was processed in an online environment and continuously monitored. Once the alarm levels have been adjusted as desired, the data is then stored in the cloud. At the same time, different alarm levels and information retrieval procedures of different users were established. The alarm is activated or deactivated to allow the user to choose whether to receive an alarm

38 or to view the alarm at any time. In contrast to the old systems, the notification sound of the phone is made by a method which is consistently provided with the repetition until Facebook, WhatsApp is canceled after the sample is taken after the sample is taken.

In order to connect to the Internet, we connect to the network where the WiFi sensor which is located in the circulation from the phone is created. Thanks to this connection, we can write our username and password in the wireless network wirelessly. Later, when the battery is turned off and the battery is plugged again, the username and password that we wrote in the cycle are automatically set and the wireless network is connected. Once connected to the network, it is now possible to make sensor evaluations based on Arduino sensor data. The subsequent set of data is transferred to the cloud environment prepared for transfer to all users. The solar power is supplied by solar energy from the battery and it is possible to expand the usage area with its low power consumption and offer great facilities. With low power consumption, the sensor data to be received from the environment can be improved day by day. One of the main purposes of the design is that it is suitable for every situation and the communication techniques can be renewed. In this way, the user can receive notifications independently of each other and set their own alarm levels at the same time. Thanks to its unique adjustable sensor levels, it can make user sequences. In addition, because all the data are recorded in the database as hours and dates, historical situation evaluation and analysis can be performed.

39

CHAPTER 5 CONCLUSION

The circuit is aware that the fire pools built to protect nature are at maximum level when needed. In this way, we are continuously informed about the fire pools that are far away and the necessary institutions can make plans according to this information. The evolving technology adds to our ability to remotely control and receive data from our systems every day. This is why we have been using the sensors for the transmission and transport of the sensors to the Internet. This provides a profit in labor, time and finance to the institutions. Besides, it can be improved if it has a suitable infrastructure for control structures that can be added on.

Our circuit provides continuous control for a better life and provides a new perspective on environmentalism by providing information on forest fires and environmental conditions.

Its Advantages

 Looking at past products sms was used. In our time, there is direct communication over the Internet.  Instead of paying for each Sms, you can pay the lowest price and make process on the internet.  Notifications are not charged separately, and the number of users placed on the on this number is reported in the most appropriate conditions.  Unlimited users can be defined at the same time in our system.  And each user can set their own alarm levels.  In the old system, the sms were automatically picked up by the alarms in the alarm system.  In our system, the number of users is the same, so the control capability is increased.  Each individual has an sms and the data is under the control of the data base.  By this way, backward information can be checked and analysis can be made.  The user can turn off this alarm after the alarm has been received if they want.  The Sms are designed on a perpetual basis and they ring as long as the alarm is active.

40

REFERENCES

Evans, M., Noble, J. J., & Hochenbaum, J. (2013). Arduino in action. Manning.

Oxer, J., & Blemings, H. (2011). Practical Arduino: cool projects for open source hardware. Apress.

Badamasi, Y. A. (2014, September). The working principle of an Arduino. In Electronics, Computer and Computation (ICECCO), 2014 11th International Conference on (pp. 1-4). IEEE.

Margolis, M. (2011). Arduino cookbook. " O'Reilly Media, Inc.".

Barrett, S. F. (2013). Arduino Microcontroller Processing for Everyone!. Synthesis Lectures on Digital Circuits and Systems, 8(4), 1-513.

Bayle, J. (2013). C programming for Arduino. Packt Publishing Ltd.

Evans, B. (2011). Beginning Arduino Programming. Apress.

Nguyen, V. (2014). Implementation of Linux GPIO Device Driver on Raspberry Pi Platform.

Ramakrishnan, A., & Conrad, J. M. (2011, March). Analysis of floating point operations in microcontrollers. In Southeastcon, 2011 Proceedings of IEEE (pp. 97-100). IEEE.

Molisch, A. F. (2012). Wireless communications (Vol. 34). John Wiley & Sons.

Urien, P. (2011, January). Convergent identity: Seamless OpenID services for 3G dongles using SSL enabled USIM smart cards. In Consumer Communications and Networking Conference (CCNC), 2011 IEEE (pp. 830-831). IEEE.

Wang, L., Von Laszewski, G., Younge, A., He, X., Kunze, M., Tao, J., & Fu, C. (2010). Cloud computing: a perspective study. New Generation Computing, 28(2), 137-146.

41

Tudor, D., Dobrescu, L., & Dobrescu, D. (2015, November). Ultrasonic electronic system for blind people navigation. In E-Health and Bioengineering Conference (EHB), 2015 (pp. 1-4). IEEE.

Vařacha, P., Mastorakis, N., Jašek, R., Pospíšilík, M., Chramcov, B., & Sámek, D. (2012). Technical Devices for Supervising of a Household via Interned Based on Arduino Microcontroller. In 12th WSEAS International conference on Applied Informatics and Communications, Istanbul, Turkey.

Wheat, D. (2012). Arduino internals. Apress.

Maxim Integrated, D. Programmable Resolution 1-Wire Digital Thermometer, Datasheet.

Warren, J. D., Adams, J., & Molle, H. (2011). Arduino for robotics. In Arduino robotics (pp.51-82). Apress.

Nakamura, K. (Ed.). (2012). Ultrasonic transducers: Materials and design for sensors, actuators and medical applications. Elsevier.

Ram, K. S. S., & Gupta, A. N. P. S. IoT based Data Logger System for weather monitoring using Wireless sensor networks.

Hughes, J. M. (2016). Arduino: A Technical Reference: A Handbook for Technicians, Engineers, and Makers. " O'Reilly Media, Inc.".

Başarslan, M. S., Kayaalp, F., & Çelik, F. (2016). Kısa Mesafe RF Algılayıcı ile Telemetri Uygulaması. Düzce Üniversitesi Bilim ve Teknoloji Dergisi, 4(2), 727-733.

Fidan, U., & Karasekreter, N. (2011). Realized and Application of GSM/SMS-based Automated Irrigation Control Unit. New World Sciences Academy, 6, 71-77.

Çakır, A., & Çalış, H. (2007). Uzaktan Kontrollü Otomatik Sulama Sistemi Tasarımı ve Uygulaması. SDÜ Fen Bilimleri Enstitüsü Dergisi, 11(3) 258-261.

42

Adiyan, A. (2012). Sıvı seviye kontrolü için scada sistem tasarımı (Doctoral dissertation, DEÜ Fen Bilimleri Enstitüsü).

Özden, S., & Dursun, M. (2010). Radyo Frekansı ile Düşük Maliyetli Su Seviyesi Kontrolü. Politeknik Dergisi, 13(4), 313-317.

Altın, S., & Bulut, F. (2016). Bluetooth Bağlantılı Ultrasonik Sıvı Seviyesi Ölçer Tasarımı ve Endüstriyel Proses Uygulamaları. Mühendislik ve Teknoloji Bilimleri Dergisi, 4(1), 19-21.

Korkmaz, Y., & Korkmaz, F. (2007). Elektrikli Cihazlar ve Güvenlik Sistemlerinin Cep Telefonu ile Uzaktan Denetlenmesi. Politeknik Dergisi, 10(1), 15-19.

Arduino (2016 ). Arduino Products , Retrieved December 26, 2016 from https://www.arduino.cc/en/Main/Products

Developers, A. (2011). What is Android, Retrieved December 26, 2016 from http://sites.google.com/site/amitsahain/Andoid--tech.pdf

Duffie, J. A., & Beckman, W. A. (1974). Solar energy thermal processes. University of Wisconsin-Madison, Solar Energy Laboratory, Madison, WI.

Programmable Resolution (2015 ). Maximintegrated , Retrieved December 26, 2016 from http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

Katırcıoğlu, İ., & Sefer, C. (2005). Sıvı Tanklarda Seviye Kontrol Sistemi. İstanbul Üniversitesi.

Duffie, J. A., & Beckman, W. A. (1974). Solar energy thermal processes. University of Wisconsin-Madison, Solar Energy Laboratory, Madison, WI.

Upset (2015 September 28 ). How the battery works, Retrieved January 26, 2016 from https://upset.com.tr/aku-nedir-ve-nasil-calisir/

43

Feher, K. (2011). U.S. Patent No. 7,904,041. Washington, DC: U.S. Patent and Trademark Office.

Hughes, J. M. (2016). Arduino: A Technical Reference: A Handbook for Technicians, Engineers, and Makers. " O'Reilly Media, Inc.".

Resolution, D. P. (2008). 1-Wire Digital Thermometer Data Sheet. Maxim integrated, USA.

Wilcher, D. (2012). Learn electronics with Arduino. Apress.

Susanto, H., Pramana, R., & Mujahidin, M. (2011). Perancangan Sistem Telemetri Wireless Untuk Mengukur Suhu Dan Kelembaban Berbasis Arduino Uno R3 Atmega328p Dan Xbee Pr. Universitas Maritim Raja Ali Haji.

44

APPENDICES

45

APPENDIX 1 HARDWARE COMPOUND

Figure A: Hardware System

Figure B: Application

46

APPENDIX 2 SOURCE CODES

#include

#include

// Include the libraries we need

#include

#include

// Data wire is plugged into port 2 on the Arduino

#define ONE_WIRE_BUS 9

#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)

OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.

DallasTemperature sensors(&oneWire);

// Start up the library

// arrays to hold device addresses

DeviceAddress dolap1, dolap2, dolap3, dolap4, dolap5;

// Include the libraries we need

#define DST_IP "

Servo myservo; // create servo object to control a servo

// a maximum of eight servo objects can be created int servpin = A2; // SERVO OUTPUT

47

String response;

String cmd; int f = 0, pos, b = 0, right = 0, left = 0, pusulaWifi = 0, donWifi, aciWifi, mesafeWifi;

#define DEBUG true

#define SSID "Ozturkarge" //name of wireless access point to connect to

#define PASS "stabilite00" //wifi password

//#define SSID "VINNWiFi_E948BA" //name of wireless access point to connect to

//#define PASS "GJMULJJJ5G" //wifi password

SoftwareSerial esp8266(10, 11); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.

// This means that you need to connect the TX line from the esp to the Arduino's pin 2

// and the RX line from the esp to the Arduino's pin 3 int connectionId; int netIhd; float alan1, alan2, alan3, alan4, alan5; float alan1last, alan2last, alan3last, alan4last, alan5last; void setup()

{

pinMode(13, OUTPUT);

//pinMode(12, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

48 pinMode(9, OUTPUT); digitalWrite(9, LOW); digitalWrite(9, HIGH); digitalWrite(13, LOW); myservo.attach(servpin); // attaches the servo on pin 9 to the servo object myservo.write(0); // tell servo to go to position in variable 'pos'

Serial.begin(115200); esp8266.begin(9600); // your esp's baud rate might be different

Serial.println("Dallas Temperature IC Control Library ");

// Start up the library sensors.begin();

// locate devices on the bus

Serial.print("Locating devices...");

Serial.print("Found ");

Serial.print(sensors.getDeviceCount(), DEC);

Serial.println(" devices.");

// report parasite power requirements

Serial.print("Parasite power is: "); if (sensors.isParasitePowerMode()) Serial.println("ON"); else Serial.println("OFF");

// method 1: by index if (!sensors.getAddress(dolap1, 1)) Serial.println("Unable to find address for Device 0"); if (!sensors.getAddress(dolap2, 2)) Serial.println("Unable to find address for Device 1");

49 if (!sensors.getAddress(dolap3, 3)) Serial.println("Unable to find address for Device 2"); if (!sensors.getAddress(dolap4, 4)) Serial.println("Unable to find address for Device 3"); if (!sensors.getAddress(dolap5, 5)) Serial.println("Unable to find address for Device 4");

// set the resolution to 9 bit per device sensors.setResolution(dolap1, TEMPERATURE_PRECISION); sensors.setResolution(dolap2, TEMPERATURE_PRECISION); sensors.setResolution(dolap3, TEMPERATURE_PRECISION); sensors.setResholution(dolap4, TEMPERATURE_PRECISION); sensors.setResolution(dolap5, TEMPERATURE_PRECISION);

Serial.print("Device 0 Resolution: ");

Serial.print(sensors.getResolution(dolap1), DEC);

Serial.println();

Serial.print("Device 1 Resolution: ");

Serial.print(sensors.getResolution(dolap2), DEC);

Serial.println();

Serial.print("Device 2 Resolution: ");

Serial.print(sensors.getResolution(dolap3), DEC);

Serial.println();

Serial.print("Device Resolution: ");

Serial.print(sensors.getResolution(dolap4), DEC);

Serial.println();

Serial.print("Device 4 Resolution: ");

Serial.print(sensors.getResolution(dolap5), DEC);

50

Serial.println();

sendData("AT+RST\r\n", 2000, DEBUG); // reset module

for (int i = 0; i < 5; i++) //attempt 5 times to connect to wifi - this is a good idea

{

boolean wifi_connected = false; //not connected yet...

if (connectWiFi()) //are we connected?

{

wifi_connected = true; //yes

break; //get outta here!

}

}

sendData("AT+CWMODE=3\r\n", 1000, DEBUG); // configure as access point

sendData("AT+CIFSR\r\n", 1000, DEBUG); // get ip address

sendData("AT+CIPMUX=0\r\n", 1000, DEBUG); // configure for multiple connections

// sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // turn on server on port 80

} void loop() {

// HEAT SENSOR READ

alan1 = printTemperature(dolap1, "alan 1");

if (alan1last != alan1){

wifiKaydet(alan1, 1, 1);

}

alan2 = printTemperature(dolap2, "alan 2");

51

if (alan2last != alan2){

wifisave(alan2, 2, 1);

}

alan3 = printTemperature(dolap3, "alan 3");

if (alan3last != alan3){

wifiKaydet(alan3, 3, 1);

}

alan4 = printTemperature(dolap4, "alan 4");

if (alan4last != alan4){

wifisave(alan4, 4, 1);

}

alan5 = printTemperature(dolap5, "alan 5");

if (alan5last != alan5){

wifiKaydet(alan5, 5, 1);

}

alan1last = alan1;

alan2last = alan2;

alan3last = alan3;

alan4last = alan4;

alan5last = alan5;

delay(5000);

}

// ** Write grade

52

void wifisave (float rating grade, int sensorId, int deviceId){

cmd = "AT+CIPSTART=";

cmd += "\"TCP\",\""; //make this command: AT+CPISTART="TCP","146.227.57.195",80

cmd += DST_IP;

cmd += "\",80";

cmd += "\r\n";

sendData(cmd, 500, DEBUG);

delay(1000); //wait a little while for 'Linked' response - this makes a difference

cmd = "GET /iot/home.php?"; //construct http GET request

cmd += "grade="; //

cmd += rating grade; // grade

cmd += "&deviceId="; //

cmd += deviceId; // Device user code

cmd += "&sensorId="; //

cmd += sensorId; // sensor code

cmd += "&islemId="; //

cmd += 1; // Write code

cmd += " HTTP/1.0\r\n";

cmd += "Host: www.ozturkelektronik.com\r\n\r\n"; //test file on my web

String sr = "AT+CIPSEND=";

sr += cmd.length();

sr += "\r\n";

esp8266.print(sr); //this is our http GET request

53

if (esp8266.find(">")) //prompt offered by esp8266

{

// Serial.println("found > prompt - issuing GET request"); //a debug message

esp8266.println(cmd); //this is our http GET request

}

else

{

wifiStart();// Reset again

}

}

// wifi reset ve Reset again void wifiStart() {

sendData("AT+RST\r\n", 2000, DEBUG); // reset module

for (int i = 0; i < 5; i++) //attempt 5 times to connect to wifi - this is a good idea

{

boolean wifi_connected = false; //not connected yet...

if (connectWiFi()) //are we connected?

{

wifi_connected = true; //yes

break; //get outta here!

}

}

54

sendData("AT+CWMODE=3\r\n", 1000, DEBUG); // configure as access point

sendData("AT+CIFSR\r\n", 1000, DEBUG); // get ip address

sendData("AT+CIPMUX=0\r\n", 1000, DEBUG); // configure for multiple connections

}

// function to print a device address void printAddress(DeviceAddress deviceAddress)

{

for (uint8_t i = 0; i < 8; i++)

{

// zero pad the address if necessary

if (deviceAddress[i] < 16) Serial.print("0");

Serial.print(deviceAddress[i], HEX);

}

}

// function to print the temperature for a device float printTemperature(DeviceAddress deviceAddress, String alan)

{

sensors.requestTemperatures();

float tempC = sensors.getTempC(deviceAddress);

Serial.print("Temp C: " + alan + " :");

Serial.print(tempC);

Serial.println();

return tempC;

55

}

// function to print a device's resolution void printResolution(DeviceAddress deviceAddress)

{

Serial.print("Resolution: ");

Serial.print(sensors.getResolution(deviceAddress));

Serial.println();

}

String sendData(String command, const int timeout, boolean debug)

{

String response = "";

esp8266.print(command); // send the read character to the esp8266

long int time = millis();

while ( (time + timeout) > millis())

{

while (esp8266.available())

{

// The esp has data so display its output to the serial window

char c = esp8266.read(); // read the next character.

response += c;

}

}

if (debug)

56

{

Serial.print(response);

}

return response;

}

//------boolean connectWiFi()

{

String cmd = "AT+CWJAP=\""; // Tukcell ozturkargeElektronik stabilite00

cmd += SSID;

cmd += "\",\"";

cmd += PASS;

cmd += "\"";

esp8266.println(cmd);

delay(5000); //give it time - my access point can be very slow sometimes

if (esp8266.find("OK")) //healthy response

{

Serial.println("Connected to WiFi...");

return true;

}

else

{

Serial.println("Not connected to WiFi.");

57

return false;

}

}

------

#include

#include

Servo myservo; // create servo object to control a servo

// a maximum of eight servo objects can be created int servpin = A2; // SERVO OUTPUT int dereceLast; int f = 0, pos, b = 0, right = 0, left = 0, pusulaWifi = 0, donWifi, aciWifi, mesafeWifi; int role_onoff;

#define DEBUG true

#define SSID "*********" //name of wireless access point to connect to

#define PASS "*************" //wifi password

#define DST_IP " 62.75.212.215 " //my web site, replace with yours

SoftwareSerial esp8266(10, 11); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.

// This means that you need to connect the TX line from the esp to the Arduino's pin 2

// and the RX line from the esp to the Arduino's pin 3 int connectionId; void setup()

{

58 myservo.attach(servpin); // attaches the servo on pin 9 to the servo object myservo.write(0); // tell servo to go to position in variable 'pos'

Serial.begin(115200); esp8266.begin(9600); // your esp's baud rate might be different pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); digitalWrite(13, LOW); sendData("AT+RST\r\n", 2000, DEBUG); // reset module for (int i = 0; i < 5; i++) //attempt 5 times to connect to wifi - this is a good idea

{

boolean wifi_connected = false; //not connected yet...

if (connectWiFi()) //are we connected?

{

wifi_connected = true; //yes

break; //get outta here!

}

} sendData("AT+CWMODE=3\r\n", 1000, DEBUG); // configure as access point sendData("AT+CIFSR\r\n", 1000, DEBUG); // get ip address sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // configure for multiple connections

59

sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // turn on server on port 80

} void loop()

{

while (esp8266.available()) {

wifiRM04();

}

}

String sendData(String command, const int timeout, boolean debug)

{

String response = "";

esp8266.print(command); // send the read character to the esp8266

long int time = millis();

while ( (time + timeout) > millis())

{

while (esp8266.available())

{

// The esp has data so display its output to the serial window

char c = esp8266.read(); // read the next character.

response += c;

}

}

if (debug)

60

{

Serial.print(response);

}

return response;

}

//------boolean connectWiFi()

{

String cmd = "AT+CWJAP=\""; // [email protected]

cmd += SSID;

cmd += "\",\"";

cmd += PASS;

cmd += "\"";

esp8266.println(cmd);

delay(5000); //give it time - my access point can be very slow sometimes

if (esp8266.find("OK")) //healthy response

{

Serial.println("Connected to WiFi...");

return true;

}

else

{

Serial.println("Not connected to WiFi.");

61

return false;

}

} int connectClose(int baglanId) {

// make close command

String closeCommand = "AT+CIPCLOSE=";

closeCommand += baglanId; // append connection id

closeCommand += "\r\n";

sendData(closeCommand, 1000, DEBUG); // close connection

}

------void wifiRM04() {

boolean has_request = false;

String in = "";

if (esp8266.available()) {

in = "";

while (true) { // WIFI MEMORY ALL DATA READ

while (esp8266.available() == false) {}

in += (char)(esp8266.read());

if (in.endsWith("\r\n\r\n")) {

has_request = true; break;

}

}

62

} if (has_request) {

int aci1 = in.indexOf("GET /komut?a="), a2;

int role_1 = in.indexOf("GET /komut?role="), m2;

int role_all = in.indexOf("GET /komut?roleall="), m3;

if (aci1 != -1) {

a2 = in.indexOf(" ", aci1 + 13);

aciWifi = in.substring(aci1 + 13, a2).toInt();

}

if (role_1 != -1) {

m2 = in.indexOf(" ", role_1 + 16);

role_onoff = in.substring(role_1 + 16, m2).toInt();

}

// SERVO MOTOR DOES NOT HAVE TOGETHER IN THIS COMPONENT

if (aciWifi > 0) {

myservo.write(aciWifi); // tell servo to go to position in variable 'pos'

Serial.println(aciWifi);

}

if (role_onoff > 0) {

switch (role_onoff)

{

case 5:

digitalWrite(5, HIGH);

63

delay(20100);

digitalWrite(5, LOW);

break;

case 50:

digitalWrite(5, HIGH);

delay(22000);

digitalWrite(5, LOW);

break;

case 6:

digitalWrite(6, HIGH);

delay(24000);

digitalWrite(6, LOW);

break;

case 60:

digitalWrite(6, HIGH);

delay(7500);

digitalWrite(6, LOW);

break;

}

Serial.println(role_onoff);

64

}

aciWifi = 0;

role_onoff = 0;

has_request = false;

}

}

65