You are on page 1of 86

DESIGN AND IMPLEMENTATION

OF TEMPERATURE AND HUMIDITY MONITORING SYSTEM


FOR HIGH PERFORMANCE SERVERS ROOM
UNIVERSITY OF KHARTOUM

By
ABADI HAIDER MOHAMMED AHMED
INDEX NO.124061

Supervisor
Dr.Samah Mohamed Hashim

A REPORT SUBMITTED TO
University Of Khartoum
In partial fulfillment for the degree of
B.Sc. (HONS) Electrical and Electronics Engineering
(ELECTRONIC AND COMPUTER SYSTEMS)
Faculty of Engineering
Department of Electrical and Electronics Engineering
October 2017
DECLARATION OF ORGINALITY

I declare this report entitled “Design and Implementation of Temperature and


Humidity Monitoring System for High Performance Servers Room” is my own
work except as cited in references. The report has been not acceptedfor any degree
and it is not being submitted currently in candidature for any degree or other
reward.

Signature:_____________________

Name:________________________

Date:

i
ACKNOWLEDGEMENT
Huge efforts were made to achieve the objectives of this project. All gratitude and thanks goes to
Dr.Samah Mohammed Hashim for her valuable and decisive decisions and knowledge.

Huge thanks and admiration to engineer Mohammed Abdallah Mohammaed Al Wali for providing and
teaching us all the necessary knowledge we need to design our system on a printed board circuit and
giving us accessibility to advanced machines to design the printed board circuit.

Thanks to engineer Fath Al Rahman for helping us in finalizing and implementing the printed board
circuit.

Thanks to teacher Muhannad for his great knowledge to achieve this project.
DEDICATION
I dedicate this project to my family for their endless support and motivation throughout my life. I
thanks all my colleagues and friends for sticking with me until the end of this project.
Abstract
Servers are used in organizations for storing and securing important data and providing a connection
inside the organization (network). These data should be kept safe and accessed, therefore the safety of
servers is essential for an organization to fulfill its goals and objectives.

The Information Technology and Network Administration has servers that provide all important data and
network distribution inside the University of Khartoum. The servers are in rooms where they should be
kept in continuous observation and monitoring for keeping them safe and functional. Therefore, the
Information Technology and Network Administration requested a design of a temperature and humidity
system for the servers.

The goal of this project is to implement the temperature and humidity system that will perform the
observation and monitoring of the servers in the rooms, as well as sending alert messages to a specified
phone number when the temperature and humidity exceed certain values that might affect and damage the
servers. Another objective is to design a graphical user interface to give a user the control and accessibility
to change the settings of the temperature and humidity sensor by entering the values that might damage the
sensor and the desired phone number.

The temperature and humidity system was implemented on a Printed Circuit Board (PCB). The system
gave results when compared with other systems that measure temperature and humidity and gave a good
accuracy.
Vj A^u/Jl( A J^JJ JL^Jl jjijjj AAL^JI L/iLijJl UJLAIJJ UJ^^JJ ^i AJ^J^J

.I^JIJI^J /^iljAl AA^AAJI .^0^1 ^jjj^^ j^l AA^^ Uli ^J/JJ/JJ t/^jJl Jj‘^j!lj AAAI ^/J/JJJI O^A

J^.JJ AJL j^Jl A^AI^ J^IJ LijliYl A£J^JI ^OJJJ AAI^JI ^lil^l jijJ AJlj^ L^JJJ L/AJ^^I A£J^J Ai/oj Sjljl

Sjlj] LJJL t^J^J .^lil^l AJSIJ^^AJ /^ij/^j ^ijl J^UU SJAJUA AjSljA L^J UJ^J U' ^*.~V ^i ^jlj^Sl

^jlj^li AjjLjJlj Sjlj^Jl A^jjJ j^l A/^A 1 L L/ AjJ* A\1 A^J^Jj

Ailfll

^i ^jl^^Jl J^^jJj ^iljJ O’ l £ ‘-^j^ UA ^jJl AjjLjJlj Sjlj^Jl A^jjJ jLx/2^l ^l^i AJA,jA ^jj^^Jl 11A UA i iJgJl ^Jc. jJjJ J3 A

AJ* A AJS AjjLjJlj Sjlj^Jl A^jj ^j^H IAJJC. JJ^A U/A A^j ^Jl Jj/^j J/^jl ^J^£j ti jAl A^jJ Lljlj^l ^i jJJ*JJljA^^JJl UA

AJAJ^AJ! U^AJ jjjjjAj^Jl ^Jc. jl A^lj AJA,-^J I^JI HJAYI ^^.^jlj^Jl


.^jlkJi i aJigii A^j JUJ Ji Ait^y/j , jl* /ij^vi j^J JS ^JJI AJOJI J/^J] AjjLjJij Sjij^Ji

j/*/^Vl ^Jc. Jj^^^Jl AJ .AC.JJLAJ1 jJljjJl A^JJ Ajj^jJlj Sjlj^Jl A^jj A/^A AJ

.AJJJOA A9JJ 0j/^ LL^IJ jLx/2^l Sj^^.1 UA AijUJl ^jjL


TABLE OF CONTENTS

I. DECLARATION OF ORGINALITY........................................................................................................................ I

II. ACKNOWLEDGEMENT....................................................................................................................................... II

III. DEDICATION...................................................................................................................................................... III

IV. ABSTRACT......................................................................................................................................................... IV
V. V

TABLE OF CONTENTS................................................................................................................................................ VI

VI. LIST OF FIGURES............................................................................................................................................... X

VII. LIST OF TABLES......................................................................................................................................... XIII

VIII. LIST OF SYMBOLS..................................................................................................................................... XIV

X. LIST OF ABBREVIATIONS............................................................................................................................... XV

1 CHAPTER 1: INTRODUCTION............................................................................................................................ 1
1.1 Overview...................................................................................................................................................................... 1

1.2 Problem Statement...................................................................................................................................................... 1

1.3 Objectives.................................................................................................................................................................... 1

1.4 Methodology................................................................................................................................................................ 1

1.5 Thesis Layout.............................................................................................................................................................. 2


2 CHAPTER 2: LITERATURE REVIEW..................................................................................................................3

2.1 Introduction................................................................................................................................................................. 3
2.2 Background and Motivation....................................................................................................................................... 3

2.3 Embedded Systems.................................................................................................................................................... 4

2.4 Temperature Sensors.................................................................................................................................................. 5


2.4.1 Types of Temperature Sensors........................................................................................................................... 6

2.5 Humidity Sensors........................................................................................................................................................ 8

2.5.1 Types of Humidity Sensors................................................................................................................................ 8

2.6 DHT11 Sensor.............................................................................................................................................................. 9

2.7 Microcontrollers........................................................................................................................................................ 10
2.7.1 The PIC18F4550............................................................................................................................................... 11

2.8 Global System for Mobile ........................................................................................................................................ 12

2.8.1 AT commands ................................................................................................................................................. 12

2.8.2 SIM800............................................................................................................................................................. 12

2.9 Printed Circuit Board ............................................................................................................................................... 13

2.10 Universal Serial Bus............................................................................................................................................ 14

2.10.1 Human Interface Device ............................................................................................................................ 15

3 CHAPTER 3: DESIGN AND IMPLEMENTATION..............................................................................................16

3.1 Overview ................................................................................................................................................................... 16

3.2 Design Considerations ............................................................................................................................................ 16

3.3 System Requirements ............................................................................................................................................. 16

3.4 Hardware Components ........................................................................................................................................... 16


3.4.1 PIC18f4550 ..................................................................................................................................................... 17

3.4.2 DHT11 Sensor..................................................................................................................................................19

3.4.3 SIM800 GSM Shield........................................................................................................................................ 20


3.4.4 Other Hardware Components ..........................................................................................................................22

3.5 Software tools............................................................................................................................................................ 23

3.6 Design and Implementation Process........................................................................................................................ 23

3.6.1 Temperature and Humidity Module.................................................................................................................24

3.6.2 GSM Communication Module ........................................................................................................................28

3.6.3 Configuration GUI module...............................................................................................................................30

3.6.4 Combining the Modules................................................................................................................................... 35

3.7 Problems Faced During Design and Implementation Process............................................................................... 41

3.7.1 Limited Supply of Components........................................................................................................................41

3.7.2 DC supply mismatch........................................................................................................................................41

3.7.3 Unavailability of Solder Mask..........................................................................................................................41

3.7.4 Track Width Consideration .............................................................................................................................42

4 CHAPTER 4: RESULTS AND DISCUSSION.....................................................................................................43

4.1 End Result.................................................................................................................................................................. 43

4.2 Benchmarking........................................................................................................................................................... 45

4.2.1 Temperature Measurement ..............................................................................................................................45

4.2.2 Humidity Measurement.................................................................................................................................... 50

5 CHAPTER 5: CONCLUSIONS AND FUTURE WORK...................................................................................51

5.1 Conclusion ............................................................................................................................................................... 51

5.2 Future Work................................................................................................................................................................ 51


5.2.1 Implementing a Graphical LCD.......................................................................................................................51

5.2.2 Providing System Logs.....................................................................................................................................51

5.2.3 Improving the Configuration Graphical User Interface....................................................................................51

5.2.4 Development of a smart battery management module.....................................................................................52

6 REFERENCES.................................................................................................................................................... 53
LIST OF FIGURES
Figure 2.1 : Classification of Embedded systems......................................................................4

Figure 2.2 : A NTC Thermistor..................................................Error! Bookmark not defined.

Figure 2.3 : A RTD........................................................................................................................7

Figure 2.4 : K Type Thermocouple..............................................................................................7

Figure 2.5: Capacitive Humidity Sensor.....................................................................................8

Figure 2.6 : Resistive Humidity Sensor.......................................................................................9

Figure 2.7: Thermal Humidity Sensor........................................................................................9

Figure 2.8 : DHT11 Sensor.........................................................................................................10

Figure 2.9 : PIC18F4550 Pinout.................................................................................................11

Figure 2.10 : SIM800.................................................................................................................. 13

Figure 2.11 : A sample of PCBs..................................................................................................14

Figure 2.12 : USB Standards......................................................................................................15

Figure 3.1 : Block Diagram of the system.................................................................................17

Figure 3.2: UNVSIM800 development board top side view....................................................20

Figure 3.3 : UNVSIM800 development board bottom side view............................................21

Figure 3.4 : Block diagram for Temperature and Humidity Module....................................24

Figure 3.5 : Temperature and Humidity Module Flowchart..................................................25

Figure 3.6 : Simulation of the Temperature and Humidity Module......................................26

Figure 3.7 : Actual Operation of the Temperature and Humidity Module...........................27

Figure 3.8 : GSM Module Block Diagram................................................................................28

Figure 3.9 : Flowchart of the GSM module..............................................................................28

Figure 3.10 : Simulation of the GSM Module...........................................................................29


Figure 3.12 : Actual Result of the GSM module.......................................................................30

Figure 3.13 : USB Device Enumerations in Simulation...........................................................31

Figure 3.14: PIC18F4550 is identified as HID device..............................................................31

Figure 3.15 : PIC18F4550 USB RAM memory........................................................................32

Figure 3.16 : User Configuration GUI.......................................................................................33

Figure 3.17: USB Configuration GUI Module Test.................................................................34

Figure 3.18 : USB Configuration GUI Module Test................................................................34

Figure 3. 19: Complete System Schematic...............................................................................35

Figure 3.20 : PCB layout.............................................................................................................36

Figure 3.21 : PCB Layout...........................................................................................................36

Figure 3.22 : PCB Fabrication...................................................................................................37

Figure 3.23 : PCB Fabrication...................................................................................................38

Figure 3.24 : PCB Fabrication...................................................................................................39

Figure 3.25: PCB Fabrication....................................................................................................39

Figure 3.26 : Soldered PCB........................................................................................................40

Figure 3.27 : Soldered PCB........................................................................................................40

Figure 3.28 : failed soldering of the PCB..................................................................................41

Figure 4.1 : Complete System Testing board............................................................................43

Figure 4.2 : Operation of the Test Board..................................................................................44

Figure 4.3 : Complete System as a PCB Board........................................................................44

Figure 4.4 : PCB Board with programmer...............................................................................45


Figure 4.5 :Thermotron Chamber with DHT11 sensor inside...............................................46
Figure 4.6 : Thermotron Control Pad......................................................................................46

Figure 4.7 : Analog Temperature meter reading (Anymetre)................................................47

Figure 4.8 : DHT11 Sensor Reading.........................................................................................47

Figure 4.9 : Thermometer..........................................................................................................49


LIST OF TABLES
Table 3.1 : Microcontrollers Comparsion................................................................................18

Table 3.2 : Sensors Comparison................................................................................................19

Table 3. 3 : UNVSIM800 Board Pinout....................................................................................21

Table 3.4 : Other Required Components.................................................................................22

Table 3.5 : Temperature and Humidity Module pinout.........................................................26

Table 4.1 : Table of Measurements...........................................................................................48

Table 4.2 : Sensor Measurements.............................................................................................49

Table 4.3 : Comparison of 2 DHT11 Sensors...........................................................................50


LIST OF SYMBOLS

x
i
v
C LIST OF Celsius
ABBREVIATIONS
V Volt

A Ampere

mA MiliAmpere

Hz ESD ElectrostaticHertz
Discharge

ASHRAE The American Society


K Kilo of Heating,

Refrigerating and Air-Conditioning


pF Pico Farad
Engineers
nF Nano Farad
NTC Negative Temperature Coefficient

uF Mircro Farard
PTC Positive Temperature Coefficient

MHz Mega Hertz


RTD Resistive Temperature Detectors
mm Milimeter
I/O Input and Output

PIC Printed Circuit Board


EEPROM

Electrically Erasable Programmable Readonly Memory

EUSART
Enhanced Universal Asynchronous Receiver
Transceiver

GSM Global System for Mobile

ETSI
European Telecommunications Standards
Institute

TDMA Time Division Multiple Access

CDMA Code Division Multiple Access


xv
SIM Subscriber Identity Module

AT Attention These
ATD Attention These Dial

ATH Attention These Hook control

ATO Attention These return to Online data state

GPRS General Packet Radio Service

USB Universal Serial Bus

HID Human Interface

GUI Graphical User Interface

LCD Liquid Crystal Display

RAM Random Access Memory

x
v
i
Chapter One Introduction

CHAPTER 1: INTRODUCTION
1.1 Overview
A server room is used to power, store and operate computer servers that support enterprise applications
and secure critical data. As the servers contain data of high importance and perform very critical tasks,
their continuous operation is a necessity for any corresponding enterprise. Therefore countermeasures
need to be taken to ensure the servers reliability.

1.2 Problem Statement


The Information Technology and Network Administration in the University of Khartoum provides and
governs a local area network for the university and its facilities. Servers are used to enable internet
browsing and storage of databases that contain student and employees data such as payroll, registering and
further on. These servers must provide continuous service thus rigorous monitoring of environmental
threats such as temperature and humidity must be done. The Information Technology and Network
Administration require a sensor that monitor the temperature and humidity of their server rooms to
improve reliability and availability of the servers.

1.3 Objectives
• Design and implementation of a temperature and humidity monitoring embedded system.

• Design and development of Graphical User Interface for system configuration.


• Design and implementation of a communication interface between the user and the sensor.

1.4 Methodology
The taken approach was the division of the system into modules, where each module represents an
objective of the system. Such an approach was taken to facilitate the troubleshooting procedures during
the development of the system, in addition to improving the system maintainability and reliability. The
modules are to be combined to formulate a complete functional system.

1
Chapter One Introduction

1.5 Thesis Layout

Chapter Two: contains a brief background about the environment monitoring in server rooms. Chapter
Three: contains description of the design method used and how it was implemented in the simulation and
reality and brief description of the components used.

Chapter Four: provides the result obtained from the simulation and benchmarking of the embedded
system.

Chapter Five: provides the conclusion of the project and the potential future work and Improvements that

could be applied.

2
Chapter Two Literature Review

CHAPTER 2: LITERATURE REVIEW

2.1 Introduction

Server rooms contain large and complex computers that control the flow of data and storage of said data for future use. An entire building
or a station with the same purpose is a data center. Server rooms or data centers require excellent monitoring of environmental threats such
as temperature, humidity, water leaks, intrusion, power outage and further on. In the aforementioned , temperature as well as humidity are
inconsistent environmental variables that need to be carefully monitored, for example computers generate heat during operation and
excessive heat bottlenecks the performance of computers, therefore maintaining a well air-conditioned room using temperature and
humidity monitoring techniques is essential for the continuous operation of computers for server rooms and data center [1].

2.2 Background and Motivation

In server rooms, avoiding downtime is critical. Temperature and humidity fluctuations can wreak havoc on server hardware and cause
costly outages. High temperatures and very low temperatures increase the risk of server failure and data loss, while low humidity means
that the dry air will lead to electrostatic discharge (ESD) which can damage critical server components, whereas too much humidity will
cause condensation, leading to hardware corrosion and equipment failure. A report from the Gartner Group in late 2003 estimated that the
average hourly cost of downtime for a computer network was $42,000, a more recent study estimates the cost of one hour of downtime has
reached about $336,000. Consequently researches have been conducted to identify a suitable range for temperature and humidity to
maintain good performance and high reliability. The American Society of Heating, Refrigerating and Air-Conditioning Engineers
(ASHRAE) recommends data centers and server rooms to maintain a temperature range of 68° to 75°F (20° to 24°C) and ambient relative
humidity levels between 45% and 55% [2].

In order to maintain the recommended ranges continuous air-conditioning and proper ventilation of the servers must be done along with
temperature and humidity monitoring, however such an

3
Chapter Two Literature Review

approach resulted in high power consumption due to the constant usage of ventilation systems. Advancements in the field lead
to the implementation of temperature and humidity control systems, which utilized ventilation systems by demand. Many
companies provide environmental conditions monitoring and control services for server rooms and data centers according to
ASHRAE standards. Most implementations of the monitoring or control systems are done as embedded systems.

2.3 Embedded Systems


An embedded system can be thought of as a computer hardware system having software embedded in it. In a general sense, it is a
microcontroller or microprocessor based system which is designed to perform a specific task. Implementation of the embedded system
could be done as an independent system or as a part of a system.

Types Of Embedded
Systems

Based On Based On The Performance


Performance & Functional Of The Microcontrollei
Requirements
Figure 2.1 : Classification of Embedded systems

Real Stan Networked Sophisticat


d lo
A Sma I Sea e Medium Sea e
lime Mobile ed
ne

Embedded systems are primarily classified into different types based on the performance of the microcontroller or based on the
performance and functional requirements of the system embedded system as shown in Figure 2.1. Real time embedded systems are by far
the most critical category in terms of functionality and reliability.

4
Chapter Two Literature Review

Embedded systems find numerous applications in various fields such as digital electronics, telecommunications, computing network,
smart cards, satellite systems, military defense system equipment, research system equipment, and so on.

2.4 Temperature Sensors


Temperature sensors possess an essential role in industries such as petrochemical, medical, automotive, aerospace and defense, consumer
electronics and further on. Temperature monitoring and control in such industries is critical for proper functionality, for example
maintaining a specific temperature is essential for equipment used to fabricate medical drugs or in an incubator used for intensive care of
newborns.

There are many different types of temperature sensors available and all have different characteristics depending upon their actual
application. A temperature sensor consists of two basic physical types:

• Contact Temperature Sensor: These types of temperature sensors are required to be in physical contact with the object
being sensed and use conduction to monitor changes in temperature.
• Non-contact Temperature Sensor: These types of temperature sensors use convection and radiation to monitor changes in
temperature and do not have to be in direct contact with the object being sensed.

The two basic types can be further sub-divided into the following three groups of sensors, Electromechanical, Resistive and Electronic.
2.4.1 Types of Temperature Sensors

1) Thermistors:-

A thermistor is a special type of resistor which changes its physical resistance when exposed to changes in temperature. Thermistors can
either have a Negative Temperature Coefficient of resistance (NTC), that is their resistance value decreases with an increase in
temperature, or have a Positive Temperature Coefficient (PTC), in which their resistance value increases with an increase in temperature.

5
Chapter Two Literature Review

Figure 2.2 : A NTC Thermistor

2) Resistive Temperature Detectors (RTD):-

An RTD, also known as a resistance thermometer, measures temperature by correlating the resistance of the RTD element with
temperature. An RTD element consists of a film or, for greater accuracy, a wire wrapped around a ceramic or glass core. The most
accurate RTDs are made using platinum but lower cost RTDs can be made from nickel or copper.

6
Figure 2.3 : A RTD

3) Thermocouple:-

Thermocouples are thermoelectric sensors that basically consists of two junctions of dissimilar metals that
are welded or crimped together. One junction is kept at a constant temperature called the reference (Cold)
junction, while the other the measuring (Hot) junction. When the two junctions are at different
temperatures, a voltage is developed across the junction which is used to measure the sensed temperature.

Figure 2.4 : K Type Thermocouple


2.5 Humidity Sensors

Humidity sensors or hygrometers, are used to measure humidity levels in the atmosphere by monitoring
the moisture and air temperature, and reporting the relative humidity (RH) in the air. Relative humidity is
the ratio of moisture in the air to the highest amount of moisture at a particular air temperature. All types
of sensors monitor the changes in the atmosphere in a fixed time in order to calculate the humidity in the
air [3].

2.5.1 Types of Humidity Sensors

1) Capacitive: A capacitive humidity sensor measures the relative humidity by placing a thin strip of
metal oxide between two electrodes. The electrical capacity of the metal oxide changes with the
atmosphere’s relative humidity. Capacitive sensors are robust against effects such as condensation
and temporary high temperatures but they are subject to contamination, drift and aging effects, but
are suitable for many applications.

Figure 2.5: Capacitive Humidity Sensor

2) Resistive: Resistive humidity sensors utilize ions in salts to measure the electrical impedance of
atoms. As humidity changes, so does the resistance of the electrodes on either side of the salt
medium. Resistive sensors are less sensitive than capacitive sensors. The accuracy and robustness
against condensation vary depending on the chosen resistive material.
Figure 2.6 : Resistive Humidity Sensor

3) Thermal: Two thermal sensors conduct electricity based upon the humidity of the surrounding air.
One sensor is encased in dry nitrogen or dry air (sealed) while the other measures ambient air
(vented). The difference between the two measures the humidity. These sensors measure absolute
humidity rather than relative humidity.

Figure 2.7: Thermal Humidity Sensor

2.6 DHT11 Sensor


The DHT11 sensor is comprised of 3 parts, a capacitive humidity sensor, a thermistor and a chip that
performs analog to digital conversion and outputs a digital signal with the temperature and humidity. The
digital signal can be read using any microcontroller. Each DHT11 element is strictly calibrated in the
laboratory that is extremely accurate on humidity calibration. The calibration coefficients are stored as
programs in the One-Time Programmable (OTP) memory, which are used by the sensor’s internal signal
detecting process [4] [5].
Figure 2.8 : DHT11 Sensor

The specifications of the sensor are:-

• Ultra-low cost

• 3 to 5 V power and I/O


• 2.5mA max current use during conversion (while requesting data)
• Good for 20-90% humidity readings with 5% accuracy
• Good for 0-50° C temperature readings ±2° C accuracy
• No more than 1 Hz sampling rate (once every second)
• Body size 1 5.5mm x 1 2mm x 5.5mm
• 4 pins with 0.1 " spacing

2.7 Microcontrollers
A microcontroller can be considered as a self-contained system with a processor, memory and peripherals.
Along with a variety of uses in electronic systems microcontrollers are particularly
used in embedded systems for real-time control applications with on-chip program memory and
devices.

2.7.1 The PIC18F4550

Peripheral Interface Controller (PIC) is a family of Harvard architecture microcontrollers made by


Microchip Technology.

It features 32K flash memory,256 bytes of Electrically Erasable Programmable Read-only


Memory(EEPROM) data memory, 2 Comparators, 10 channels of 10-bit Analog-to-Digital converter, 2
capture/compare/PWM functions, 3 timers, an Enhanced Universal Asynchronous Receiver Transceiver
(EUSART), 5 parallel ports and USB interface.

The PIC18F4550 microcontroller has 40 pins. The pin configuration is shown in Figure 2.9 [6].

Figure 2.9 : PIC18F4550


MCLR/VPP/RE3 Pinout RB7/KBI3/PGD
RA0/AN0 RA1/AN1 RB6/KBI2/PGC
RA2/AN2/VREF-/CVREF RB5/KBI1/PGM
RA3/AN3A/REF+ RB4/AN11/KBI0/CSSPP
RA4/T0CKI/C10UT/RC RB3/AN9/CCP2<1>A/PO
V RB2/AN8/INT2A/MO
RA5/AN4/SS/HLVDIN/ RB1 /AN 10/l NT 11SC
C20UT K/SCL
RE0/AN5/CK1SPP RBO/AN12/INT0/FLT0/
RE1/AN6/CK2SPP SDI/SDA
RE2/AN7/OESPP VDD VDD
Vss OSC1/CLKI Vss
OSC2/CLKO/RA6 RD7/SPP7/P1D
RC0/T1OSO/T13CKI RD6/SPP6/P1C
RC1 m OSI/CCP2*1 RD5/SPP5yP1B
VUOE RC2/CCP1/P1A RD4/SPP4
VuSB RD0/SPP0 RC7/RX/DT/SDO
RD1/SPP1 RC6/TX/CK
RC5/D+/VP
RC4/D-A/M
RD3/SPP3
RD2/SPP2
2.8 Global System for Mobile

Global System for Mobile (GSM) is a wireless telephone technology that is used globally in phones. GSM
is developed by the European Telecommunications Standards Institute (ETSI) for mobile communications.
GSM uses a variation of time division multiple access (TDMA) and is the most widely used of the three
digital wireless telephony technologies (TDMA, GSM, and CDMA). GSM digitizes and compresses data,
then sends it down a channel with two other streams of user data, each in its own time slot. It operates at
either the 900 MHz or 1800 MHz frequency band. Since many GSM network operators have roaming
agreements with foreign operators, users can often continue to use their mobile phones when they travel to
other countries. Subscriber Identity Module (SIM) cards holding home network access configurations may
be switched to those will metered local access, significantly reducing roaming costs while experiencing no
reductions in service [7] [8].

2.8.1 AT commands

AT commands are instructions used to control a modem. AT is the abbreviation of attention. Every
command line starts with "AT" or "at". Many of the commands that are used to control wired dialup
modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return to online data state),
are also supported by GSM/GPRS modems and mobile phones. Besides this common AT command set,
GSM/GPRS modems and mobile phones support an AT command set that is specific to the GSM
technology, which includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS
(Send SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS
messages) [9].

2.8.2 SIM800

SIM800 is a quad-band GSM/GPRS module that works on frequencies GSM850/900/1800/1900MHz, it


can transmit Voice, SMS and data information with low power consumption. Featuring Bluetooth, module
control via AT commands and a UART port for serial transmission.
Figure 2.10 : SIM800

2.9 Printed Circuit Board


A printed circuit board (PCB) mechanically supports and electrically connects electronic components
using conductive tracks, pads and other features etched from copper sheets laminated onto a non-
conductive substrate. The non-conductive substrate is a thin board made of fiberglass, composite epoxy, or
other laminate material.

Components (e.g. capacitors, resistors or active devices) are generally soldered on the PCB using their
footprint or land pattern which is the arrangement of pads (in surface-mount technology) or through-holes
(in through-hole technology) used to physically attach and electrically connect a component to a printed
circuit board. PCBs can be single sided (one copper layer), double sided (two copper layers) or multi-layer
(outer and inner layers). Conductors on different layers are connected with vias. Multi-layer PCBs allow
for much higher component density. The manufacturing and assembly of PCB can be automated.
Manufacturing circuits with PCBs is cheaper and faster than with other wiring methods as components are
mounted and wired with one single part. PCBs are used in both desktop and laptop computers, TVs,
radios, digital cameras, cellphones ... etc. [10]
Figure 2.11 : A sample of PCBs

2.10 Universal Serial Bus


A group of seven companies began the development of Universal Serial Bus (USB) in 1994: Compaq,
DEC, IBM, Intel, Microsoft, NEC, and Nortel. The goal was to make it fundamentally easier to connect
external devices to PCs by replacing the multitude of connectors at the back of PCs, addressing the
usability issues of existing interfaces, and simplifying software configuration of all devices connected to
USB, as well as permitting greater data rates for external devices. A team including Ajay Bhatt worked on
the standard at Intel; the first integrated circuits supporting USB were produced by Intel in 1995.Ever
since USB standard have undergone several improvements providing different capabilities as shown in
Figure 2.12 [11]
USB Standard Data Transfer Speed Also Known As

USB 1.1 12 Mbps Full Speed

USB 2.0 480 Mbps Hi Speed

USB 3.0 5 Gbps USB 3.0 or SuperSpeed

USB 3.1 Gen 1 S Gbps USB 3.1 Gen 1 or SuperSpeed

USB 3.1 Gen 2 10 Gbps SuperSpeed+ or Su perSpeed 10

Figure 2.12 : USB Standards

2.10.1 Human Interface Device

The Human Interface Device USB Class (HID) is mainly used for devices that allow human control over a
computer. Using these devices, the host is able to react on human input (e.g. movements of a mouse or
keypresses). This response has to happen quickly, so that the computer user does not notice a significant
delay between his action and the expected feedback, examples of HID class devices are keyboards, mouse,
display devices and gaming controllers. The USB HID class is defined in a number of documents provided
by the USB Implementers Forum's Device Working Group. The HID class is not necessarily a human
interface but a device using the HID class has to be able to work within the limits of the HID class where
the exchange of data between a device and a computer is in the form of reports with fixed length. HID
devices do not require the installation of special drivers as their drivers are generally implemented with the
operating system. [12]
Chapter Two Design and Implementation

CHAPTER 3: DESIGN AND IMPLEMENTATION

3.1 Overview
Designing a fully operating embedded system requires steady and calculated steps to ensure
each part of the system is fulfilling its job to achieve the objectives. In this chapter we are
going to discuss the way the system was divided into modules, understand each module and
join the modules together to form the completed embedded system.

3.2 Design Considerations


The system was divided into modules in order to observe in fault that could occur in any
module and replaced without affecting the rest of the system. This helps in improving the
maintainability and availability of the system. The market availability affects the design of
the system , so having the best quality components might not be an option.

3.3 System Requirements


The system should provide a continuous monitoring of the temperature and humidity
surrounding the servers room. If one or both of the temperature and humidity exceed a certain
value then the system must send a message to a specified number that alter of a possible
danger to the servers every five minutes until the temperature and humidity returns to a value
below what’s configured by the user. The values of the temperature and humidity should be
configured and edited by the user and should be set around ASHRAE as well as the specified
phone number that receives the message.

3.4 Hardware Components


A simple block diagram of the system is shown in Figure 3.1, where each block represents a
major component of the system. For some blocks several comparisons and compromises were
made in order to arrive to a suitable component for the system.

1
6
Chapter Two Design and Implementation

Figure 3.1 : Block Diagram of the system

3.4.1 PIC18f4550

The following comparison was done in Table 3.1before choosing the PIC18F4550.

1
7
Chapter Two Design and Implementation

Table 3.1 : Microcontrollers Comparsion


Device

PIC18F4455 PIC18F4550 PIC16F877A

Features

FLASH (bytes) 24K 32K 14.3K

EEPROM (bytes) 256 256 256

USART Yes Yes Yes

PORTS 5 ports 5 ports 3 ports

USB Yes Yes Yes

The system requires a USB interface for the Configuration Graphical User Interface (GUI)
block and a considerable amount of flash memory, the most suitable choice is the
PIC18F4550.

1
8
Chapter Three Design and Implementation

3.4.2 DHT11 Sensor

The following comparison was done in Table 3.2 before choosing the DHT11 sensor.

Table 3.2 : Sensors Comparison

Device

DHT11 DHT22 LM35 HS1101

Features

Measures Temperature & Temperature & Temperature only Humidity only


humidity humidity

Output Digital Digital Analog Analog

Range 0-50 °C -40-125 °C -55- 150 °C 0-100 %

20-90 % 0-100 %

Accuracy ±2 °C ±0.5 °C ±1.5 °C ±2%

5% 2-5%

The comparison between DHT11 and DHT22 shows that DHT22 is more accurate and has a wider range but is not the sensor that
was used in the system because the market availability considerations play a massive role while the DHT11 is available. Digital
sensors are better than analog sensor and more reliable.
3.4.3 SIM800 GSM Shield

For the ease of implementation, a development board for the sim800 was used instead of the actual SIM800. The board is called

1
9
Chapter Three Design and Implementation

UNVSIM800 development board, it has the following specifications [12]:-

• Two power supply interface: 5V-18V DC power supply or 3.5-4.2V power supply.
• Audio interface: using 3.5mm jacks for voice calls, voice playback and other functions.
• Micro-SIM card holder.

• LED indicator light to show if the module is operating or not.


• SMA connector and antenna.

Figure 3.2: UNVSIM800 development board top side view

2
0
Chapter Three Design and Implementation

Figure 3.3 : UNVSIM800 development board bottom side view

The board provides interface between the SIM800 and the outside world using the UART transmission and reception pins. The pinout of
the board is given in Table 3. 3 [13].
Table 3. 3 : UNVSIM800 Board Pinout
PIN Description

DCIN 5-18 V DC power input, used to supply power to the development


board.

VDD Used to match the high voltage output of the TTL serial port.
GND Ground of the system

RXD
3V8 SIM800 data receiving end, need to connect the sending end of the
Input or output, when DCIN is connected to the power supply, the
external system.
output of this pin 3V8 DC voltage. When used as an input , this pin is
TXD used todata
supply power to the
SIM800 sending end, needdevelopment board
to connect the : 3.5 —end
receiving 4.2ofV.the

external system.

GND Ground of the system.


2
RST SIM800 reset, active low effective duration 600MS. 1
Chapter Three Design and Implementation

3.4.4 Other Hardware Components


Table 3.4 : Other Required Components
Component Usage

Crystal oscillator 8 MHz Required by the PIC18F4550.

22pF capacitors Required for the crystal oscillator.

104nF capacitors
Required by the USB interface in the
PIC18F4550.

0.1uF capacitor Required by the L7805CV regulator.

0.33uF capacitor Required by the L7805CV regulator.

16x2 LCD
Used to display the sensor and other
outputs from the PIC18F4550

4.7K ohm resistor Required by the DHT11sensor.

1K variable resistor
Used for the adjustment of contrast in the
LCD.

L7805CV 5 V regulator
To provide regulated 5 V from the 12V of
the DC supply.

DC supply Provides 12V for the circuit

USB connector
To connect the USB cable with the
PIC18F4550.

Used to program the PIC18F4550


PICKit3 programmer
with the hex file

2
2
Chapter Three Design and Implementation

3.5 Software tools

• MikroC for PIC compiler was used for the development and compilation of the C code for the PIC18F4550.
• Proteus simulator was used to design and simulate electronic circuits in each block, it was a major backbone for the development
and testing process.
• Visual Studio was used to develop the GUI for the sensor configuration using C# programming language.
• Altium Designer was used to construct the PCB circuit for the system.

3.6 Design and Implementation Process

The system was divided into 3 modules:-


1) Temperature and Humidity monitoring module.
2) GSM communication module.
3) Configuration GUI module.
3.6.1 Temperature and Humidity Module

The block diagram in Figure 3.4 represents the module. In this module, all the components require 5V dc supply for operation. The
DHT11 sensor will monitor the temperature and humidity, transmit the data to the microcontroller and the values will be displayed on
the LCD.

Figure 3.4 : Block diagram for Temperature and Humidity Module

2
3
Chapter Three Design and Implementation

A flowchart on how the module will operate is shown in Figure 3.5. The start signal is a low level input signal sent for 18ms, without
the start signal from the microcontroller the DHT11 will not give response signal to microcontroller. DHT11 will send out low-
voltage-level for 80us as response signal, then a high level signal for 80us for preparation to send data. The microcontroller will check
for the response signal and the preparation signal to check whether the sensor is responsive or not.

2
4
Sendiheck Inva
start signal to response
sensor
whether the DHT11 va Receive data from
lid
from DHT11 sensor is \ c DHT11 sensor
valid or not. / no
Display
response from
the sensor

Does the checksum of


the data = the received
checksum

Display the error


checksum.

Yes
Process the data then display the temperature and humidity values.

Figure 3.5 : Temperature and Humidity Module Flowchart

The DHT11 will transmit data in the following format, 8bit humidity integer data + 8bit the Humidity decimal data + 8bit temperature
integer data + 8bit fractional temperature data +8 bit checksum for data integrity, however since the sensor is not accurate enough to
measure decimals
Chapter
the 8 bits Three
for decimal data will be transmitted as zeros. The data is saved andDesign andonto
displayed Implementation
the LCD.

LCD1
LK4
015L
T en p = 29° C

O ID=>5«76 y.
RH
CO
C0
>>>O KtO QQQQQQQQ
ID
UJ

RCQ/T10SOiT B15
RAG/ANO
3B RA1/AN1 RC1/T1
1CKI
OS ■ Fi
4B I/CCP2/UOE 16 1 gu
RA2/AN2/VREF-‘CVREF RC2/CCP1/P1A
5« ■23
6"
RA3/AN3-VREF+ RC4VD-/VM
24 re
RA4/T0CKI/C1OLTT/RCV RC5/D+/VP
7-
RA5/AN4/SS/LVDIN/C20UT RC6/TX/CK
■25 3.6
14« 2
13" RA6/OSC2.CLKO RC7/RX/DT/SDO 6 :
OSC1/CLKI
Si
R 3 ■ 1
S : 34« RBO/AN RD0VSPP0 ■ 9 m
e 12.,INT0,'FLT0/SDI.’,SDA RD1/SPP1
35 B
RB1 /AN 10/I NT 1 /SCKfSCL RD2/SPP2
■ ul
D 36B 21

4
u RB2/AN&1NTZVWO RD3VSPP3 22 ati
u 37"
R B3/A N 9/CC P2'VP 0 RD4VSPP4
■27
D
5
L
J
L
3
38"
RB4/AN11 /KBIO/CSSPP RD5/SPP5/P18
■28
2
D'GI
T
AL
on
o -
4
RB5/KBI1/PGM RD6/SPP0/P1C
■309
of
RB6/KBI2'PGC
RB7/KBI3PGD RD7/SPP7/P1D
0 th
VDD
RE0/AN5/CK1SP 3
DATA e
REVAN6/CK2SP
P 9
10 GND Te
i P RE2- ■1 l m
VUSB AN7/OESPP
F RE&WCLR/VPP DHT pe
11 ra
*TEXT tu
>
re
an
d
H
u
mi
dit
y
M
od
ul
e
2
6
Chapter Three Design and Implementation
3.6.2 GSM Communication Module

This module consists of the microcontroller and the UNVSIM800 development board interfaced together.
As a module both the microcontroller and the board operate using 5V of dc supply, however in the
complete system higher voltage must be supplied to the development board to account for the voltage
drop.

The RX and TX pins of the PIC18F4550 are connected with the TX and RX of the board for serial
transmission of the AT commands required to transmit the message using the GSM board. In the
simulation, a virtual terminal is used to mimic the SIM800 board.

Fi
gu
re
3.
9:
Fl
ow
ch
ar
t
of
th
e
G
S
M
m
od
ul
e
2
7
Chapter Three Design and Implementation

Figure 3.10 : Simulation of the GSM Module

2
8
Chapter Three Design and Implementation

Figure 3.12 : Actual Result of the GSM module

The shield in Figure 3.11 the LED will blink every 1 second if it is not operating properly, while blink
every 5 seconds if in proper operational mode.

3.6.3 Configuration GUI module

This module consists of two parts:-

• An implementation at the microcontroller side to store the configurations set by the user.
• A User interface to allow the user to the set the configuration.

The linkage of the two parts is done through USB interface. As soon as USB connection is made and the
clock speed of the microcontroller complies with the USB standards, USB device enumerations will occur
where the PIC18f4550 will send descriptor reports to identify itself as a HID class device and other
important parameters such as vendor and product ID, powering mode, endpoints used, reports length and
so on. Fi
gu
re
3.1
1:
G
S
M
M
od
ul
e
op
er
ati
ng
2
9
Chapter Three Design and Implementation

Figure 3.13 : USB Device Enumerations in Simulation

Fi
gu
re
3.
14
:
PI
C
18
F4
55
0
is
id
USB data is stored in USB RAM memory in the microcontroller. The memory allocation is as shown en
in
tif
Figure 3.15, thus USB data is limited to that address space. ie
d
as
H
ID
de
vi
ce
3
0
Chapter Three Design and Implementation
OOO
h
Banks 0 User Data
to 3

3FFh
Buffer Descnptors. USB 400h
Data or User Data 4FFh
500h

Banks
4
USB Data or
to 7 User Data
(USB
RAM)

7FFh
BOO
h

Banks 8 .
Unused
to 14

FOO
h
F60h
Bank15 ' SFRs FFFh
Figure 3.15 : PIC18F4550 USB
RAM memory

3
1
fF X
8 New Project - Proteus 8 Professions! - Schematic Capture

3H
: Capture X
ft |
.lINTER Field Value
NAL.
F'CVtg
RLP
l-l-ICjlNTSRNAL;
POWERuF
G€T_DeSCRIPT
OR_
H-|l,JINTERNAL
RESET
Q
B
CAP

r:IS
CRYST

GET.DeSCRIP
I^IQlOCa

F
RES J
f USB Sensor Control TCR
FRO)^DEVICE
L : K..
-
UNIVERSITY ■*: OF
KHARTOUM

!► II ■ !\ 3 Message^) ANIMATING: 00.00:31.466104 (CPU load 12'A)

Figure 3.17: USB Configuration GUI Module Test

9 USB
Anal
<? I yzer
&

8 New Project - Proteus 8Professions! ■ Schematic Capture


Virtual Terminal INTERNAL:
RESET

I|
A|Q INTERNAL RESET

ICCTL
&ET_D£S
CRIFTQR
CONTROL_TRANSFER
CAP GETDESC
_FRQM_C
R
CAYSlI
€VI CE
IPTOR_FR
F :: 13F
RES
US ECO
j
’I' USB Sensor Control
OUD€VtC
E

UNIVERSITY OF KHARTOUM

Humdity

► !► || ■ !\ 3 Messaged) ANIMATING: 00 01:01.100338 (CPU toad 137.)

Figure 3.18 : USB Configuration GUI Module Test


Chapter Three Design and Implementation

3.6.4 Combining the Modules

In order to achieve a fully functioning system, the modules must be combined into a full complex system.
This procedure was done using Altium Designer by constructing a PCB that will include the modules and
other required components as stated in Table 3.5.

In order to construct a PCB, a circuit schematic is needed first Figure 3. 19 shows the schematic.

Fi
gu
re
3.
19
:
C
o
m
pl
et
e
Sy
ste
m
Sc
he
m
ati
c
3
3
Further comes the construction of the components footprints and importing the footprints into the PCB
file. Tracks are used to connect the components together, the fully routed board is shown in Figure 3.20.

Figure 3.20 : PCB layout


Chapter Three Design and Implementation

The bottom layer represents what should be on the bottom side of the board, which means anything
depicted as blue should be implemented on the bottom side. While red represents the top layer indicating
what should be done on top. This PCB is single sided as can be seen in Figure 3.20, Figure 3.21 no tracks
are visible on the top side and all the connections are made on the bottom side. The yellow represents the
silk screen or the overlay layer which is used for the naming of components or any other writings, finally
the pink represents the mechanical layer which indicates where cutting of the board should occur.

Afterwards, the board must be fabricated. The fabrication process starts with the drilling of the holes, pads
and vias required on the board, then a mechanical outline is performed to determine the size of the board.
After that the drilling of the tracks begins, once finished the board is cut off the sheet.

Fi
gu
re
3.
22
:
P
C
B
Fa
br
ica
tio
n
3
5
Chapter Three Design and Implementation

Fi
gu
re
3.
23
:
P
C
B
Fa
br
ic
ati
on
3
6
Chapter Three Design and Implementation

Figure 3.24 : PCB Fabrication

Fi
gu
re
3.
25
:
P
C
B
Fa
br
ica
tio
n
3
7
Normally the next step would be fabricating the solder mask layer, however the chemicals required to
create the mask were not available .Thus, the final step was to solder the components onto the board as
shown in

Figure 3.26 : Soldered PCB


3.7 Problems Faced During Design and Implementation Process

3.7.1 Limited Supply of Components

The system implementation was based on DHT22 because of its better qualifications but due to the lack of
market availability in Sudan and delivery problems, the DHT11 was used instead and set the accuracy of
the system to a lower grade.

3.7.2 DC supply mismatch

The UNVSIM800 was an alternative component , being the UNVSIM900 was the intended one but market
availability played a role as well. A slight voltage drop below 5V caused the board to not function
properly and costed us a lot of time. The introduction of a 12V DC supply and L7805CV 5 V regulator
was taken. Other alternatives were taken but didn’t give results.

3.7.3 Unavailability of Solder Mask

The lack of solder mask on top of the copper in the PCB caused delays in the process of making the PCB ,
as the solder will stick to as much copper as it can which if left unhandled will definitely create a short
circuit and possibly ruin the entire board. Soldering required meticulous work and high precision.

Figure 3.28 : failed soldering of the PCB


Chapter Three Design and Implementation

3.7.4 Track Width Consideration

Tracks are made on the PCB to connect components together where it allows electricity to flow through
them. If a certain amount of voltage crosses a think track, it might possibly burn the track or the pad from
all the resistance. Therefore having wider tracks or pads when connected to high voltages will not be
damaged.

4
0
CHAPTER 4: RESULTS AND DISCUSSION
4.1 End Result

Figure 4.1 : Complete System Testing board

Figure 4.2 : Operation of the Test Board

Figure 4.4 : PCB Board with programmer


Programmer pins were implemented on the PCB to provide means for reprogramming of the microcontroller. Each module is implemented
as pin holders to allow convenient replacement in case any fault occurs.

4.2 Benchmarking
4.2.1 Temperature Measurement

The sensor was benchmarked twice using two different methods. In the first benchmark an analog temperature sensor (Anymetre) and a
Thermotron [14] were used as basis of comparison.
Chapter Four Results and Discussion

Figure 4.5 :Thermotron Chamber with DHT11 sensor inside

Fi
gu
re
4.6
:
Th
er
m
ot
ro
n
Co
nt
rol
Pa
d
4
3
Figure 4.7 : Analog Temperature meter reading (Anymetre)

Figure 4.8 : DHT11 Sensor Reading


The Thermotron slowly decrease the chamber temperature until it reaches the specified value. The process can
quite some time until it reaches the specified value..

Table 4.1 : Table of Measurements

Thermotron DHT11 Anymetre

40 °C 35 C 36 C

30 C 32 C 34 C

20 C 24 C 28 C

As seen in Table 4.1 the results from the DHT11 and the Anymetre are in close proximity, however they
deviated from the Thermotron which I believe is due the Thermotron very slow response and behavior, as
temperature is dynamic and can rapidly change in short intervals of time that are faster than the Thermotron
response.

The second comparison was done using a standard thermometer Figure 4.9, Table 4.2 shows the
measurements of the thermometer against the DHT11 sensor under a predefined air conditioner temperature
value.
Figure 4.9 : Thermometer

Table 4.2 : Sensor Measurements

DHT11 Thermometer Air conditioner set value

28°C 30°C 30°C

25°C 26°C 26°C

23°C 23 °C 23 °C
19°C 20°C 20°C

18°C 18°C 18°C

The measurements are relatively the same which indicates a good level of accuracy for the DHT11 sensor.

4.2.2 Humidity Measurement

As a suitable humidity sensor was not found to perform benchmarking with, it was decided to use two
DHT11 sensors and compare their humidity readings. Table shows the comparison.

Table 4.3 : Comparison of 2 DHT11 Sensors

DHT11 Sensor (1) DHT11 Sensor (2)

Temperature, Humidity Temperature, Humidity

35°C, 13% 36°C , 13%

34°C, 14% 34°C , 14%

33°C, 14% 33°C, 14%

32°, 15% 31°, 16%

30°, 16% 31°, 17%

The readings are almost identical for the two sensors, which indicates some credibility to the DHT11 sensor
humidity measurement.
Chapter Five Conclusions and Future Work

CHAPTER 5: CONCLUSIONS AND FUTURE WORK


5.1 Conclusion
The aim of the project was to design a temperature and humidity monitoring embedded system for a high
performance server room. The objectives were achieved and the system functions as desired in the
specifications. The system will provide continuous monitoring of temperature and humidity in the
environment and alert the user whenever the measurements are not desired. A pursuit for improvements
towards the system are still on-going. As more time was spent working on this project, the more the
attachment and passion for this project has grown. Future development of the system can lead to a more
robust system and more features to be provided for the user

5.2 Future Work


5.2.1 Implementing a Graphical LCD

If we increase the size of the LCD we would be able to add more icons such as battery percentage, date
and time in order to improve the interaction with the user and make it easier..

5.2.2 Providing System Logs

Using logs help keep track of measured data by the sensor at set intervals of time to give an observation
of the environment. These observations can be used to identify abnormal behavior and countermeasures
could be done.

5.2.3 Improving the Configuration Graphical User Interface

• To increase the number of phones that the alert message will be sent to, in order to ensure other user
receiving the messages in case failure to deliver to the main intended user .
• The ability to charge the SIM card through the interface.

• Support of Arabic language.


5.2.4 Development of a smart battery management module

In case the power goes out, the system needs an internal power supply to ensure the continuous monitoring of
the environment.

4
8
REFERENCES

[1] Prathamesh Narkhede, Bhushan Kiratkar, Bhushan Suryawanshi, "Physical Conditions Monitoring
in Server," International Journal of Electrical and Electronics Research, vol. Vol. 3, no. Issue 4, p.
3, December 2015.

[2] R. Grundy, "Recommended Data Center Temperature & Humidity," AVTECH, 14 November 2005.
[Online]. Available: https://avtech.com/articles/3647/recommended-data-center- temperature-
humidity/.

[3] S. International, "Different Types Of Humidity Sensors," 24 February 2016. [Online]. Available:
http://www.switches.co.za/different-types-humidity-sensors/.

[4] D.-R. UK, "DHT11 Humidity & Temperature Sensor," 30 July 2010. [Online]. Available:
www.droboticsonline.com.

[5] L. Aosong(Guangzhou) Electronics Co., "Temperature and humidity module DHT11 Product
Manual," [Online]. Available: www.aosong.com.

[6] M. T. Inc, PIC18F2455/2550/4455/4550 Datasheet, 2009.

[7] A. A. Huurdeman, The Worldwide History of Telecommunications, Wiley-IEEE Press, 2003.

[8] M. Rouse, "GSM (Global System for Mobile communication)," May 2007. [Online]. Available:
http://searchmobilecomputing.techtarget.com/definition/GSM.

[9] D. Home, "Introduction to AT Commands," [Online]. Available:


http://www.developershome.com/sms/atCommandsIntro.asp.

[10] Wikipedia, the free encyclopedia, "Printed circuit board," [Online]. Available:
https://en.wikipedia.org/wiki/Printed_circuit_board#cite_ref-1.

4
9
[11] T. Fisher, "Universal Serial Bus (USB)," 28 August 2017. [Online]. Available:
https://www.lifewire.com/universal-serial-bus-usb-2626039.

[12] USB.org, "Device Class Definition for HID 1.11," 21 January 2001. [Online]. Available:
www.usb.org/developers/hidpage/HID1_11.pdf.

[13] Globals, "Global Hawk electronic UNV-SIM800 voice board," [Online]. Available:
http://en.globals.social/item.html?id=tb38636874126.

[14] Thermotron, "Thermotron," [Online]. Available: http://thermotron.com/.

5
0
Appendix A MikroC Codes

Appendix A: MikroC Codes


A.1 Main Code
// LCD module connections sbit LCD_RS at RB0_bit;

sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit;

sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit;

sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at

TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit

LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at

TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit;

// End LCD module connections

unsigned char readbuff[64] absolute 0x500; // Buffers should be in USB RAM unsigned char writebuff[64] absolute 0x540;

char cnt; int i;

char count; char tmp[64] ; char hum[64]; char

number1[64]; int d_temp; int d_hum;

A-
1
Appendix A MikroC Codes

void interrupt(){

USB_Interrupt_Proc(); // USB servicing is done inside the interrupt

unsigned char Check, T_byte1, T_byte2, RH_byte1, RH_byte2, Ch ;

unsigned Temp, RH, Sum ; char message1 []= "Temp = 00 C "; char

message2 []= "RH = 00 % ";

void Initialization) {

UART1_Init(9600);

delay_ms(1000);

void eeprom(){

for (i=0; i<64; i++) { count = EEPROM_Read(0x00+i);

tmp[i] = count;
}

for (i=0; i<64; i++) { count = EEPROM_Read(0x64+i);

hum[i] = count;
}

for (i=0; i<64; i++) { count = EEPROM_Read(0x80+i);

number1[i] = count;
}

A-
2
void Sms_temp()

UART1_Write_Text("AT");

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

UART1_Write_Text("AT0");

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

UART1_Write_Text("AT+CMGF=1");

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

UART1_Write_Text("AT+CMGS=");

Delay_ms(200);

UART1_Write(0x22); // "

Delay_ms(200);

UART1_W rite_Text(number1);

Delay_ms(200);

UART1_Write(0x22); // "

Delay_ms(1000);
UART_Write(0x0D);

Delay_ms(1000);

UART1_Write_Text("Alert !, The Temperature Is Too High !"); Delay_ms(2000);

UART_Write(26);

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

void Sms_hum()

UART1_Write_Text("AT");

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

UART1_Write_Text("AT0");

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

UART1_Write_Text("AT+CMGF=1");

Delay_ms(1000);

UART_Write(0x0D);
Delay_ms(1000);

UART1_Write_Text("AT+CMGS=");

Delay_ms(200);

UART1_Write(0x22); // "

Delay_ms(200);

UART1_W rite_Text(number1);

Delay_ms(200);

UART1_Write(0x22); // "

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

UART1_Write_Text("Alert !,It Is Too Humid !"); Delay_ms(2000);

UART_Write(26);

Delay_ms(1000);

UART_Write(0x0D);

Delay_ms(1000);

void StartSignal(){ TRISD.F0 = 0;

PORTD.F0 = 0; delay_ms(18);
PORTD.F0 = 1; delay_us(40);

TRISD.F0 = 1;
}

void CheckResponse(){

Check = 0; delay_us(40); if (PORTD.F0 == 0)

{ delay_us(80);

if (PORTD.F0 == 1) Check = 1; delay_us(40);} }

char ReadData(){ char i, j;

for(j = 0; j < 8; j++){ while(!PORTD.F0); delay_us(30); if(PORTD.F0 == 0)


i&= ~(1<<(7 - j));
else {i
|= (1 << (7 - j)); while(PORTD.F0);}
}

return i; } void main() { begin :

ADCON1 |= 0x0F;

CMCON |= 7; eeprom();

d_hum = atoi(hum); d_temp = atoi(tmp);

Lcd_Init();

Lcd_Cmd(_LCD_CURSOR_OFF);

Initialization();

HID_Enable(&readbuff, &writebuff); while (1){

Lcd_Cmd(_LCD_CLEAR);

StartSignal();
CheckResponse(); if(Check == 1){

RH_byte1 = ReadData();

RH_byte2 = ReadData();

T_byte1 = ReadData();

T_byte2 = ReadData();

Sum = ReadData();

if(Sum == ((RH_byte1+RH_byte2+T_byte1+T_byte2) & 0XFF)){ Temp = T_byte1;

RH = RH_byte1;

message1 [7] = 48 + ((Temp / 10) % 10); message1 [8] = 48 + (Temp % 10); message1 [9] = 223;

message2 [7] = 48 + ((RH / 10) % 10); message2 [8] = 48 + (RH % 10);

Lcd_out (1,1,message1); lcd_out (2,1,message2);

if( Temp >= d_temp ){ Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1, 1, "Temp Too High!"); lcd_out (2,1,message2);

delay_ms(5000);

Sms_temp();
delay_ms(300000) ;

if (RH >= d_hum){ Lcd_Cmd(_LCD_CLEAR);


Lcd_out (1,1,message1); lcd_out (2,1,"It Is Too Humid!");

delay_ms(5000);

Sms_hum();

delay_ms(300000);

} if ( (RH >= d_hum)&&( Temp >= d_temp )) { Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1, 1, "Temp Too High!"); lcd_out (2,1,"It Is Too Humid!");

delay_ms(5000);

Sms_temp();

Sms_hum();

delay_ms(300000);
}

else{

Lcd_Cmd(_LCD_CURSOR_OFF);

Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "Check sum

error");} }

else {

Lcd_Out(1, 3, "No response"); Lcd_Out(2, 1, "from the

sensor");
}

delay_ms(1000);
if(readbuff[0]=='9'){

while(1){

while( !HID_Read()); Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1, 5, "USB MODE");

if(readbuff[0]=='0'){ for(cnt=1;cnt<64;cnt++)

tmp[cnt- 1]=readbuff[cnt]; delay_ms(500); for (i=0;

i<64; i++) { count = tmp[i];

EEPROM_Write(0x00+i,count); delay_ms(500); }
}

if(readbuff[0]==T){ for(cnt= 1;cnt<64;cnt++) hum[cnt-

1]=readbuff[cnt]; delay_ms(500); for (i=0; i<64; i++)

{ count = hum[i];

EEPROM_W rite(0x64+i,count); delay_ms(500);


}
}

if(readbuff[0]=='2'){

for(cnt=1;cnt<64;cnt++) number1[cnt-1]=readbuff[cnt];

delay_ms(500); for (i=0; i<64; i++) { count = number1[i];

EEPROM_W rite(0x80+i,count); delay_ms(500);


}
}
if(readbuff[0]=='7')
Appendix A MikroC Codes
goto begin ;

A.2 USB Descriptor Code

const unsigned int USB_VENDOR_ID = 0x1234; const

unsigned int USB_PRODUCT_ID = 0x0001;

const char USB_SELF_POWER = 0x80; // Self powered 0xC0, 0x80 bus powered

const char USB_MAX_POWER = 50; // Bus power required in units of 2 mA

const char HID_INPUT_REPORT_BYTES = 64;

const char HID_OUTPUT_REPORT_BYTES = 64;

const char USB_TRANSFER_TYPE = 0x03; //0x03 Interrupt

const char EP_IN_INTERVAL = 1;

const char EP_OUT_INTERVAL = 1;

const char USB_INTERRUPT = 1; const

char USB_HID_EP = 1; const char char


bLe
USB_HID_RPT_SIZE = 33; ngth
;
bLe
ngth
/* Device Descriptor */ -
Des
const struct { cript
or
size
in
byte
s
(12h
)
A-
11
Appendix A MikroC Codes
char bDescriptorType;
// bDescriptorType - The constant DEVICE (01h)
unsigned int bcdUSB; char
// bcdUSB - USB specification release number (BCD) // bDeviceClass
bDeviceClass; char
- Class Code // bDeviceSubClass - Subclass code // bDeviceProtocol -
bDeviceSubClass; char
Protocol code // bMaxPacketSize0 - Maximum packet size for
bDeviceProtocol; char
endpoint 0 // idVendor - Vendor ID // idProduct - Product ID //
bMaxPacketSize0;
bcdDevice - Device release number (BCD)
unsigned int idVendor;
// iManufacturer - Index of string descriptor for the manufacturer
unsigned int idProduct;

unsigned int bcdDevice; char iProduct; // iProduct - Index of string descriptor

char iManufacturer; for the product.

char iSerialNumber; // iSerialNumber - Index of string descriptor for the serial


number.

char bNumConfigurations; // bNumConfigurations - Number of possible


configurations

} device_dsc = {
0x12, // bLength

0x01, // bDescriptorType

0x0200, // bcdUSB

0x00, // bDeviceClass
//
0x00,
bDeviceSubClass
0x00, // bDeviceProtocol

8, // bMaxPacketSize0
USB_VENDOR_ID, // idVendor

A-
12
Appendix A MikroC Codes

USB_PRODUCT_ID, // idProduct 0x0001, // bcdDevice

0x01, // iManufacturer

0x02, // iProduct

0x00, // iSerialNumber

0x01 //bNumConfigurations
};

/* Configuration 1 Descriptor */ const

char configDescriptor1[]= {

// Configuration Descriptor

0x09, // bLength - Descriptor size in bytes

0x02, // bDescriptorType - The constant CONFIGURATION (02h)

0x29,0x00, // wTotalLength - The number of bytes in the configuration


descriptor and all of its subordinate descriptors

1, // bNumInterfaces - Number of interfaces in the configuration

1, // bConfigurationValue - Identifier for Set Configuration and Get


Configuration requests

0, // iConfiguration - Index of string descriptor for the configuration

USB_SELF_POWER, // bmAttributes - Self/bus power and remote wakeup


settings

USB_MAX_POWER, // bMaxPower - Bus power required in units of 2 mA 0x0


9,
bLe
ngth
// Interface Descriptor -
Des
cript
or
size
in
byte
s
(09h
)
A-
13
0x04, // bDescriptorType - The constant Interface (04h)

0, // bInterfaceNumber - Number identifying this interface

0, // bAlternateSetting - A number that identifies a descriptor with alternate


settings for this bInterfaceNumber.

2, // bNumEndpoint - Number of endpoints supported not counting endpoint

zero

0x03, // bInterfaceClass - Class code

0, // bInterfaceSubclass - Subclass code

0, // bInterfaceProtocol - Protocol code

0, // iInterface - Interface string index

// HID Class-Specific Descriptor

0x09, // bLength - Descriptor size in bytes.

0x21, // bDescriptorType - This descriptor's type: 21h to indicate the HID


class.

0x01,0x01, // bcdHID - HID specification release number (BCD).

0x00, // bCountryCode - Numeric expression identifying the country for


localized hardware (BCD) or 00h.

1, // bNumDescriptors - Number of subordinate report and physical


descriptors.

0x22, // bDescriptorType - The type of a class-specific descriptor that follows

USB_HID_RPT_SIZE,0x00, // wDescriptorLength - Total length of the descriptor identified


above.
0x07, // bLength - Descriptor size in bytes (07h)

0x05, // bDescriptorType - The constant Endpoint (05h)

USB_HID_EP | 0x80, // bEndpointAddress - Endpoint number and direction


USB_TRANSFER_TYPE, // bmAttributes - Transfer type and supplementary information

0x40,0x00, // wMaxPacketSize - Maximum packet size supported

EP_IN_INTERVAL, // bInterval - Service interval or NAK rate

// Endpoint Descriptor

0x07, // bLength - Descriptor size in bytes (07h)

0x05, // bDescriptorType - The constant Endpoint (05h)

USB_HID_EP, // bEndpointAddress - Endpoint number and direction


USB_TRANSFER_TYPE, // bmAttributes - Transfer type and supplementary information

0x40,0x00, // wMaxPacketSize - Maximum packet size supported

EP_OUT_INTERVAL // bInterval - Service interval or NAK rate

};

const struct {

char report[USB_HID_RPT_SIZE]; }

hid_rpt_desc =

{0x06, 0x00, 0xFF, // Usage Page = 0xFF00 (Vendor Defined Page 1)

0x09, 0x01, // Usage (Vendor Usage 1) //

0xA1, 0x01, Collection (Application)


Appendix A MikroC Codes

// Input report

0x19, 0x01, // Usage Minimum

0x29, 0x40, // Usage Maximum

0x15, 0x00, // Logical Minimum (data bytes in the report may have minimum
value = 0x00)

0x26, 0xFF, 0x00, // Logical Maximum (data bytes in the report may have maximum
value = 0x00FF = unsigned 255)

0x75, 0x08, // Report Size: 8-bit field size

0x95, HID_INPUT_REPORT_BYTES,// Report Count

0x81, 0x02, // Input (Data, Array, Abs)

// Output report

0x19, 0x01, // Usage Minimum

0x29, 0x40, // Usage Maximum

0x75, 0x08, // Report Size: 8-bit field size

0x95, HID_OUTPUT_REPORT_BYTES,// Report Count

0x91, 0x02, // Output (Data, Array, Abs)

0xC0} // End Collection


};

//Language code string descriptor

const struct { char bLength; char

bDscType; unsigned int string[1];

} strd1 = {

A-
16
4,

0x03,

{0x0409}

//Manufacturer string descriptor

const struct{ char bLength; char

bDscType; unsigned int

string[16];

}strd2={

{'M','i','k','r','o','e','l','e','k','t','r','o','n','i','k','a'}

34, //sizeof this descriptor string 0x03,

};

//Product string descriptor const

struct{ char bLength; char

bDscType; unsigned int

string[10];

}strd3={
0x03,

','S','e','n','s','o','r'}

//Array of configuration descriptors

const char* USB_config_dsc_ptr[1];

//Array of string descriptors const

char* USB_string_dsc_ptr[3];

void USB_Init_Desc(){

USB_config_dsc_ptr[0] = &configDescriptor1;

USB_string_dsc_ptr[0] = (const char*)&strd1;

USB_string_dsc_ptr[1] = (const char*)&strd2;

USB_string_dsc_ptr[2] = (const char*)&strd3;


}

You might also like