• No results found

Florida State University Libraries

N/A
N/A
Protected

Academic year: 2021

Share "Florida State University Libraries"

Copied!
76
0
0

Loading.... (view fulltext now)

Full text

(1)

Florida State University Libraries

Electronic Theses, Treatises and Dissertations The Graduate School

2017

Open-Source Low-Cost Internet of Things Platform for Buildings

Xiaorui Liu

(2)

FLORIDA STATE UNIVERSITY COLLEGE OF ENGINEERING

OPEN-SOURCE LOW-COST INTERNET OF THINGS PLATFORM FOR BUILDINGS

By XIAORUI LIU

A Thesis submitted to the

Department of Electrical and Computer Engineering in partial fulfillment of the

requirements for the degree of Master of Science

2017

(3)

Xiaorui liu defended this thesis on July 20th, 2017.

The members of the supervisory committee were:

Reza Arghandeh

Professor Directing Thesis

Simon Y. Foo Committee Member

Hui Li

Committee Member

The Graduate School has verified and approved the above-named committee members, and certifies that the thesis has been approved in accordance with university requirements.

(4)

ACKNOWLEDGMENTS

Many thanks are due to many people. My major professor didn’t know what he was getting himself into when he took me on as a student, and I will always be grateful for his support and guidance.

The other members of my committee deserve hazard pay, and this paper would not be the same without their diligence and assistant: many thanks.

(5)

TABLE OF CONTENTS

List of Tables . . . vi

List of Figures . . . vii

Abstract . . . ix

1 What is An Internet Of Things 1 1.1 The Origin Of The Internet Of Things . . . 1

1.2 The Development Of The Internet Of Things . . . 2

1.3 The Architecture Of The Internet Of Things . . . 3

1.3.1 Devices Layer . . . 3

1.3.2 Network Layer . . . 6

1.3.3 Management Layer . . . 7

1.3.4 Application Layer . . . 8

1.4 The Challenge Of The Internet Of Things . . . 9

1.4.1 Challenge 1 : Battery Requirement . . . 9

1.4.2 Challenge 2 : Sensors Requirement . . . 9

1.4.3 Challenge 3 : Security Requirement . . . 9

1.5 The Future Of The Internet Of Things . . . 10

1.5.1 Building System . . . 10

1.5.2 Healthcare . . . 10

1.5.3 Personal Uses . . . 11

1.5.4 Services . . . 11

1.5.5 Transportation . . . 11

2 Hardware for Internet of Things Platform 13 2.1 Micro-processor Development Board . . . 13

2.1.1 Raspberry Pi . . . 14

2.1.2 Arduino Uno . . . 14

2.1.3 NodeMCU . . . 15

2.2 Relevant Hardware . . . 16

2.2.1 Ethernet Shield . . . 17

2.2.2 Temperature And Humidity Sensor . . . 17

2.2.3 Light Dependent Resistor (LDR) Sensor . . . 18

2.2.4 Ultrasonic Sensor . . . 19

2.2.5 Infrared Obstacle Avoidance Sensor . . . 19

2.2.6 Passive Infrared Sensor (PIR) . . . 20

2.2.7 Sound Sensor . . . 21

2.2.8 Dust Sensor . . . 21

(6)

3 Software for Internet of Things Platform 23

3.1 Arduino IDE . . . 23

3.2 Xampp . . . 24

3.2.1 Apache . . . 25

3.2.2 HyperText Markup Language (HTML) . . . 25

3.2.3 Personal Home Page (PHP) . . . 26

3.2.4 phpMyAdmin . . . 26

3.3 MySQL . . . 28

3.4 Jupyter NoteBook . . . 31

4 Design And Demo for Internet of Things Platform 33 4.1 The Initial System . . . 33

4.1.1 Initial System Architecture . . . 33

4.1.2 Initial System Hardware Connection . . . 34

4.1.3 Initial System Software Support . . . 36

4.2 Final System . . . 37

4.2.1 Final System Architecture . . . 38

4.2.2 Final System Hardware Connection(1) . . . 38

4.2.3 Final System Hardware Connection(2) . . . 40

4.2.4 Final System Software Support . . . 41

5 Result And Future Work for Internet of Things Platform 49 5.1 Data Analysis . . . 49

5.1.1 Pearson Correlation . . . 49

5.1.2 Heat Map . . . 50

5.2 Advantage of this Internet of Things Platform . . . 52

5.2.1 Open-Source . . . 53

5.2.2 Low-Cost . . . 54

5.3 Relevant Management Applications . . . 54

5.3.1 Building Management . . . 54

5.3.2 Building Monitoring . . . 55

5.4 Future Work For The IOT System . . . 55

5.4.1 Wireless Connection Method . . . 56

5.4.2 Sensors . . . 56

5.4.3 PCB Design . . . 56

5.4.4 Web Page Design . . . 56

Appendix A Good Time Had by All 58 References . . . 63

Biographical Sketch . . . 66

(7)

LIST OF TABLES

2.1 Comparing Table for 3 Micro-controllers . . . 16

4.1 Initial System Sensors Connection . . . 34

4.2 Final System Sensors Connection 1 . . . 39

4.3 Final System Sensors Connection 2 . . . 41

5.1 Coefficient Correlation Table . . . 50

5.2 Variable Table . . . 51

(8)

LIST OF FIGURES

1.1 IOT Global Market Source: IHS [12] . . . 2

1.2 IOT Architecture Model . . . 3

1.3 RFID . . . 5

2.1 Raspberry Pi . . . 14

2.2 Arduino Uno Microcontroller . . . 15

2.3 NodeMCU . . . 16

2.4 Ethernet Shield . . . 17

2.5 DHT11 . . . 18

2.6 LDR Sensor . . . 18

2.7 Ultrasonic Sensor . . . 19

2.8 Infrared Obstacle Avoidance Sensor . . . 20

2.9 Passive Infrared Sensor . . . 20

2.10 Big Sound Sensor . . . 21

2.11 Small Sound Sensor . . . 21

2.12 Dust Sensor . . . 22

3.1 Arduino IDE . . . 24

3.2 Xampp User Interface . . . 25

3.3 phpMyAdmin User Interface . . . 26

3.4 Table Structure in phpMyAdmin . . . 27

3.5 MySQL Workbench . . . 28

3.6 All Databases In MySQL . . . 29

3.7 Create A Database In MySQL . . . 30

3.8 Create A Table In MySQL . . . 30

3.9 Connection of Jupyter Notebook and MySQL . . . 32

(9)

4.1 Initial System Architecture . . . 34

4.2 Arduino Uno Development Kit . . . 35

4.3 Initial System Hardware Connection Demo . . . 35

4.4 Mac Address Information . . . 36

4.5 Final System Architecture . . . 38

4.6 NodeMCU Development Kit . . . 39

4.7 Final System Hardware Connection Demo . . . 40

4.8 Final System Sensors Operating Principle . . . 41

4.9 IP Address Information . . . 42

4.10 Final System Web Server Home Page . . . 43

4.11 Final System Web Server Real Time Monitor Page Print Screen . . . 45

4.12 Final System Web Server Real Time Data Stream Print Screen . . . 46

4.13 Final System Web Server Real Time DHT11 Sensor Line Chart Print Screen . . . 47

4.14 Final System Web Server Real Time LDR Sensor Line Chart Print Screen . . . 48

5.1 Heat Map . . . 51

5.2 Outside-Inside Temperature Chart . . . 52

5.3 Outside-Inside Humidity Chart . . . 53

(10)

ABSTRACT

Internet of Things (IOT) systems are becoming a popular concept of every smart system. Many people intend to develop various IOT systems which could be smart socket can be controlled remotely and tracking the electricity consumption to save energy or a security system for home which combines several sensors and cover a big area.

The goal of this thesis was to introduce a method to construct an IOT system that can monitor different parameters. The design of this project also focused on wireless interaction in order to make the system more perceptual. The design of the system was modified several times which include a changing from using Ethernet to Wi-Fi. Ultimately, it provides an effective method for monitoring a building system which could be the temperature, humidity, light intensity, or the movement of objects, etc. The final design fulfills the fundamental goals and there is a visualization web page for the IOT system which both includes a real time data monitoring and a real time charting. This thesis will give a thorough overview of how to build an own IOT system.

(11)

CHAPTER 1

WHAT IS AN INTERNET OF THINGS

This chapter is an introductory section to the IOT. The history of IOT will be discussed and then the development of IOT will be illustrated that different technologies came to our daily life and they make our life easier. After that, the future of IOT will be explained, what is the development tendency and which technology is the most popular one to attract people to improve now. Finally, the notable challenges will be discussed last.

1.1 The Origin Of The Internet Of Things

Opinions of the origin of the IOT vary. There are some ideas or small projects before 1999, then the IOT concept started becoming more common in 1999, then it became popular and attract more and more people. At the beginning, the concept of the IOT included wide range like healthcare, utilities and transportation,etc [1].

An example of the first appliance was a modified Coke machine at Carnegie Mellon University which was an original fundamental IOT system in 1982 [2]. Because an expansion of the department caused some employees’ offices to be located further away from the main building where the Coke machine was located. People needed to walk further to buy a coke. If the Coke bottles had been in the machine 3 hours, the cokes would be cold. It is not hard to imagine that sometimes they would find an empty machine, and sometimes get a warm Coke. Some people wanted to devise a solution for it. They installed micro-switches in the Coke machine to sense how many bottles were present and use a server program to confirm how long the bottles had been in this machine and display the result in a screen. This result will let everyone know which Cokes are cold.

However, a real milestone in the IOT is in 1999. The term IOT was first coined by Kevin Ashton a British technology pioneer [3]. He discussed that people have limited time and attention to capture data in the real world and computers could monitor these data instead of people, using the gathered data to track, count and understand everything around us. We could also know things needed replacing, repairing or recalling. Although he mentioned this idea in last century, this idea

(12)

is also the main idea of the IOT now and we are devote ourselves to making the design of IOT systems better and better.

1.2 The Development Of The Internet Of Things

The development of the IOT has been very fast, it can remotely control the network infrastructure [4], create more opportunities for computer based systems to control the physical world, reduce the human intervention and improve the efficiency [5][6][7][8]. Now, IOT technology is encompassed in smart homes, smart grids, virtual power plants, and smart cities, etc.

The IOT has tremendous power in our life. For example, bar codes by using them we can make payments for groceries, also when we buy something from the Internet, we could use it to get the shipments’ location information [9]. IOT combines a wide variety of different sizes sensors, capa- bilities, functional hardware and supports many different kinds of applications [10]. The different applications depend on different sensors and actuators and this makes a new range of opportunities possible [11]. The number of IOT devices all over the world outnumbers the actual number of people in 2011. i.e. it achieved billion interconnected devices [1]. Figure 1.1 shows the development of the IOT in the global market in 2020 which is projected to be twice that of 2015 and by 2024, it is projected to double again.

Figure 1.1: IOT Global Market Source: IHS [12]

(13)

1.3 The Architecture Of The Internet Of Things

IOT system contains 4 parts which are application layer, management layer, network layer and devices layer. As shown in Figure 1.2, the devices are fundamental layer in the whole system foundation. Because it is foundation of the system. If this layer does not contain with appropriate components, IOT system will not work appropriately. Then the network layer makes it possible to connect these devices with the Internet. After this information is collected, filtering and analyzing the data is the function of the management layer. Once that is done, the user can use this infor- mation though their phone, laptop or other device which is the application layer. In general, the architecture of the IOT is very clear and easy, but a good product may have several demanding requirements build in to these layers.

Figure 1.2: IOT Architecture Model

1.3.1 Devices Layer

This layer includes various sensors, micro-controllers, radio frequency identification (RFID) and camera all of which play an important role in the construction of embedded systems. Embedded system are changing people’s lives, driving the development of all kinds of products. If we have a variety of embedded systems to be assistants in our life, our lives will get conveniently.

(14)

The relationship of them is not complex. For example, modern embedded systems are always based on micro-controllers. If we use the human body as a simple example to characterize an IOT system, the sensors are equivalent to the human eye, nose, skin and other sensory organs, the micro- controllers are equal to the human brain and the connecting circuits between micro-controllers and the sensors are the nervous system. After the sensory organs receive some signals, the signals will be transmitted to the brain though the nervous system. For the IOT system, sensors are responsible for collect the data, the circuit will be a connection and transmit all these data to the micro-controller and finally the micro-controller classifies and deals with it appropriately.

Sensor Technology. The main function for the sensor technology is to identify objects and collect information, and provide massive and accurate data supported for follow-up information processing and corresponding decision-making behavior, which is the basic physical network of perception, recognition and information collection in the real world.

Sensor network consist of seismic, thermal, visual, infrared, acoustic and radar, which are able to monitor a wide variety of ambient conditions including the following [13]:

• Temperature Sensor

• Water Level Sensor

• Pressure Sensor

• Smoke Sensor

• Sound Sensor

• Glucose level Sensor

• Oxygen level Sensor

Radio Frequency Identification. RFID technology is a communication technology that identi- fies a specific target by radio frequencies and reads and writes the relevant data without the need to establish a mechanical or optical contact between the system and a particular target. It generally uses 1-100 GHz wave and its suitable for 1-12 meters identification communication [14].

The RFID signal is automatically identified and tracked by adjusting the electromagnetic field to the radio frequency from the tag transfer attached to the item. Some of the tags in the electromagnetic field that are emitted from the reader can obtain energy without the need for a battery, there is

(15)

also a tag that itself has a power source and can take the initiative to emit radio waves. The tag contains information about the electronic storage that can be identified within a few meters.

The RFID technology helps us to manufacture the access card which can improve the safety of building access or egress and other application of RFID technology include identity documents, supply chains, inventory tracking, car charges, security and production control.

Figure 1.3: RFID

Micro-controller. Micro-controller Unit (MCU) is an appropriate reduction of the central pro- cessing unit (CPU) frequency and specifications, and integrated memory, timer, USB, A/D conver- sion, and other interfaces in a single chip, the formation of chip-level computer works for different applications to do different control.

Embedded System . An embedded system refers to a system which is based on computer technology and targets an application. For an IOT system, an embedded system combines sensor technology, integrated circuit technologies, electronic application technologies as one of the complex technologies. After several decades of evolution, embedded systems are characterized by intelligent terminal products everywhere.

• Small Size, Light Weight

• Safe Operation, Real-Time Operation

• Low Power Consumption

• Work In Harsh Environment

• Reliable And Low Cost

(16)

1.3.2 Network Layer

The purpose of the network layer is to realize the transparent transmission of data between the end systems. It connects every IOT part seamlessly and its responsible for delivering high speed, low loss, secure and reliable delivery of data information to the management layer while recognizing the data from the devices layer. The specific functions include addressing and routing, establishment, hold and termination of the connection. The methods always contain one of the following Wi-Fi, Bluetooth, Zigbee, or Ethernet, etc.

Wi-Fi Technology. Wi-Fi is a technology that allows electronic devices to connect to a wireless local area network (WLAN), typically using a 2.4G Ultra High Frequency (UHF) or 5G Super High Frequency (SHF) Industrial, Scientific and Medical (ISM) radio frequency band. Connecting to a WLAN is usually password protected, but it may also be open, allowing any device within the WLAN to connect, such as personal computers, smart phones, digital cameras, tablet computers, and modern printers. The range of Wi-Fi usually is inoor 20 meters and a greater range outdoors [15].

Bluetooth Technology. Bluetooth technology uses UHF radio waves in the 2.4-2.485 GHz ISM band [16] to realize a wireless technology standard that enables short range data exchange between fixed equipment, mobile devices and building personal area networks. Normally, the effective range for bluetooth is approximately 10 meters.

Zigbee Technology. Zigbee technology is based on IEEE802.15.4 standard low power Local Area Network (LAN) protocol. According to international standers, ZigBee technology is a short range, low power wireless communication technology. It is designed for work in personal areas, such as home automation and office device data collection [17]. Transmission range is generally between 10 and 100 meters. If the transmission power is increased, the transmission range can also be increased to 1-3 km.

Ethernet Technology. Ethernet technology is commonly used in LAN and Wide Area Network (WAN), which is a wire connected method [18]. Ethernet interconnects the devices at 10 to 100 Mbps, and Ethernet is the most widely and dominant used technology due to its low cost, high reliability, and 10 Mbps rate.

(17)

1.3.3 Management Layer

The management layer is the monitor of all data which displays the real time status of all embedded system. Then from the real time monitoring and analysis, all information will be displayed. Such as, the temperature is higher than the requirement, the humidity is lower or the product are sold out, etc. The data storage and data analysis will be illustrated in this subsection.

Data Storage. For the IOT data storage, it is not too hard to image how much data may be produced by a whole system. Brendan Clooins discussed that a Boeing 787 flight will collect 100GB of data per hour; An oil well will produce 1TB data every day; London Metro monitor will collect 1.5TB of data per minute. These huge data needs to be stored in a place which is safe and has large capacity. Both Solid State Drives (SSD) and Hard Disk Drives (HDD) will be required. As well as the cloud storage will be needed.

At the same time, the database is also important for IOT data. There are many types of databases, from the most simple storage of a variety data to a large numberof data in a large scale data storage system, all kinds of databases have wide applications in all aspects. There are 3 different types of databases, usually divided into hierarchical databases, network databases and relational databases.

The requirement of databases:

• Data Sharing

• Reduce The Redundancy Of Data

• Independence Of Data

• Centralized Control

• Data Security And Reliability

Data Analysis. Compare with the data collection from the hardware, data analysis or data mining is more complex. However, it is the real objective for collecting data. Even two irrelevant things will have relevant connection.

The most famous example ”beer” and ”Diaper” happend in walmart in 1990s [19]. A data Data analyst found an understandable phenomenon: in some specific cases, ”beer” and ”Diaper” two seemingly unrelated goods will often appear in the same shopping basket, the reason for this unique sales phenomenon is the mother is at home to take care of the baby, the young father went to the

(18)

supermarket to buy diapers. Father in the purchaser of diapers at the same time, often they will buy beer for their themselves, so there will be beer and diapers, two seemingly irrelevant goods, in the same shopping basket. Walmart found this unique phenomenon and began putting the beer and diapers in the same area, so that the young father could find these two goods at the same time and quickly complete the shopping and the supermarket will get more profit from this.

The story of ”beer and diapers” must have technical support. American scholar Agrawal proposed to find out the association between the goods by analyzing the collection of goods in the shopping basket and finding the customer’s buying behavior based on the relationship between the com- modities in 1993. From the perspective of mathematics and computer algorithms, he proposed a method of calculating the association of goods - Aprior algorithm. In 1990’s, Walmart attempted to use the Aprior algorithm with the shopping basket data analysis, and was successful, resulting in a ”beer and diapers” story.

From this classic case, the Knowledge Discovery in Database (KDD) provided a solution to find out the hidden information at the back of IOT which can enhance the system and give better choices [20].

1.3.4 Application Layer

Application layer to achieve the combination of technology and application of IOT, and ultimately improvements in daily life. For example, the monitoring of the transport infrastructure which decrease the traffic jams, the monitoring of the transportation processes which will protect some fragile objects or prevent objects leakage. Intelligent street light also is a kind of IOT that it can adjust according to the weather conditions, which effectively save the energy and reduce energy cost.

• Weather Station

• Smart Home

• Smart Cities

• Connected Car

(19)

1.4 The Challenge Of The Internet Of Things

The rapid development of IOT brings a large number of challenges in the hardware and in the software. More accurate hardware will be needed and software with may different capabilities will be needed which can help to collect the data or deal with the data. Living in a big data environment, the security issues will create issues. These issues will be discussed in the subsection.

1.4.1 Challenge 1 : Battery Requirement

The IOT has evolved into a vast network of may different aspects, in a wide range of applications, power consumption is one of the most important problem. In this field, many networking devices are equipped with micro-controllers, sensors, and wireless devices. Most of them need a battery to provide power. Battery installation, maintenance and repair are not only difficult, but also bring high cost, while in some workshops or factories, these operations are even very dangerous. For example, if the sensor is intended to track endangered animals, it is difficult to replace the battery after put into use. The dimensions and lifespan of the battery will be critical in such applications.

In a stationary application, a small solar panel could be combined with a battery to provide extra electricity, supplementing the wireless charging method also is feasible. Focusing on the quality of battery and extend the battery life time may be the target of study.

1.4.2 Challenge 2 : Sensors Requirement

Sensors are the cornerstones of the entire IOT system that can measure and generate. In general, sensors have 4 major components: a sensing unit, a processing unit, a transmitting/receiving unit, and a power unit [21]. A sensor can detect whether the house door is closed or not, or it could confirm if there is high concentration of CO2 in a area. The accuracy of the IOT system totally depends on the sensors. The material, size and lack of interference of them are very important which the whole system depends on. So the innovation in sensor hardware is just as important as sensor software innovation.

1.4.3 Challenge 3 : Security Requirement

With the increasing amount of personal information being included in the network, security prob- lems are emerging. For example, all the household data, vehicle data and the current location can be read and connected. A home display with IOT function does help to reduce some of the

(20)

potential exposure risks, but there is no corresponding protection measurement, there is a lot of information exposed on line, which means that serious loopholes and abuse will emerge. A high level of security will become more and more important.

The sensor network technologies will meet challenges in which information and communication systems are invisibly embedded surrounding us [22]. Especially, the security problem of Wireless Sensor Network (WSN) which is the creation of an end-to-end secure channel between remote entities [23]. After the sensor network collects the data, the privacy of this data and how to manage this data becomes important. The data centers need to enhance this technology to process efficiently and decrease the response time [24] as well as maintaining security.

1.5 The Future Of The Internet Of Things

In fact, just a few years ago, the IOT is still regarded as a fantasy which is day dream technical.

The purpose is to find the next big goal to stimulate new development projects. More and more infrastructure need IOT to implement, it is time to take a look how IOT will shape the vision of the future.

1.5.1 Building System

In the office area, the IOT system will combine with human sensing and light sensor which could take full advantage of the natural light source. The lights only turn on when the natural light is not enough. Use human induction sensing to turn off the light, Air Conditioning. If the sun light is too strong in the afternoon, the light sensors will control electric curtains turn off which prevents a high air conditioning energy consumption of high indoor temperature.

IOT based smart conference room can be set up a variety of models. To achieve a variety of intelligent managements, user-friendly, and energy saving. For example, if the conference room will be used in 3 minutes, the computers, air conditioning, and lights or curtain will automatically open, coffee machine will heat the water. After the meeting, the air conditioning, coffee machine, light or curtain will closed by the system requirement.

1.5.2 Healthcare

If the medical technology based on IOT, it will completely change the human health model. For example, the weight monitoring and recording for everyday, after the weight, all the data will

(21)

automatically record and show the variation of the value when is the highest one and when is the lowest one. Then give a health plan to the users. It is helpful for everyone keep health. Also, it works for the patients who have a chronic diseases. They will bot only receive a drug treatment and the IOT system will provide a remote monitoring, remote treatment program adjustment, lifestyle management, including the overall disease management program. The potential population, long- term measurement, the IOT can also be predicted by large data, to determine the users risk of illness and help with illness prevention.

1.5.3 Personal Uses

The small low cost embedded systems like the Beacon by Estimote [25]. They provide a series of beacon, such as location beacons, proximity beacons, sticker beacons and video beacons. They construct the sensors as Printed Circuit Board (PCB), using a button battery for power. Some of these devices are equipped with Nordic low power bluetooth board chip, temperature sensor and accelerometer. It also contains light sensor, pressure sensor, motion sensor, etc. It is tiny in size which enables a person to attach it to their cell phone.

1.5.4 Services

A supermarket without any checkout line which is new to our imagination. ’Amazon go’ is an example without cashiers or checkout lines [26]. They used the camera to recognized every customer and the item determined based on data received from a scale, pressure sensor, load cell, etc. The more technologies are combined in this system, the more accurate information will get. It is not a mature system now, if the machine cannot determine what the customer picked up from the inventory, the system will use the purchase history to analyze. The accuracy, sensitivity and number of sensors will resolve this IOT system issue soon.

1.5.5 Transportation

The autonomous vehicle is an attractive project which contains IOT technologies. Google self- driving cars have traveled 1,725,921 miles until Jun 30, 2016 [27]. The vehicles operate through cameras, radar sensors and laser range sensors to see other vehicles and use a detailed map to navigate. The vehicle are evolving the data collection and sending it to drives and upload data to the cloud, such as the location information and road conditions [28]. This information will be

(22)

helpful for all vehicles. The challenges are how to avoid any accident from the self-driving car and how to deal with the emergency accidents. Ideally,in the future, self-driving vehicles will fully realize a decrease in number and severity of accidents, traffic jams and environment contaminants.

(23)

CHAPTER 2

HARDWARE FOR INTERNET OF THINGS PLATFORM

In this chapter, it will be demonstrated that the relevant hardware to construct an IOT System contains two parts, one part describes the hardware used, such as different micro-controllers and the second part will describe relevant hardware consisting of sensor which is used along with the micro-controller to record various parameters. For example, different sensor modules, cameras, Radio-frequency identification module can be used in an IOT system.

2.1 Micro-processor Development Board

The micro-processor development board is a printed circuit board containing a micro-processor and minimal support logic. It is equivalent to a miniature computer which only lacks an input/output device. Compared with even laptop computers, a micro-processor development board is very small size, light weight and inexpensive. It is a better and more convenient choice for the application and development of uses such as smart meters, real-time industrial control, communications equipment, navigation systems, household appliances, etc.

In the electronics community, there are two popular development boards. They are Raspberry Pi and Arduino Uno. Where Arduino Uno is a micro-controller motherboard. A micro-controller is a simple computer that can run one program at a time, over and over again. It is very easy to use, it variety from Raspberry Pi, because Raspberry Pi consist of a general-purpose computer, usually with a Linux operating system, and the ability to run multiple programs.

In general, Raspberry Pi suit with a central control server, responsible for communication with the Internet, sampling and storage Arduino Uno reported status data, dealing with large amounts of data (such as audio, video, picture related). Arduino is responsible for sensor sampling, such as light intensity, temperature, human infrared sensor and so on.

(24)

2.1.1 Raspberry Pi

This product was produced by a small charity group in the UK called Raspberry Pi Foundation.

Raspberry Pi is a Linux-based hardware platform with open source. This company aims at pro- moting the teaching of basic computer science courses in schools.

The dimensions of rasberry pi are 85.60 mm 56.5 mm. It is an ARM-based microcomputer board, secure digital (SD) / MicroSD card for the memory hard drive, card board around the 1/2/4 USB interface and a 10/100 Ethernet interface (a type without network port), can be connected to a keyboard, mouse and cable, also it has a video analog signal TV output interface and an HDMI high-definition video output interface. The above components are all integrated into a board as shown in Figure 2.1. With all the basic functions of the personal computer, one only needs to turn on the monitor or screen, the keyboard and you can perform typical personal computer functions such as spreadsheets, word processing, playing games, play high-definition video and many other features.

Figure 2.1: Raspberry Pi

2.1.2 Arduino Uno

Arduino Uno was created by the Ivrea Interactive Design Institute. It is a simple tool for fast prototyping, for students, even without the background of electronic programming. After several

(25)

years of development, the Arduino Uno board was modified to accommodate new needs and chal- lenges, it accommodate the design of products for IOT applications, 3D printing and embedded environments. All Arduino Uno boards are fully open source, allowing users to build their different embedded system independently and eventually adapt to their special needs.

The Arduino Uno has a clock speed of 16 MHz, 2 KB of SRAM, 32 KB of flash storage, 14 digital input/output channels, 6 analog Input/Output channels, and it costs around $25. The Arduino Uno´s dimensions are 6.86 x 5.34 x 1.50 cms. It is depicted as shown in Figure 2.2 below. Because the Arduino Uno is very popular within the robotics and electronics community, there is ample support available for it. The Arduino Uno is a very versatile board which can be employed for a variety of applications, thus the addition of design alterations will be handled easily by the Arduino Uno.

Aside from this, the Arduino Uno has a very user friendly integrated development environment which is simple to use and contains large libraries which make the coding process smooth and efficient.

Figure 2.2: Arduino Uno Microcontroller

2.1.3 NodeMCU

NodeMCU is a further developed version of the previously mentioned micro-controller. The working principle is based on Arduino Uno and a Wi-Fi unit has been added. It is illustrated in Figure 2.3

(26)

NodeMCU Micro-controller below. The firmware of NodeMCU runs on the ESP8266 Arduino core which is a 2.4 GHz Wi-Fi chip with full TCP/IP stack and it is an open source platform for internet of things. The NodeMCU has a 128 Kbytes memory, 4Mbytes storage, 11 digital input/output channels, 1 analog input/output channel. The dimension of this board are 5.00 x 2.60 x 1.50 cms which is also smaller than Arduino Uno. The most important thing is this micro-controller is that its mature ESP8266 technology takes advantage of the abundant resources available, and also it is in common usage with other hardware.

Figure 2.3: NodeMCU

Table 2.1: Comparing Table for 3 Micro-controllers

Raspberry Pi 3 Arduino Uno R3 NodeMCU

Dimension 86.9 x 58.5 x 19.1mm 75.14 x 53.51 x 15.08mm 49 x 24.5 x 13mm Communication Method Wi-Fi/BlueTooth Ready Support Different Shields WiFi Ready

Programming Language Python C/C++ C/Lua

Price $39.95 $24.95 $8.79

2.2 Relevant Hardware

Different kinds of sensors and relevant modules will be discussed and shown in this section. Various sensors can provide diverse information. For example, GPS clock sensors which can give us all the information about the location and the time in real time, smoke sensor generally is a security device which can help to detect the a fire or a person smoking in a non-smoking area.

(27)

Using these different sensors, Wi-Fi or Ethernet shield which can help to connect Arduino Uno to the internet wirelessly, the IOT can be used for remotely identifying, locating, tracking and monitoring a wide variety of parameters. Information can also be exchanged and communicated due to their connection with the micro-controller. Ethernet shield is a important relevant hardware which can enable the sensors to transmit data to another server.

2.2.1 Ethernet Shield

The Ethernet shield was selected because of its simple and easy connection of each pin with Arduino Uno. The Ethernet shield allows the Arduino Uno board to connect to the internet. The ethernet shield is based on the wiznet w5100 ethernet chip. The wiznet w5100 provides a network stack capable of both Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) . It supports up to four simultaneous socket connections. The Ethernet library must be downloaded to the Arduino Uno. It is illustrated in Figure 2.4.

Figure 2.4: Ethernet Shield

2.2.2 Temperature And Humidity Sensor

Digital temperature and humidity can be detected using a digital humidity and temperature (DHT11) sensor. DHT11 sensors are small in size, with dimensions of 15.50 x 12.00 x 5.50 mm, have low power requirements, and have a signal transmission distance of up to 20 meters. As seen in Figure 2.5, they have a 4-pin single row pin package including the input power pin (VCC), signal

(28)

pin (DATA), not connect pin(NC) and negative power pin (GND). The DHT11 needs a 5 volt power supply, it has separate digital outputs for temperature and humidity. It works in the temperature range of 0 to 50 centigrade with an error margin of 2 centigrade and 20-80% humidity readings with 5 percent accuracy.

Figure 2.5: DHT11

2.2.3 Light Dependent Resistor (LDR) Sensor

The second type of sensor is LDR sensor which is a semiconductor photosensitive device. In the harsh environment of a high temperatures, and humidity, it maintains a high degree of stability and reliability. When the sensor is irradiated by light, the resistance value will decrease quickly, whereas if the location becomes dark, the resistance value will increase quickly; in other words, the resistance is inversely proportional to the amount of light sensed. It has 3-pin single row pin package which includes an input power pin (+5V), a signal pin (DATA) and a negative power pin (GND) as illustrated in Figure 2.6.

Figure 2.6: LDR Sensor

(29)

2.2.4 Ultrasonic Sensor

The ultrasonic sensor measures the distance to an object by converting AC power to ultrasonic waves and emitting these waves. The waves are then reflected off an object and the sensor uses the time it takes for the echo to return to determine the distance of the object. Ultrasonic sensors lack interference issues from the sun when being used outdoors and they have a good sensing range. The Parallax PING Ultrasonic sensor seen in Figure 2.7, has a range between 2 and 300 centimeters with an accuracy of +/- 0.5 centimeters. It has one input power pin (VCC), a negative power pin (GND), a trigger pin(TRIG) and an echo pin(ECHO) which respectively work for emitting signals and receiving signals.

Figure 2.7: Ultrasonic Sensor

2.2.5 Infrared Obstacle Avoidance Sensor

An Obstacle Avoidance Sensor uses the infrared reflection principle to detect obstacles. When there is no object in front, the infrared receiver will not receive signals; when there is an object in front of it, the object will block and reflect infrared light, then the infrared receiver will receive signals. The sensitivity of this sensor is high. In theory, it has a detection range of 0 to 5 meters when the sensor works in a proper environment. However, it is easily affected by other visible light which will make the effective range decreased. As seen in Figure 2.8, it has a 3-pin single row pin package including the input power pin (VCC), negative power pin(GND) and signal pin (OUT).

The Operating voltage range of this sensor is 3.3 V - 5V volt.

(30)

Figure 2.8: Infrared Obstacle Avoidance Sensor

2.2.6 Passive Infrared Sensor (PIR)

PIR sensor runs 5V - 12V power which support digital signal. The sensing range is 7 meters and 60 degree detection pattern. In fact, it is a motion sensor which can detect all the actions from any object. If it detects something, the output of it will be 1, otherwise it will show 0. It has two slots inside, each slot is made of a special material that is sensitive to infrared. When the sensor is idle, both slots detect the same amount of infrared, the ambient amount radiated from surrounding light. When a warm object passes by, it first interrupts one half of sensor which causes a positive change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These changing pulses are what is detected. As seen in Figure 2.9, it has a 3 pin single row pin package including the input power pin (VCC), signal pin (OUT) and negative power signal (GND).

Figure 2.9: Passive Infrared Sensor

(31)

2.2.7 Sound Sensor

There are two kinds of sound sensor, one is big sound sensor and another is small sound sensor.

They are focus on different sound intensity. There is a sound set points adjust button on the sensor.

When less sensitive, it takes more sound to trigger the device, when more sensitive, it takes less sound to trigger the device. As shown in Figure 2.10 and Figure 2.11, it has 4 pins which include analog signal pin (A0), negative power signal (G), power pin (+), and digital signal pin (D0).

Figure 2.10: Big Sound Sensor

Figure 2.11: Small Sound Sensor

2.2.8 Dust Sensor

The dust sensor work for detecting the dust particle concentration in air. It commonly used as a air quality sensor to monitor the percentage pf PM 2.5 in the air. An infrared light LED and a photo-sensor are optically arranged in the device. The photo-sensor detects the reflected IR LED light by dust particles in air. As shown in Figure 2.12, it has 5 pins which include ground pin (GND), power pin (VCC), signal output pin 1 (P1), signal output pin 2 (P2), and digital pins 0 (RX).

(32)

Figure 2.12: Dust Sensor

(33)

CHAPTER 3

SOFTWARE FOR INTERNET OF THINGS PLATFORM

In this chapter, the relevant software to construct an IOT System and how to combine the hardware section with the software effectively will be discussed. The software includes the Arduino IDE, Xampp, MySQL (database), Jupyter notebook, etc. Although the hardware is the basis for an IOT system, the software is essential, the software provided the communication with the hardware. For the micro-controller, a programming software is necessary. If data will be collected, a database is indispensable. After receiving the data, data analysis is the next steps enabled the data to be used.

3.1 Arduino IDE

The open-source Arduino Software (IDE) makes the code writing and uploading to the board very easy. It runs on Windows, Mac OS X, and Linux system. IDE is a physical computing platform which implements the Processing or Wiring language that based on a simple I/O board and a development environment. IDE can be used to develop independently interactive objects or it can be connected to software on a computer. As long as one writes the program code in the IDE and uploads the program to the Arduino Uno circuit board, the program tells the Arduino Uno circuit board what to do. The coding language for Arduino Uno refers to the Arduino core library file provides a variety of application programming interface(API) and C or C++. A sample is attached below. The Arduino Uno user interface in Figure 3.1 shown below.

pinMode(4,OUTPUT);//The Pin 4 for the output mode

digitalWrite(4,HIGH);// Pin 4 output high level digital signal int pirValue=0; //

const int trigPin = 5;

const int echoPin = 4;

long duration, distance;

(34)

Figure 3.1: Arduino IDE

3.2 Xampp

Xampp is a powerful tool to integrated varies software package. It can be installed on Windows, Linux, Solaris, Mac OS X and other operating systems. Xampp just needs to download, unzip and it can start being used. It contains Apache distributions for MySQL, PHP and Perl. These details of software and the function of it will be discussed in a subsection of this chapter. Xampp is very easy to use. The only thing to connect all of this software is to open Xampp control Panel and start ”Apache” and ”MySQL”, in the meantime the confirmation of their specific port should be available then Apache, MySQL and PHP will be connected. The default port for Apache is port 80 and port 3306 is default port for MySQL. The Xampp user interface in Figure 3.2 shown below.

(35)

Figure 3.2: Xampp User Interface

3.2.1 Apache

Apache is an open source web server for the Apache Software Foundation that runs on most computer operating systems because of its multi-platform and security being widely used and is the most popular Web server software one. It is fast, reliable and can be compiled with simple API extensions to compile Perl or Python interpreters into the server.

3.2.2 HyperText Markup Language (HTML)

Hypertext Markup Language (HTML) is a tool for constructing a web page interface. ”Hypertext”

means that the page can contain pictures, links, and even music, programs and other non-text elements. The structure of the hypertext markup language includes the ”head” section, and the

”main body” section, where the ”head” section provides information about the web page, and the

”body” section provides the specific content of the web page.

(36)

3.2.3 Personal Home Page (PHP)

PHP is a generic open source scripting language. Grammar has absorbed the C language, Java and Perl features, widely used, mainly applicable to the field of Web development. It can perform dynamic web pages faster than others. PHP is made with the dynamic page and embedded in the HTML document to implement a efficiency and proven web pages. PHP will be used to generate a site home page. When a visitor opens the home page, the server executes the PHP command and sends the execution result to the visitor’s browser.

3.2.4 phpMyAdmin

phpMyAdmin is a free software tool written in PHP and it depends on Web-Base architecture as MySQL database management tools in web pages, so that the MySQL database can be managed using the web interface. This web interface can be a better way to enter complex SQL syntax in a simple way, especially to handle the import and export of large amounts of data. One of the bigger advantages is that phpMyAdmin is executed on the web server as with other PHP program, furthermore these programs remotely manage the MySQL database for easy creation, modification, and deletion database and data sheet. But also phpMyAdmin established commonly used php syntax, easy to write the required SQL grammar when the page is correct.

Figure 3.3: phpMyAdmin User Interface

(37)

In the subsection, phpMyAdmin will be used as a example to demonstrate how to build a database.

Firstly, open the Uniform Resource Locator (URL) 127.0.0.1 which is Xampp’s dashboard, click the phpMyAdmin. The dashboard is in the Figure 3.3 as shown below. Secondly, click the ”NEW”

to create a new database (For example, IOT). Choose a database name (For example, sensors) and press ”create”. Then, create a user who will have access to the database. Press ”Add user” and enter a username and a password for the user who will have access to the database. The final step is writing SQL language to add all variable names in the database.

CREATE TABLE ’IOT’.’sensors1’ (

’id’ INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

’vdate’ TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

’temperature’ VARCHAR( 11 ) NOT NULL

’humidity’ VARCHAR( 11 ) NOT NULL

’photoresistor’ VARCHAR( 11 ) NOT NULL )

After creating the schema ”IOT” and the table sensor1, the architecture of this database shown below in Figure 3.4. For data type, the most important is request an auto increment type, and for time type use timestamp.

Figure 3.4: Table Structure in phpMyAdmin

(38)

3.3 MySQL

MySQL is a relational database management system, developed by the Swedish company MySQL AB, is currently owned by Oracle’s products. MySQL is one of the most popular database man- agement systems. In the web application, MySQL is the best Relational Database Management System. Unlike other databases, relational databases store the data in a different table, rather than putting all the data in a large table, which increases the speed and improves flexibility. The SQL language which uses MySQL, is the most commonly used standardized language for access- ing databases. MySQL software because of its small size, high processing speed, low total cost of ownership, and open source, give it excellent performance. If it worked with PHP and Apache it would be a good development environment.

Figure 3.5: MySQL Workbench

The MySQL workbench, shown below in Figure 3.5. It is very clear to show all the schemas, tables and every variable in the table. It can be used to create a database, but the major function for this

(39)

tool is database visualization and management. In this part, MySQL will be the second example to show how to build a database. First, open the MySQL command line client. The first step is to confirm which default databases are already in MySQL, write ”show databases;” into the command line, seen in Figure 3.6 below. It will list all databases stored in MySQL. Besides the databases listed, other names can be used as name for databases. Then to create a database write ”create database sensor data;” in the command line, sensor data is a example name for database. The process and result shown below in Figure 3.7.

Figure 3.6: All Databases In MySQL

After this step, the database will be created in MySQL, then the table will need to be created. Before creating a table, the database needs to be chosen. Using ”use sensor data;” to select sensor data, it means the table will be created in this database. The following sentences are appropriate code for the above process. ”create table dataset (id INT NOT NULL AUTO INCREMENT PRIMARY KEY, vdate TIMESTAMP NOT NULL DEFAULT CURRENT TIMESTAMP, temperature VAR- CHAR( 11 ) NOT NULL, humidity VARCHAR( 11 ) NOT NULL, photoresistor VARCHAR( 11 )

(40)

Figure 3.7: Create A Database In MySQL

NOT NULL);” will be used for create a table. Finally, using ”show columns from dataset;” to list everything in this table. The result shown in the below Figure 3.8. Any change in the command line client, will result in appropriate change in the workbench.

Figure 3.8: Create A Table In MySQL

(41)

3.4 Jupyter NoteBook

As a data analysis software, Jupyter’s name is the combination of Julia, Python and R language.

It means it combines all these different coding languages in it, but now it is a Multi-Language and supports far more than three. The advantages of Jupyter Notebook are that it is easy to share, it unpacks to running the code and it is clear user interface.

Using Jupyter NoteBook, the data analysis is very easy and the data visualization is excellent. The first step is to connect with MySQL. Importing several packages and also using the information in the database, the connection will be finished, the code attached below and the result in Figure 3.9.

import pymysql import pandas as pd

import matplotlib.pyplot as plt import numpy as np

import seaborn as sns

%matplotlib inline

conn = pymysql.connect(host=’localhost’, port=3306, user=’root’, passwd=’’, db=’test’) //The information of database "test";

cur = conn.cursor()

cur.execute("SELECT time, temperature FROM sensor") print(cur.description)

for row in cur:

print(row)

#cur.close()

#conn.close()

(42)

Figure 3.9: Connection of Jupyter Notebook and MySQL

(43)

CHAPTER 4

DESIGN AND DEMO FOR INTERNET OF THINGS PLATFORM

This chapter describes all the experiments required to construct this IOT system. All the hardware parts in chapter 2 and software parts in chapter 3 are discussed here. This chapter begins with the initial system for this IOT which had some disadvantages; therefore, the improved version. The second part, describes the final system. Also, the final system dashboard, monitor web page and whole platform has been described and illustrated in this chapter.

4.1 The Initial System

The Arduino Uno can collect and display a wide variety of data from various sensors, the first step of real value comes from monitoring the data over the network. In the initial system the basic requirement is to receive the real time data from the sensors. The initial system was built using Ethernet Shield and a combination of different sensors.

4.1.1 Initial System Architecture

As seen in the flow chart, Figure 4.1 below, the complete IOT system comprises of an Arduino Uno, DHT11 sensor, LDR sensor, a power supply, and Ethernet shield. The Arduino Uno is intended to run the sensor program that directs the sensors to detect relevant data and send it back to the laptop screen with the help of Arduino IDE software. If a wireless connection is needed, an Ethernet board is used in this system.

In order to accomplish this, a power supply is connected to the Arduino Uno. The power supply may either be a battery or a USB power adapter. An Ethernet shield should be connected with an Ethernet port by an Ethernet cable. The system is designed so that when a code is programmed into the Arduino Uno, data is obtained from the sensors, followed by the Ethernet board requesting the data be sent to the web server, after the web server receives the data, it displays the real time

(44)

data on the web page and then transfers the data to the MySQL database via the Xampp software.

Thereby, the data will automatically be stored in the database.

Figure 4.1: Initial System Architecture

4.1.2 Initial System Hardware Connection

The connection and wiring for the DHT11 and the LDR sensor can be seen in Table 4.1. Figure 4.2 shows all the pin functions of Arduino Uno. The digital input/output pin 2 of Arduino Uno is connected to the signal pin of the DHT11 sensor. The LDR sensor is an analog sensor, therefore the analog input/output pin A0 of the Arduino Uno is connected to the signal pin of the LDR sensor module. Through the signal pin, both the DHT11 module and the LDR sensor module can act as either a slave receiver or a slave host, transmitting to and receiving data from the micro-controller.

The 3.3v output from the Arduino Uno is connected to the photo resistor sensor 3.3v input and DHT11 3.3v input, supplying both modules with the required power. Finally, the Arduino Unos ground pin is connected to the LDR sensor and the DHT11 ground pins.

Table 4.1: Initial System Sensors Connection Arduino Uno Input/Output Pin Function

Analog Pin A0 LDR Sensor Input Digital Pin 2 DHT11 Sensor Input Ground Pin Negative Power Pin 5V Power Source Pin

(45)

Figure 4.2: Arduino Uno Development Kit

All the pins in the Arduino Uno and Ethernet board are connected in a one to one correspondence.

Once the Ethernet shield is plugged into the Arduino Uno board, the connection will be finished.

The initial system shown in Figure 4.3 below.

Figure 4.3: Initial System Hardware Connection Demo

(46)

4.1.3 Initial System Software Support

The mac address was determined in order to use an Ethernet shield. mac address is received by typing ”getmac” in Command Prompt window. The resulting address is shown below Figure 4.4.

The physical Address displayed was also used while programming.

Figure 4.4: Mac Address Information

byte mac[] = { 0xF4, 0x8C, 0x50, 0x01, 0x48, 0xD9 };//Mac Address IPAddress server(146,201,69,217); //Ip address for server

IPAddress ip(146,201,69,215);//web page IP Address

Broadcasting data over a dedicated web page on the network is helpful for monitoring live data which is very clear and easy. Getting historic information in this way will also be easy. After capturing multiple parameters it is very convenient to check them on the web page and connecting this web page with the database will make the data store directly in the database.

After all the connections between the hardware modules are made, the first step is to open Xampp control Panel and start ”Apache” and ”MySQL”, then the MySQL will be connected with php- MyAdmin. The second step is to build a database for the data. After finishing the connections with MySQL, building the database either in MySQL or phpMyAdmin works well.

After completing the basic settings of the database, PHP file and HTTP request will be needed as the method to get data from Arduino Uno to the database. All these files need to be saved under the htdocs a folder in Xampp.

The first PHP file works for writing data directly into the database from the web page. It includes

(47)

$dbconnection =

mysqli_connect("p:localhost","root","","test");

// Database connection Server: localhost Username:root Password:NULL Database:test

$dbselect = mysqli_select_db($dbconnection, "test");

// Select database ’test’

$sql="INSERT INTO test.sensors(temperature) VALUES(’".$_GET["temperature"]."’)";

//Insert temperature value in sensors table

This PHP file works for displaying the data which is received from these sensors and a 2 seconds refresh is required. This is for the data visualization. The result will be shown in Figure

$result = mysqli_query($con,’SELECT * FROM sensors ORDER BY id DESC’);

while($row = mysqli_fetch_array($result)) {

echo "<tr>";

echo "<td>" . $row[’id’] . "</td>";

echo "<td>" . $row[’vdate’] . "</td>";

echo "<td>" . $row[’temperature’] . "</td>";

echo "</tr>";

}

mysqli_close($con);

4.2 Final System

The Final system varies from the original design due to a change in the selection of the micro- controller. Since the Ethernet shield depends on an Ethernet port, it has more limitations than the Wi-Fi shield. The goal is to minimize the interactions between the system components and find a convenient way to eliminate the need for an Ethernet port. When this is accomplished, it can be put in any location with or without an Ethernet port.

(48)

4.2.1 Final System Architecture

The revised system is composed of a NodeMCU, various sensors, a power supply, and a WiFi Router. The NodeMCU is intended to run the sensors program, but it is now based on the Wi-Fi.

The power supply requirement does not change. The WiFi router is a networking device that enables creation of a Wireless environment. The NodeMCU and laptop were connected though the same router implying that they work under the same network. The final system flow chart with the complete system components can be seen in Figure 4.5.

Figure 4.5: Final System Architecture

4.2.2 Final System Hardware Connection(1)

The wiring and connection for sensors and the NodeMCU can be seen in Figure 4.6. Analog input output pin A0 of the NodeMCU is connected to the signal pin of the LDR module, the Digital input output pin 2 of the NodeMCU is connected to the signal pin of the DHT11 module and the digital input output pin1 of the NodeMCU is connected to the signal pin of the motion sensor.

Through this signal pin, all sensors can transmit data and receive instructions from the NodeMCU.

The 3.3v output from the NodeMCU is connected to the input of all sensors, supplying the three

(49)

modules with power. Finally, the NodeMCUs ground is connected to the ground pin of all sensors.

The NodeMCU and its pin table can be seen in Table 4.2.

Figure 4.6: NodeMCU Development Kit

Table 4.2: Final System Sensors Connection 1

NodeMCU Input/Output Pin Function

Analog Pin A0 Light Dependent Resistor Sensor Input

Digital Pin D2 DHT11 Sensor Input

Ground Pin Negative Power Pin

5V Power Source Pin

After the confirmation of all pins, the pin table will be used in the code to define which pin connects with which sensor:

const int DHTPin = 4; // DHT sensor pin D2=4 (See the pin table) DHT dht(DHTPin, DHTTYPE);// Add a library for DHT11

float temperature = 0; // At the beginning,temperaturevalue =0 float humidity = 0; // At the beginning, humidity value =0 int photocellPin = A0; // Light sensor pin Analog A0

(50)

int photocellReading = 0; // At the beginning, light Sensor value =0

For this connection, the Ethernet shield is not required. The final system shown in the Figure 4.7 below.

Figure 4.7: Final System Hardware Connection Demo

4.2.3 Final System Hardware Connection(2)

Except the DHT11 and LDR sensor, the infrared sensor is also required for counting number of people in a building. It is an important parameter for building the system which helps to analyze the relevant relation. Also, it helps with the energy saving and lower power consumption.

int IR1Pin = 12; // Input for infrared sensor 1 int IR2Pin=14; // Input for infrared sensor 2

pinMode(IR1Pin, INPUT);// Read infrared sensor 1 Pin pinMode(IR2Pin, INPUT);// Read infrared sensor 2 Pin

(51)

Table 4.3: Final System Sensors Connection 2 NodeMCU Input/Output Pin Function

Digital Pin D5 Infrared Sensor 1 Input Digital Pin D6 Infrared Sensor 2 Input Ground Pin Negative Power Pin 5V Power Source Pin

As shown below in the Figure 4.8, there are two infrared sensors A and B, that connects with NodeMCU digital pin. If infrared B detects signals and at the same time infrared A does not detect any signal implies a person entering the building and therefore the system automatically adds one.

Else if, infrared A detects signals, at the same time B does not detect any signal indicates a person exiting the building and hence the system automatically subtracts one. By using this method, the number of visitors can be roughly calculated.

Figure 4.8: Final System Sensors Operating Principle

4.2.4 Final System Software Support

The network IP address was determined and then the Command Prompt in Windows was entered and ”ipconfig” was written in the command line to require the IP address. The output will show the address of the network. Below Figure 4.9, it showed the resulting IP address. After finding the wireless local area network(LAN) adapter Wi-Fi on the display, and then the IPV4 address is the networks IP for this computer. This address will be used in the programming code.

(52)

const char* ssid = "NETGEAR18"; /The Username of router

const char* password = "password1225";/The Password of router const char* host = "192.168.1.8";/IP Address

Figure 4.9: IP Address Information

Real time data are required in the monitor, the easiest way to obtain the real time data to request a refresh from the web page. After the request, this web page will find the relevant code file and run it again each time. The monitoring web page receive data every 3 seconds. Every time the database will receive new data, the record in the database will renew.

refresh code

$url=$_SERVER[’REQUEST_URI’];

header("Refresh: 3; URL=$url");

// Refresh the webpage every 3 seconds

All of this steps above are finished, when the browser is opened and the IP address of the laptop is entered (in this case 192.168.1.8), this web page as a result will refresh every 3 seconds with all the sensor data. The web page shown below in Figure 4.10.

In the final system, old PHP files also work and added a real time visualization part. This basic idea for this visualization chart is connection the google chart with the database.

(53)

Figure 4.10: Final System Web Server Home Page

$table = array();

$table[’cols’] = array(

array(’label’ => ’Startup’, ’type’ => ’string’), array(’label’ => ’Users1’, ’type’ => ’number’), );

$rows = array();

while($r = mysqli_fetch_array($result)) {

$temp = array();

// the following line will be used to slice the Pie chart

$temp[] = array(’v’ => (string) $r[’vdate’]);

// Values of each slice

$temp[] = array(’v’ => (int) $r[’temperature’]);

$rows[] = array(’c’ => $temp);

}

$table[’rows’] = $rows;

$jsonTable = json_encode($table);

(54)

function drawChart() {

var data = new google.visualization.DataTable(<?=$jsonTable?>);

var options = { title: ’’,

hAxis: {title: ’Time’},

vAxis: {title: ’Temperature’}, legend: ’1’

};

In Figure 4.11, it shows three different sensor chart from the sensor station which includes temper- ature, humidity, and light intensity. It is very convenient to monitor all of this data in one chart which can decrease the time to find out if there is something wrong. At the same time, a data value of the sensor can be find in web page as well which shown in Figure 4.12. But the value between light intensity and the temperature is large. The separate chart also available and click the left side hyper-link which connect with their own chart which will easy to get all the value and every point in a specific time. In Figure 4.13 and Figure 4.14 show the temperature and light sensor in real time independently. In the chart X-axis always is time and Y-axis is the value of the sensor.

Because the value between light intensity and the temperature.

(55)
(56)
(57)
(58)
(59)

CHAPTER 5

RESULT AND FUTURE WORK FOR INTERNET OF THINGS PLATFORM

5.1 Data Analysis

This part includes the results of the sensors data which collect by the IOT system in chapter 4.

The main purpose is to interlink different factory of the environment.

5.1.1 Pearson Correlation

According to a serial of relevant idea by Francis Galton,Karl Pearson came up the pearson corre- lation in the 1880s [29][30][31]. Pearson correlation is a measure of the linear correlation between two variables. The formula to calculate Pearson correlation is

ρX,Y = cov(X,Y )σ

XσY

cov is the covariance. Covariance is a measure of the joint variability of two random variables [32].

E[X] is expected value of X which equal to mean of X.

cov(X, Y ) = E(X − E[X])(Y − E[Y ]) = E XY ] − E[X] E[Y ]

σX is the standard deviation of X , σY is the standard deviation of Y. The stander deviation use to quantify the amount of dispersion of a set of data values [33]. It is the arithmetic square root of the variance which reflects the degree of discretization of a data set.

σX =pE[X2] − (E[X])2

In the formula, X and Y are the two variables. After the calculation, the result value should between +1 and -1, where 1 is total positive linear correlation, 0 is no linear correlation, and -1 is total negative linear correlation. The coefficient closer to the 1 ot -1 means they are strong correlation.

If the coefficient equal to 0, that means the two variables are not linear correlation, they may have other curve correlation. The detail can be find in the table 5.1.

(60)

Table 5.1: Coefficient Correlation Table Pearson coefficient Correlation

0.6-1.0 Strong correlation 0.4-0.6 Moderate correlation 0.0-0.4 Weak correlation

0.0 Unrelated

-0.4 - 0.0 Weak correlation -0.6 - -0.4 Moderate correlation -1 - -0.6 Strong correlation

5.1.2 Heat Map

Through using the Pearson correlation to analysis the data, the result can be seen in Figure 5.1 heat map which is a graphical representation of data where the individual values contained in a matrix are represented as colors. In the picture, the deep color means the two variables have weak correlation, the light color means the two variables have strong correlation.

In the picture, the lightest color area is in the inside humidity and outside humidity area. It means they have strong relationship, the outside humidity changing will result in a inside humidity changing and then inside temperature and humidity have a moderate correlation as well as the outside humidity and the outside temperature.

The inside light intensity gives a reference to these inside parameters. In the daytime, people in the building system will use light to work, the light must be stronger than the evening, the temperature in the daytime also will be higher than the evening, the humidity has the same changing tendency as the temperature. That is the reason most areas for the light intensity are in light color which means a strong correlation with other variables.

However, the inside temperature and the outside humidity are in a deep red area as well as the inside humidity and the outside temperature, the relationship are not obvious, even no relation.

The reason may be is the data size is too small, only one week data be adopted in this analysis or the occasionally data missing. Based on these problems, the requirement of the system need to be a persistent reliable system.

In Figure 5.2, it shown the outside temperature in yellow color and inside temperature in blue color. The variation of the temperature outside is repeating by one day, their is a big gap between

(61)

Figure 5.1: Heat Map

Table 5.2: Variable Table

Name In Heat Map Meaning

Temp Inside temperature Hygrometer Outside Humidity Photoresistor Inside light Intensity Humidity Inside Humidity Temperature Outside temperature

(62)

Figure 5.2: Outside-Inside Temperature Chart

the highest temperature and the lowest temperature. For the inside temperature, it basically stable with 20 centigrade.

In Figure 5.3, it shown the outside humidity in blue color and inside temperature in yellow color.

The variation of the humidity outside repeating as the outside temperature which will get the peak value in the afternoon, lowest value in the evening and a big gap between the highest and the lowest value. For the inside humidity, it changed in a small range and kept a stable value in 40.

5.2 Advantage of this Internet of Things Platform

An increasing of platforms and applications of IOT in the global IOT market and they are not mature enough which do not have a specific protocol for every IOT product. In this situation, the improving system function is the first step and then the combination of these advantage is the second step. After all, the protocol or requirement for every IOT products will be clear. For this system which introduce in this thesis. It has two big advantage which are open-source and low cost. The details will be discussed in the subsection.

References

Related documents