CHAPTER 1 INTRODUCTION 1.1 Introduction

54 downloads 0 Views 2MB Size Report
The Broadcom BCM43438 chip provides 2.4GHz 802.11n wireless LAN, Bluetooth. Low Energy, and Bluetooth 4.1 Classic radio support. Built directly onto the ...
CHAPTER 1 INTRODUCTION 1.1 Introduction Automation is the use of control systems and information technology to control equipment, industrial machinery and processes, reducing the need for human intervention. In the scope of industrialization, automation is a step beyond mechanization. Mechanization provided human operators with machinery to assist them with the physical requirements of work while automation greatly reduces the need for human sensory and mental requirements as well. [1] Home automation refers to the use of computer and information technology to control home appliances and features. Systems can range from simple remote control of lighting through to complex computer/Single chip computer/micro-controller or hybrid system combining microcontroller and single chip computer based networks with varying degrees of intelligence and automation. So How about having a security system that will detect smoke, excessive electrical power usage, burglar attempts and unauthorized movements in your house and alert you? This is what home automation is about and there is no end to its application. In fact, sophisticated home automation systems are now being developed that can maintain an inventory of household items, record their usage through an RFID (Radio Frequency Identification) tag, and prepare a shopping list or automatically order replacements. Automation plays an increasingly important role in the global economy and in daily experience. Engineers are trying hard to combine automated devices with different type of tools to create hybrid and complex systems for a fast expanding range of applications and human activities. Many roles for human in home environment and as well as industrial processes presently beyond the scope of automation. Human like or even comparable to human like

pattern recognition, language recognition, and

language production ability are well beyond the capabilities of modern computer systems. Tasks requiring subjective assessment or synthesis of complex sensory data, |1 ©Daffodil International University

such as scents and sounds, as well as high-level tasks such as strategic planning, currently require human expertise. Now a days the number of electronic devices increasing in our home environment, as electronic controllable devices in the home rises, interconnection and communication becomes a useful factor and as well as desirable feature for our daily use. For example, a fan or an air-conditioner can be turned off and on depending on the room temperature ,lights can be turned on and off depending on the ambient light sensor placed on that room.PIR sensor can sense movement of the objects ,thus Rooms will become "intelligent" and will send signals to the controller when someone enters. If no one is supposed to be home and the alarm system is set, the system could call the owner, or the neighbors, or an emergency number. In simple format, domestics may be as straightforward as turning on the lights when a person enters the room. In advanced installations, rooms can sense not only the presence of a person inside but know who that person is and perhaps set appropriate lighting, temperature, music levels or television channels, taking into account the day of the week, the time of day, and other factors.

1.2 Project objective The aim of this project is to design and construct a home automation system that can remotely control any household appliance connected to it, using a microcontroller, a single chip computer and an UWP(Universal Windows Platform) application for sending command and

receiving feedback, Through which user will be able to

communicate with the system by GUI and Voice command. Which can also be able to take sensor reading from the sensors attached to it and depending on the sensor value it can make various decisions.

1.3 Methodology The system will consist of a central controlling unit which is a single chip computer in this case I am using a Raspberry Pi 3 . Raspberry pi3 is a credit card sized minicomputer capable of doing lot of computing process. As a microcontroller I am using a Arduino Uno R3 which is manufactured based on the Atmel ATmega328. The |2 ©Daffodil International University

Arduino will host all the sensors and the relay or other switching devices that are being used for turning ON or OFF the electrical appliances. ATmega328 on Arduino will communicate to the sensors and read data from them and also the Arduino can control the switching device to control the appliances. Here Raspberry pi3 will host the control client through which we can view the sensor data, we can check the current device status which is connected to the specific Arduino, and we can also set the device status. To communicate between Arduino and Raspberry Pi3 I have used the I2C communication bus which was developed Philips semiconductor back in 1980. In I2C communication bus the Raspberry Pi3 will act as master device and the Arduino will act as a slave device.

1.4 Organization of the report This report is organized as follow: Chapter 2 describes about the block diagram of the complete system and also the diagram of the other module and components. It also narrates about the implementation of the hardware section of the system. Chapter 3 contains the user application (Controlling app) design and implementation of the application. Chapter 4 narrates how the single chip computer and the microcontroller (Atmel Atmega328) communicate over i2c bus. Chapter 5 contains system deployment and testing result. Finally Chapter 6 concludes the report with recommendation for future expansion provisions of the work.

1.5 Project justification This project is of contributory knowledge to the development and implementation of home automation system in such developing country like Bangladesh using available components like microcontroller, single chip computer, sensors etc. Beside that this system provides some extend of advance feature and safety measure some of the possible application or feature of the system are listed below 

Remote Controlling of your electrical home appliances through control app.



Controlling of your electrical home appliances through voice command thus provides hands free option to interact with the system.



Getting Real-time status of the electrical appliances of your home. |3

©Daffodil International University



Real-time temperature and ambient light information for individual rooms.



Optimal temperature suggestion depending on the daily temperature sensor Reading



Setting the Air conditioner Temperature according to the optimal temperature suggestion Status of your gas burner through flame sensor.



Automatic lights on/off depending on the ambient light sensor status. (Outer side)



Voice command feature will greatly help the people who are handicap, disabled or old people. It’s also provides some extend of safety measure for children and old people as they can avoid using the electrical switches to control home appliance

|4 ©Daffodil International University

CHAPTER 2 HARDWARE DESIGN 2.1 Introduction Hardware design is one of the most crucial part of this work. But before getting into the technical details block diagram of complete system and its connection should be studied. Then the circuit be

diagram of various

discussed. In this chapter, hardware

module and working principle will

description

of the system is

provided.

Then the design cost analyzed to study its feasibility of application in the real life.

2.2 Block diagram of the system Fig 2.1 shows the simple block diagram of the system. The diagram depicts basic connection and data flow across the system. In my system the Arduino which contains a microcontroller (ATmega328) hosts the relay module which has 10 channels and the sensor module. The sensor module contains three different sensors to sense the environment of the home those are Temperature sensor, Ambient light sensor and flame sensor. The microcontroller drives and controls these components, like switching the state of relay and reading the values from the sensors. Now the Arduino is connected to the Raspberry Pi3 a SCC via I2C bus. Raspberry Pi and Arduino talks over I2C bus, in the bus Raspberry Pi3 is acting as a master and Arduino is acting as slave. Raspberry Pi3 is running by Windows IoT core OS and an UWP application to provide graphical user interface (GUI) and to provide voice command feature. The can be controller through a computer, mobile, Xbox and other devices running on windows 8 or later version which is connected to the home network. The Universal Windows Platform is designed to perform on wide range of Computer and portable devices which are being powered by Microsoft Windows operating system. UWP application will run on Both Headed and Headless devices However this same work can be done remotely through internet and with the help on Microsoft azure cloud service and other cloud services for IoT applications.

|5 ©Daffodil International University

Fig 2.1:Block Diagram of The Complete System

For better accessibility and to provide hands free feature this system has voice command system. The user can communicate with the system through the voice recognition system.

2.2.1 Circuit diagram of complete system Now we will go little deep into the system’s hardware configuration with all the major and minor components it consists of. Fig 2.2 shows the circuitry diagram of the system. In the power supply module transformer is being powered by AC current thus the transformer converts it into DC current. Then the DC current is supplied to a bridge rectifier in order to rectify the signal. The current is sent to the capacitor to cancel out noise (ripple) in the signal. There are 3 three terminal positive regulators LM 7808 , LM 7805 ,LM7805 which supplies 8v,5v and 5v respectively. Since we need 3 power supply line for Arduino, Pi and Relay module. Each of these output line are connected to another capacitor with small capacity for further improvement of the overall output current. This powers our 3 main component Raspberry Pi3, Arduino and Relay board. The sensors are powered from the Arduino’s 5v output pin and the ground reference which is 0v is being taken from the Arduino board. All the sensors in the sensor module are sharing the same voltage |6 ©Daffodil International University

supply line and ground reference. H However owever these 3 sensors has their 3 separate signal output line

Fig 2.2: Circuit Diagram of Complete System for sending the sensor measurement, which are connected to 3 different analog input pin of Arduino. The relay module consists of 10 relay chann channel el each of them are connected to 10 digital output pin of Arduino. In order to communicate between Pi3 and Arduino there is I2C bus installed. This bus consists of two wire one is serial data line (SDA) and another is serial clock line (SCL) however this bus also need to connect the ground reference and the 5v line via two pull pull-up up resistor of 4.7K.

|7 ©Daffodil International University

2.2.2 Circuit diagram main p power supply In this sub section narrates the complete details of the power supply module of the system. In the power supply modu module le a step down transformer (in our case 220V/12V,AC, 50Hz,

3A ) is being powered by 220V AC current thus the

transformer converts it into 12V 3Amp DC current. Then the DC current is supplied to a full wave bridge rectifier ((see the section below) in order der to rectify the signal (as shown in Fig.2.6). The current is sent to the 25V 1000MFD capacitor to cancel out noise (ripple) in the signal

Fig 2.3 2.3: Circuit Diagram Main Power Supply There are 3 three terminal positive regulators LM7808, LM7805, LM7805 which supplies 8V-1Amp, 5V-1Amp 1Amp and 5V 5V-1Amp 1Amp respectively. Since we need 3 power supply line for Arduino, Pi and Relay module. Each of these output line are connected to another 25V 100MFD capacitor with small capacity for further improvement of the

|8 ©Daffodil International University

overall output current. There a LED connected with a resistor of 1K ohm (as shown in Fig.2.3) to indicate the power up state of the module.

Full wave bridge rectifier A Full wave rectifier is a circuit arrangement which makes use of both half cycles of input alternating current (AC) and converts them to direct current (DC). In our tutorial on half wave rectifiers, we have seen that a half wave rectifier makes use of only one half cycle of the input alternating current. Thus a full wave rectifier is much more efficient (double+) than a half wave rectifier. This process of converting both half cycles of the input supply (alternating current) to direct current (DC) is termed full wave rectification. This type of single phase rectifier uses four individual rectifying diodes connected in a closed loop “bridge” configuration to produce the desired output. The main advantage of this bridge circuit is that it does not require a special centre tapped transformer, thereby reducing its size and cost. The single secondary winding is connected to one side of the diode bridge network and the load to the other side as shown below in Fig. 2.4

Fig 2.4: Full Wave Bridge Rectifier The four diodes labeled D1 to D4 are arranged in “series pairs” with only two diodes conducting current during each half cycle. During the positive half cycle of the supply, diodes D1 and D2 conduct in series while diodes D3 and D4 are reverse biased and the current flows through the load as shown below in Fig 2.5. |9 ©Daffodil International University

The positive half-cycle:

Fig. 2.5: The Positive Half-cycle of Full Wave Bridge Rectifier

During the negative half cycle of the supply, diodes D3 and D4 conduct in series, but diodes D1 and D2 switch “OFF” as they are now reverse biased. The current flowing through the load is the same direction as before. The negative half-cycle:

Fig. 2.6: The Negative Half-cycle of Full Wave Bridge Rectifier As the current flowing through the load is unidirectional, so the voltage developed across the load is also unidirectional the same as for the previous two diode full-wave rectifier, therefore the average DC voltage across the load is 0.637Vmax. Full-wave rectifier with smoothing capacitor:

|10 ©Daffodil International University

Fig. 2.7: Operation of Bridge Rectifier The smoothing capacitor converts the full-wave rippled output of the rectifier into a smooth DC output voltage. Generally for DC power supply circuits the smoothing capacitor is an Aluminum Electrolytic type that has a capacitance value of 100uF or more with repeated DC voltage pulses from the rectifier charging up the capacitor to peak voltage. However, there are two important parameters to consider when choosing a suitable smoothing capacitor and these are its Working Voltage, which must be higher than the no-load output value of the rectifier and its Capacitance Value, which determines the amount of ripple that will appear superimposed on top of the DC voltage. Too low a capacitance value and the capacitor has little effect on the output waveform. But if the smoothing capacitor is sufficiently large enough (parallel capacitors can be used) and the load current is not too large, the output voltage will be almost as smooth as pure DC. As a general rule of thumb, we are looking to have a ripple voltage of less than 100mV peak to peak. The maximum ripple voltage present for a Full Wave Rectifier circuit is not only determined by the value of the smoothing capacitor but by the frequency and load current, and is calculated as:

=



, Volts

(2.1) |11

©Daffodil International University

Where: I is the DC load current in amps, ƒ is the frequency of the ripple or twice the input frequency in Hertz, and C is the capacitance in Farads. The main advantages of a full full-wave wave bridge rectifier is that it has a smaller AC ripple value for a given load and a smaller reservoir or smoothing capacitor than an equivalent half-wave wave rectifier. Therefore, the fundamental frequency of the ripple voltage is twice that of the A AC C supply frequency (100Hz) where for the half-wave half rectifier it is exactly equal to the supply frequency (50Hz).

2.2.3 Circuit diagram of sensor m module In this sub section discussion over the sensor module will be made. There are 3 sensor in this sensor module.. First one is Ambient Light sensor which is a Light Dependent Resistor (LDR),Second ,Second one is temperature sensor LM LM35,and ,and third one is flame sensor based on infrared radiation detection. The Flame Sensor can be used to detect fire source or other lightt sources of the wavelength in the range of 760nm - 1100 nm. These sensor are powered from the Arduino’s 5v output pin and the ground reference which is 0v is being taken from the Arduino board. All the sensors in the sensor module are sharing the same vol voltage tage supply line and ground reference.

Fig. 2.8: Sensor M Module ( Light, Temperature, Flame ) |12 ©Daffodil International University

However these 3 sensors has their 3 separate signal output line . The temperature sensor is connected to the A1 analog input pin of the Arduino , LDR is connected to the A0 analog input pin of the Arduino and flame sensor is connected to the A2 analog input pin of the Arduino.

Light dependent resistor/Light sensor A photoresistor (or light-dependent resistor, LDR, or photocell) is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photoconductivity. A photoresistor can be applied in light-sensitive detector circuits, and light- and dark-activated switching circuits. A photoresistor is made of a high resistance semiconductor. In the dark, a photoresistor can have a resistance as high as several mega ohms (MΩ), while in the light, a photoresistor can have a resistance as low as a few hundred ohms. If incident light on a photoresistor exceeds a certain frequency, photons absorbed by the semiconductor give bound electrons enough

Fig. 2.9 : Light Dependent Resistor energy to jump into the conduction band. The resulting free electrons (and their hole partners) conduct electricity, thereby lowering resistance. The resistance |13 ©Daffodil International University

range and sensitivity of a photoresistor can substantially differ among dissimilar devices. Moreover, unique photoresistor may react substantially differently to photons within certain wavelength bands. A photoelectric device can be either intrinsic or extrinsic. An intrinsic semiconductor has its own charge carriers and is not an efficient semiconductor, for example, silicon. In intrinsic devices the only available electrons are in the valence band, and hence the photon must have enough energy to excite the electron across the entire band gap. Extrinsic devices have impurities, also called dopants, and added whose ground state energy is closer to the conduction band; since the electrons do not have as far to jump, lower energy photons (that is, longer wavelengths and lower frequencies) are sufficient to trigger the device. If a sample of silicon has some of its atoms replaced by phosphorus atoms (impurities), there will be extra electrons available for conduction. This is an example of an extrinsic semiconductor.[2]

LM35 integrated-circuit The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly-proportional to the Centigrade temperature. The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling.

Fig. 2.10 : LM35 Integrated-Circuit The LM35 device does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full −55°C to 150°C |14 ©Daffodil International University

temperature range. Lower cost is assured by trimming and calibration at the wafer level. The low-output impedance, linear output, and precise inherent calibration of the LM35 device makes interfacing to readout or control circuitry especially easy. The device is used with single power supplies, or with plus and minus supplies. As the LM35 device draws only 60 µA from the supply, it has very low self-heating of less than 0.1°C in still air. The LM35 device is rated to operate over a −55°C to 150°C temperature range, while the LM35C device is rated for a −40°C to 110°C range (−10° with improved accuracy). The LM35-series devices are available packaged in hermetic TO transistor packages, while the LM35C, LM35CA, and LM35D devices are available in the plastic TO-92 transistor package. The LM35D device is available in an 8-lead surface-mount small-outline package and a plastic TO-220 package.[3]

Flame sensor The Grove - Flame Sensor can be used to detect fire source or other light sources of the wavelength in the range of 760nm - 1100 nm. It is based on the YG1006 sensor which is a high speed and high sensitive NPN silicon phototransistor. Due to its black epoxy, the sensor is sensitive to infrared radiation. In fire fighting robot game, the sensor plays a very important role, it can be used as a robot eyes to find the fire source.

Fig. 2.11: Flame Sensor

|15 ©Daffodil International University

2.2.4 Relay A relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a switch, but other operating principles are also used, such as solid-state relays. Relays are used where it is necessary to control a circuit by a separate low-power signal, or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits as amplifiers: they repeated the signal coming in from one circuit and re-transmitted it on another circuit. Relays were used extensively in telephone exchanges and early computers to perform logical operations. A type of relay that can handle the high power required to directly control an electric motor or other loads is called a contactor. Solid-state relays control power circuits with no moving parts, instead using a semiconductor device to perform switching. Relays with calibrated operating characteristics and sometimes multiple operating coils are used to protect electrical circuits from overload or faults; in modern electric power systems these functions are performed by digital instruments still called "protective relays". Magnetic latching relays require one pulse of coil power to move their contacts in one direction, and another, redirected pulse to move them back. Repeated pulses from the same input have no effect. Magnetic latching relays are useful in applications where interrupted power should not be able to transition the contacts.

Fig. 2.12: Relay |16 ©Daffodil International University

Magnetic latching relays can have either single or dual coils. On a single coil device, the relay will operate in one direction when power is applied with one polarity, and will reset when the polarity is reversed. On a dual coil device, when polarized voltage is applied to the reset coil the contacts will transition. AC controlled magnetic latch relays have single coils that employ steering diodes to differentiate between operate and reset commands.[4]

2.3 Arduino Uno R3 /Atmel ATmega 328 The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega8U2 programmed as a USBto-serial converter.

Fig. 2.13: Arduino UNO R3 |17 ©Daffodil International University

Technical specification Microcontroller

ATmega328

Operating Voltage

5V

Input Voltage (recommended)

7-12V

Input Voltage (limits)

6-20V

Digital I/O Pins

14 (of which 6 provide PWM output)

Analog Input

Pins 6

DC Current per I/O

Pin 40 mA

DC Current for

3.3V Pin 50 mA

Flash Memory

32 KB of which 0.5 KB used by boot loader

SRAM

2 KB

EEPROM

1 KB

Clock Speed

16 MHz

Power The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically. External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector. The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts. The power pins are as follows: 

VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.

|18 ©Daffodil International University



5V. The regulated power supply used to power the microcontroller and other components on the board. This can come either from VIN via an on-board regulator, or be supplied by USB or another regulated 5V supply.



3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.



GND. Ground pins.

Memory The Atmega328 has 32 KB of flash memory for storing code (of which 0,5 KB is used for the bootloader); It has also 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

Input and output Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 k Ohms. In addition, some pins have specialized functions: 

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. T These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip .



External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt () function for details.



PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite () function.



SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language. |19

©Daffodil International University



LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off. The Uno has 6 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function.



I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library.

Additionally, some pins have specialized functionality: There are a couple of other pins on the board: 

AREF. Reference voltage for the analog inputs. Used with analogReference ().



Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.

Communication The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this serial communication over USB and appears as a virtual com port to software on the computer. The '8U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows, an *.inf file is required.. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1). A Software Serial library allows for serial communication on any of the Uno's digital pins. The ATmega328 also support I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus; |20 ©Daffodil International University

2.4

Raspberry Pi3

The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries. The original model became far more popular than anticipated,]selling outside of its target market for uses such as robotics and domatics . Peripherals (including keyboards, mice and cases) are not included with the Raspberry Pi..

Specifications: SoC: Broadcom BCM2837 CPU: 4× ARM Cortex-A53, 1.2GHz GPU: Broadcom VideoCore IV RAM: 1GB LPDDR2 (900 MHz) Networking: 10/100 Ethernet, 2.4GHz 802.11n wireless Bluetooth: Bluetooth 4.1 Classic, Bluetooth Low Energy Storage: microSD GPIO: 40-pin header, populated Ports: HDMI, 3.5mm analogue audio-video jack, 4× USB 2.0, Ethernet, Camera Serial Interface (CSI), Display Serial Interface (DSI)

Wireless radio The Broadcom BCM43438 chip provides 2.4GHz 802.11n wireless LAN, Bluetooth Low Energy, and Bluetooth 4.1 Classic radio support. Built directly onto the board. its only unused feature is a disconnected FM radio receiver.(shown in Fig.2.12)

Fig. 2.14: Raspberry Pi3 on Board Wireless Radio Chip |21 ©Daffodil International University

Antenna There’s no need to connect an external antenna to the Raspberry Pi 3. Its radios are connected to this chip antenna soldered directly to the board, in order to keep the size of the device to a minimum. Despite its diminutive stature, this antenna should be more than capable of picking up wireless LAN and Bluetooth signals – even through walls.

SoC Built specifically for the new Pi 3, the Broadcom BCM2837 (shown in Fig.2.13) system-on-chip (SoC) includes four high-performance ARM Cortex-A53 processing cores running at 1.2GHz with 32kB Level 1 and 512kB Level 2 cache memory, a VideoCore IV graphics processor, and is linked to a 1GB LPDDR2 memory module on the rear of the board.

Fig. 2.15: Raspberry Pi3 System on a chip (SOC)

GPIO The Raspberry Pi 3 features the same 40-pin general-purpose input-output (GPIO) header as all the Pi’s going back to the Model B+ and Model A+. Any existing GPIO hardware will work without modification; the only change is a switch to which UART is exposed on the GPIO’s pins, but that’s handled internally by the operating system.

|22 ©Daffodil International University

USB chip The Raspberry Pi 3 shares the same SMSC LAN9514 chip as its predecessor, the Raspberry Pi 2, adding 10/100 Ethernet connectivity and four USB channels to the board. As before, the SMSC chip connects to the SoC via a single USB channel, acting as a USB-to-Ethernet adaptor and USB hub.

2.5 Cost Analysis of The Hardware To design the hardware, the following components are required:  Raspberry Pi3 Model B Quantity:1 pc Cost: 4000.00  Arduino UNO R3(China) Quantity:1 pc Cost: 600.00  10 Channel Relay Module Quantity:1 pc Cost: 800.00  Transformer (12V,3A) Quantity:1 pc Cost: 120.00  Light Dependent Resistor(LDR) Quantity:1 pc Cost: 5.00  Grove Flame Sensor Quantity:1 pc Cost: 900.00  Temperature Sensor(LM35) Quantity:1 pc Cost: 60.00  Linear Voltage Regulator IC(7808) Quantity:1 pc Cost: 40.00 |23 ©Daffodil International University

 Linear Voltage Regulator IC(7805) Quantity:2 pc Cost: 70.00  Microphone Quantity:1 pc Cost: 350.00  Acrylic Box Quantity:1 pc Cost: 850.00  Miscellaneous Quantity: N/A Cost: 2000.00 So, Total cost is 9795 (Nine thousand Seven hundred ninety five taka only ). This cost is very reasonable

|24 ©Daffodil International University

CHAPTER 3 SOFTWARE DESIGN AND IMPLEMENTATION

3.1 Introduction In the software part of this project there are two block of program/code are running in two different device across the entire system. A Arduino sketch (see APPENDIX E) on the Arduino UNO R3 which based on C/C++ language and another Universal Windows Platform application Based on the language C# and .NET framework running on the raspberry pi3.We will mainly focus on the UWP application on this section.

3.2 Overall description In this Sub section I will discuss about the overall description of the application software.

List of technology used Language: C# Framework: .NET Platform: Universal Windows Platform IDE: Microsoft Visual Studio Community 2015

3.2.1 Product perspective The perspective of the application is to provide a user friendly graphical user interface through which user can create different room assigning the specific I2C bus address , add device under the room scope assigning specific Pin number ,send command to carry out the task and to view the sensor data in presentable format. This piece of software will also facilitate the communication of Arduino and raspberry pi3 through the I2C bus. Beside facilitating the Voice recognition system.

3.2.2 Product functions There are few basic functionality which will be handle by the application. some of them listed below     

Provide Graphical user interface for rooms, devices , device control. Monitoring facility of sensor values Control the devices in other words control the specific digital pin status Facilitate the communication between Arduino and raspberry pi3 Facilitate Voice recognition system

|25 ©Daffodil International University

3.2.3 Class diagram Class diagram of the universal windows platform applic application ation is given below: below

Fig. 3.1: Class Diagram of UWP Application.

|26 ©Daffodil International University

3.2.4 Operating environment This application is designed to build on universal windows platform so it can have the advantage of ruining on every device that installed with Microsoft windows operating system such as computer, laptop, tab, mobile phone, SBC . Which gives the application a wide range of device coverage. Windows 8 or later version of windows operating system is need for the application. In the context of this project the application will run on a raspberry pi3 which is powered by windows IoT core operating system.

3.2.5 Design and implementation constraints In the context of this project, Due to limited CPU speed/processing power and RAM resource limitation in raspberry pi3 this application’s may not serve its best performance. Further improvement in UI and graphical content may cause failure to run this application on raspberry pi3.

3.3 External interface requirements In his sub section we will discuss about the interfaces of the application with different user ,software, hardware and communication interfaces in details. Also the communication flow between different interfaces.

3.3.1 User interface User interface is an interface through which user will communicate with the system. In general we have 4 different user interfaces in this application. The home screen, setting interface for the overall setting of the application , and a room list interface and device state and sensor reading interface. Fig. 3.2, Fig.3.3, Fig. 3.4 shows the interfaces for home screen , room and setting

Fig. 3.2:Home screen Interface

|27 ©Daffodil International University

Fig. 3.2:Room/Device control Interface

Fig. 3.2: Application Configuration Interface

|28 ©Daffodil International University

3.3.2 Hardware interface While this application will be running on raspberry pi3 it will communicate or will be interfacing

with

microphone

through

the

speech

recognition

library

“Windows.Media.SpeechRecognition;” of .NET frame work. It will take voice as input from the microphone and convert it to text through speech recognition engine of .NET framework. The app is also going to communicate with a Arduino with the GPIO of the raspberry pi3 using our self defined protocol and I2C bus a physical medium.

3.3.3 Software interfaces This application was developed in C# language as this is the native langue of .NET framework. There few library used for different process such as “Windows.UI.Xaml;” for XAML support and UI component ,”Windows.UI.Xaml.Controls;” for controlling, System.IO; for basic input and output operation.

|29 ©Daffodil International University

CHAPTER 4 COMMUNICATION

4.1 Introduction In this system the raspberry pi3 we initially interact with the user, in other word user will interact with this system through the UWP application’s Graphical user interface from raspberry pi3 itself or from other device. However user also can use the voice control system. All these input will be processed in raspberry pi3 until it takes the form which can be understood by the Arduino/microcontroller (ATmega328). Then this input will be sent to the Arduino through I2C bus to carry out the specific task. Furthermore the data of sensor reading and device state of the different relay channel that are being collected by the Arduino also need to be sent to the raspberry pi3 to show in the control application. This data are also sent through the I2C bus from Arduino to raspberry pi3.

4.2 I2C bus The physical I2C bus This is just two wires, called SCL and SDA. SCL is the clock line. It is used to synchronize all data transfers over the I2C bus. SDA is the data line. The SCL & SDA lines are connected to all devices on the I2C bus. There needs to be a third wire which is just the ground or 0 volts. There may also be a 5volt wire is power is being distributed to the devices. Both SCL and SDA lines are "open drain" drivers. What this means is that the chip can drive its output low, but it cannot drive it high. For the line to be able to go high you must provide pull-up resistors to the 5v supply. There should be a resistor from the SCL line to the 5v line and another from the SDA line to the 5v line. only need one set of pull-up resistors for the whole I2C bus, not for each device, as illustrated below:

Fig. 4.1: I2C Bus Line Configuration |30 ©Daffodil International University

The value of the resistors is not critical. I have seen anything from 1k8 (1800 ohms) to 47k (47000 ohms) used.

Masters and Slaves The devices on the I2C bus are either masters or slaves. The master is always the device that drives the SCL clock line. The slaves are the devices that respond to the master. A slave cannot initiate a transfer over the I2C bus, only a master can do that. There can be, and usually are, multiple slaves on the I2C bus, however there is normally only one master. It is possible to have multiple masters, but it is unusual and not covered here. On your robot, the master will be your controller and the slaves will be our modules such as the SRF08 or CMPS03. Slaves will never initiate a transfer. Both master and slave can transfer data over the I2C bus, but that transfer is always controlled by the master.

4.3 The I2C physical protocol when the master (controller) wishes to talk to a slave (our CMPS03 for example) it begins by issuing a start sequence on the I2C bus. A start sequence is one of two special sequences defined for the I2C bus, the other being the stop sequence. The start sequence and stop sequence are special in that these are the only places where the SDA (data line) is allowed to change while the SCL (clock line) is high (Fig. 4.2). When data is being transferred, SDA must remain stable and not change whilst SCL is high. The start and stop sequences mark the beginning and end of a transaction with the slave device.

Fig. 4.2: I2C Bus Clock Synchronization |31 ©Daffodil International University

Data is transferred in sequences of 8 bits. The bits are placed on the SDA line starting with the MSB (Most Significant Bit). The SCL line is then pulsed high, then low. Remember that the chip cannot really drive the line high, it simply "lets go" of it and the resistor actually pulls it high. For every 8 bits transferred, the device receiving the data sends back an acknowledge bit(as shown in Fig. 4.3), so there are actually 9 SCL clock pulses to transfer each 8 bit byte of data. If the receiving device sends back a low ACK bit, then it has received the data and is ready to accept another byte. If it sends back a high then it is indicating it cannot accept any further data and the master should terminate the transfer by sending a stop sequence.

Fig. 4.3: I2C Bus Data Sequence

Bus speed The standard clock (SCL) speed for I2C up to 100KHz. Philips do define faster speeds: Fast mode, which is up to 400KHz and High Speed mode which is up to 3.4MHz. All of our modules are designed to work at up to 100KHz. We have tested our modules up to 1MHz but this needs a small delay of a few uS between each byte transferred. In practical robots, we have never had any need to use high SCL speeds. Keep SCL at or below 100KHz and then forget about it.

I2C Device addressing All I2C addresses are either 7 bits or 10 bits. The use of 10 bit addresses is rare thus not covered here. All of our modules and the common chips we will use will have 7 |32 ©Daffodil International University

bit addresses. This means that you can have up to 128 devices on the I2C bus, since a 7bit number can be from 0 to 127. When sending out the 7 bit address, we still always send 8 bits. The extra bit is used to inform the slave if the master is writing to it or reading from it. If the bit is zero the master is writing to the slave. If the bit is 1 the master is reading from the slave. The 7 bit address is placed in the upper 7 bits of the byte and the Read/Write (R/W)(as shown in Fig. 4.4) bit is in the LSB (Least Significant Bit).

Fig. 4.4: I2C Bus Data Sequence bit Orientation

The placement of the 7 bit address in the upper 7 bits of the byte is a source of confusion for the newcomer. It means that to write to address 21, you must actually send out 42 which is 21 moved over by 1 bit. It is probably easier to think of the I2C bus addresses as 8 bit addresses, with even addresses as write only, and the odd addresses as the read address for the same device. To take our CMPS03 for example, this is at address 0xC0 ($C0). You would uses 0xC0 to write to the CMPS03 and 0xC1 to read from it. So the read/write bit just makes it an odd/even address.

4.3 Communication protocol First we need to decide how the pi and Arduino going to talk. To make a reliable protocol, we must first have clear objectives or goals for the communication. In consideration of this project, the approximate goals can be following: 

Read sensors



Read device's state |33

©Daffodil International University



Set device state

Protocol defines rules to communicate over the bus. Protocol is nothing more than byte sequence. I have defined protocol for sending and receiving bytes. Sending bytes are fixed of three(Fig,4.4) while receiving byte array is of fourteen bytes. Refer following schematics to understand protocol defined for this project ('X' denotes random value or '0', it will be ignored while communicating):

Fig. 4.5: Structure of Request Command Byte Array

|34 ©Daffodil International University

Fig. 4.6: Structure of Response Byte Array In Fig 4.5 narrates the response structure of different mode setting. At Mode 0 the Arduino sends the sensor values to Pi. At Mode 1 Arduino sends the device state connected to it. At Mode 2 Arduino sends the changed status of the specific device after updating.

|35 ©Daffodil International University

CHAPTER 5 SYSTEM DEPLOYMENT AND TEST RESULT 5.1 Introduction In this chapter we will discuss about the deployment of the system and the test results that generated in the system testing phase of the whole system in different case scenario.

5.2 Deployment of the system I have installed the raspberry Pi3 ,Arduino ,Relay and other components as described in the chapter 2 . The main power supply board will power up all the components. Then these components are placed into a acrylic box for durability and safety issues. The raspberry Pi3 is loaded with our UWP controlling application which was deployed through Microsoft Visual Studio 2015 Community version IDE since the software application was developed in this IDE. After Complete deployment the we will push the system through a test.

Figure. 5.1 : Original system photograph

|36 ©Daffodil International University

5.3 Testing of the system For the test purpose we have connected a light to relay channel 1 which is connected to the arduino’s digital pin 3 and a fan to relay channel 2 which is connected to the arduino’s digital pin 4. Now we will test the system by sending command from our UWP controlling application via both graphical user interface and voice command. Table 5.1 shows that the system is working properly according to its operation described in earlier chapters. Table. 5.1 : Test result of the system Serial Number

Input Method

1

GUI

2

GUI

3

GUI

4

5

6

7

8

User Action Create room Adding device to the room

Monitorin g the sensor update GUI Light button clicked(on ) GUI Fan button clicked(on ) GUI Light button clicked(of f) GUI Fan button clicked(of f) Voice Turn on command the light(Digit al pin 3 )

Input Parameter

Sensor Readin g -

Relay Statu s OFF

-

OFF

Updated

OFF

Digital pin Updated value = 1

ON

Digital pin Updated value = 1

ON

Fan turned ON

Digital pin Updated value = 0

OFF

Light turned OFF

Digital pin Updated value = 0

OFF

Fan turned OFF

ON

Light turned ON

I2C bus address Digital pin number correspondin g to Light connected relay channel -

“Light on”

Updated

Status Room created successfull y Device added successfull y Sensor reading is updating properly Light turned ON

|37 ©Daffodil International University

9

10

11

Voice Turn on command the fan(Digita l pin 4 ) Voice Turn on command the light(Digit al pin 3 ) Voice Turn on command the light.

“Fan on”

Updated

ON

Fan turned ON

“Light off”

Updated

ON

Light turned OFF

“Fan off”

Updated

ON

Fan turned OFF

5.4 Summary In this chapter I have described how the hardware is implementation is done and the testing result of the system. Test result are summarized in tabular form also. The tabular data shows that the system is working as indented from both medium of input and the system output was relevant.

|38 ©Daffodil International University

CHAPTER 6 CONCLUSION 6.1 Conclusion In this work I have developed a interactive home automation system that can be driven from both controlling application and also voice command. Voice command feature will greatly help the people who are handicap ,disabled or old people. Its also provides some extend of safety measure for children and old people as they can avoid using the electrical switches to control home appliance .

6.2 Limitation of the proposed system The components and relay used in this system has a power rate up to 2 KW. Thus this system is not applicable for high powered electrical appliance or component. If any one wish to use this system with load heavier than 2KW then only the relay channel need to changed. This system is only capable to detect the state of gas burner it cannot turn ON or OFF the gas burner as our burners are not advance enough to take response from the system.

6.2 Recommendation for future work The possibilities of the home summation system are endless. We can integrate almost everything of our daily life to this system to work them more efficiently and to make them intelligent to carry out their task by own. One of the major future work could be developing a Android application to interact with this system as its is the most widely use portable device platform. Some other possible enhancement of the system listed below 

Updated Things like Coffee machine , Washing machine can be added to this system to control them through this device .



Home with solar power and other renewable energy system can be added to monitor and control via this device.



This system can extended to manage automated inventory system.

|39 ©Daffodil International University



This system can be used to communicate with smart vehicle

to get

notification about fuel and other status . 

Can provide Prior Notification of the traffic on the road depending on local or regional traffic API.

 Other home security system can be ingrate to this system to make home more safer

|40 ©Daffodil International University

REFERENCES [1]Home Automation. n.d. in Wikipedia. Retrieved March 25, 2017 From https://en.wikipedia.org/wiki/Home_automation [2] Diffenderfes, Robert (2005). Electronic Devices: System and Applications. New Delhi: Delimar. p. 480. ISBN 978-1401835149. [3] LM35 Texas Instruments technical documents (AUGUST 2016) Retrieved March 25, 2017 From http://www.ti.com/product/LM35 [4] Relay. n.d. in Wikipedia. Retrieved March 25, 2017 From https://en.wikipedia.org/wiki/Relay [5] Ahmed ElShafee, Karim Alaa Hamed,” Design and Implementation of a WiFi Based Home Automation System”, International Journal of Computer, Electrical, Automation, Control and Information Engineering Vol: 6, No: 8, 2012 [6] Hayet Lamine and Hafedh Abid , ”Remote control of a domestic equipment from an Android application based on Raspberry pi card”, IEEE transaction 15th international conference on Sciences and Techniques of Automatic control & computer engineering STA'2014, Hammamet, Tunisia, December 21-23, 2014 [7] Jain Sarthak,Vaibhav Anant and Goyal Lovely ,“Raspberry Pi based Interactive Home Automation System through E-mail.”,IEEE transaction,2014 International Conference on Reliability, Optimization and Information Technology ICROIT 2014, India, Feb 68 2014 [8] Shih-Pang Tseng, Bo-Rong Li, Jun-Long Pan, and Chia-Ju Lin,”An Application of Internet of Things with Motion Sensing on Smart House“, 978-1-4799-62846/14 c ⃝ 2014 IEEE [9] Kim Baraka, Marc Ghobril, Sami Malek, Rouwaida Kanj, Ayman Kayssi “Low cost Arduino/Android-based Energy-Efficient Home Automation System with Smart Task Scheduling” , 2013 Fifth International Conference on Computational Intelligence, Communication Systems and Networks. [10] R.Pivare, M.Tazil,”Bluetooth Based Home Automation System Using Cell Phone”, 2011, IEEE 15th International Symposium on Consumer Electronics Singapore. . [11] Jan Gebhardt, Michael Massoth, Stefan Weber and Torsten Wiens , “Ubiquitous Smart Home Controlling Raspberry Embedded System”, UBICOMM: The Eighth International Conference on Mobile Ubiquitous Computing, Systems, Services and Technologies, 2014. [12] R. Harper, Inside the Smart Home, 2003. [13] N.-O. Skeie, Object-Oriented Analysis, Design, and Programming using UML and C#, 2014 [14] Arduino. (2015). Arduino. Available: https://www.arduino.cc/Hacking [15] Raspberry, "Raspberry Pi 2 Model B," 2015. |41 ©Daffodil International University

APPENDIX A LM7808 3-Terminal 1A Positive Voltage Regulator Features     

Output Current up to 1A Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24 Thermal Overload Protection Short Circuit Protection Output Transistor Safe Operating Area Protection

|42 ©Daffodil International University

APPENDIX B LM7808 3-Terminal 1A Positive Voltage Regulator Features     

Output Current up to 1A Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24 Thermal Overload Protection Short Circuit Protection Output Transistor Safe Operating Area Protection

|43 ©Daffodil International University

APPINDIX C LM35 Precision Centigrade Temperature Sensors Features       

Calibrated Directly in Celsius (Centigrade) Linear + 10-mV/°C Scale Factor 0.5°C Ensured Accuracy (at 25°C) Rated for Full −55°C to 150°C Range Operates from 4 V to 30 V Less than 60-μA Current Drain Low Self-Heating, 0.08°C in Still Air

|44 ©Daffodil International University

APPENDIX D ATMEL 8-BIT MICROCONTROLLER WITH 4/8/16/32KBYTES IN-SYSTEM PROGRAMMABLE FLASH Features 

Advanced RISC Architecture. – 131 Powerful Instructions – Most Single Clock Cycle Execution – 32 x 8 General Purpose Working Registers – Fully Static Operation – Up to 20 MIPS Throughput at 20MHz – On-chip 2-cycle Multiplier



High Endurance Non-volatile Memory Segments. – 32KBytes of In-System Self-Programmable Flash program Memory – 1KBytes EEPROM – 2KBytes Internal SRAM – Write/Erase Cycles: 10,000 Flash/100,000 EEPROM – Data Retention: 20 years at 85°C/100 years at 25°C(1) – Optional Boot Code Section with Independent Lock Bits In-System Programming by On-chip Boot Program. True Read-While-Write Operation. Atmel® QTouch® Library Support. – Capacitive Touch Buttons, Sliders and Wheels – QTouch and QMatrix® Acquisition – Up to 64 sense channels

  



Peripheral Features. – Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode – One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode – Real Time Counter with Separate Oscillator – Six PWM Channels – 8-channel 10-bit ADC in TQFP and QFN/MLF package

|45 ©Daffodil International University

APPENDIX E Arduino Sketch #include #define _DEBUG_ /* Arduino's I2C Slave Address */ #define SLAVE_ADDRESS 0x40 /* PIN DECLARATION */ int Pin_AmbientLight_LDR = A0; int Pin_PassiveIR = A3; int Pin_Temperature = A1; /* Global Variable */ volatile short Value_AmbientLight_LDR, Value_Temperature; volatile bool Value_PassiveIR; volatile short temp_Value_PassiveIR; /* Protocol Variable */ byte Mode, Pin, Value; byte Response[14]; void setup() { // Initialize pins pinMode(Pin_AmbientLight_LDR, INPUT); pinMode(Pin_PassiveIR, INPUT); pinMode(Pin_Temperature, INPUT); pinMode(0, OUTPUT); pinMode(1, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(2, OUTPUT); pinMode(13, OUTPUT); |46 ©Daffodil International University

# ifdef _DEBUG_ Serial.begin(9600); #endif // Initialize I2C Slave on address 'SLAVE_ADDRESS' Wire.begin(SLAVE_ADDRESS); Wire.onRequest(SendData); Wire.onReceive(ReceiveData); } void loop() { // Read LDR // Arduino supports 10-bit Analog Read. // Thus we need to convert it into 8-bit. Value_AmbientLight_LDR = analogRead(Pin_AmbientLight_LDR); Value_AmbientLight_LDR = map(Value_AmbientLight_LDR, 0, 1023, 0, 255); //Serial.print(Value_AmbientLight_LDR); // Read PassiveIR value temp_Value_PassiveIR = analogRead(Pin_PassiveIR); Serial.print(temp_Value_PassiveIR); Serial.println(""); if(temp_Value_PassiveIR