Introduction: Home/Office Automation

This instructable offers a detailed description and implementation of using an Arduino for Home/Office Automation and Efficiency. This project is designed and intended to make life simpler, make things easier for the elderly and handicapped, and to save energy costs. The idea of an office automation system will definitely improve the working standards in the workplace. The fundamental control system uses a Bluetooth module which gives wireless access to smart phones. The appliances controlled depends on what appliances is plugged into the system. The system design will not remove the existing actuating switches, but rather it will be controlled with a low voltage system technique. This system is designed to control electrical devices throughout the home/office. It will be very easy to install, add or change electrical devices connected to the system. The system can also control lights in the home/office based on the natural light. The lights will also be motion activated meaning that the lights will only be on when people are in the area. The system will be easy to use as well as cost effective. The power for this system will be provided by the mains but in future by renewable energy. The renewable energy that will be used in this system is solar power via solar panels.

Step 1: DEFINITION OF PROBLEMS

Aim

To design an automated system that controls electrical appliances in the office that can be switched on or off using a smartphone or tablet device.

Requirements

Ø Cost effective

Ø Easy to operate

Ø Lights should be on only when motion is detected

Ø Ceiling fans should be switched on/off based on a set temperature

Constraints

Ø Minimal health hazards

Ø Shouldn’t consume more electricity than without the system

Ø Use existing mounts and fixtures

Ø A secondary backup power source must be available

Criteria

Ø Easy to operate

Ø Environmentally friendly

Ø Safe towards the public

Ø Reduce electricity usage

Ø Save money

Ø Low maintenance

Step 2: SOLLUTION SPECIFICATION

Step 3: Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs such as inputs from light sensors, motion sensors, pushbuttons, or a Twitter message. The Arduino can turn these inputs into outputs such as activating a motor, turning on LEDs, or even publish something online. The board can be told what to do by sending a set on instruction to the microcontroller on the board. This is done by using the Arduino programming language and the Arduino Software (IDE) which is based on processing.

Over the years, Arduino has been the brain of thousands of projects, from everyday objects to complex scientific instruments. A global community of students, hobbyists, artists, programmers, and professionals has gathered around this open-source platform. Their contributions have added up to an incredible amount of accessible knowledge that can be of great help to beginners and experts.

Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping, aimed at students without a background in electronics and programming. As it reached a wider community, the Arduino board started changing to adapt to new needs and challenges, differentiating its offer from simple 8-bit boards to products for IoT applications, wearable, 3D printing, and embedded environments. All Arduino boards are completely open-source, empowering users to build them independently and eventually adapt them to their particular needs. The software is open-source, and it is growing through the contributions of users worldwide.

Why Arduino is chosen

Arduino has a simple and accessible user experience and it has been used in thousands of different projects and applications. The Arduino software is easy-to-use for beginners, yet flexible enough for advanced users. It runs on Mac, Windows, and Linux. Teachers and students can use it to build low cost scientific instruments or to get started with programming and robotics. Designers and architects build interactive prototypes, musicians and artists use it for installations and to experiment with new musical instruments. Arduino is a key tool to learn new things.

There are many other microcontrollers and microcontroller platforms available for physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many others offer similar functionality. All of these tools take the messy details of microcontroller programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of working with microcontrollers, but it offers great advantages such as:

· Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules costs around R400.

· Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.

· Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. It's conveniently based on the Processing programming environment, so individuals learning to program in that environment will be familiar with how the Arduino IDE works.

· Open source and extensible software - The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. AVR-C code can be added directly into Arduino programs.

· Open source and extensible hardware - The plans of the Arduino boards are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money.

Step 4: Bluetooth Technology

Bluetooth is a global wireless communication standard that connects devices to each other over a certain distance. It is built into billions of products on the market today.

The key features of Bluetooth technology:

· Less complication

· Less power consumption

· Available at cheaper rates

· Robustness

How does Bluetooth work

Bluetooth sends and receives radio waves in a band of 79 different frequencies (channels) centred on 2.45 GHz, set apart from radio, television, and cell phones, and reserved for use by industrial, scientific, and medical gadgets. Bluetooth's short-range transmitters are one of its biggest plus points. They use virtually no power and, because they don't travel far, are theoretically more secure than wireless networks that operate over longer ranges, such as Wi-Fi.

Bluetooth devices automatically detect and connect to one another and up to eight of them can communicate at any one time. They don't interfere with one another because each pair of devices uses a different one of the 79 available channels. If two devices want to talk, they pick a channel randomly and, if that's already taken, randomly switch to one of the others. This a technique known as spread-spectrum frequency hopping. To minimize the risks of interference from other electrical appliances and also to improve security, pairs of devices constantly shift the frequency they're using thousands of times a second.

What is Bluetooth used for

The first and leading application of Bluetooth technology would be to eliminate the tangling of cables that would mess up the room.

1. Bluetooth’s biggest contribution is to provide a phone with a headset that works wirelessly. This is possible by providing the caller with an earpiece and a small microphone attached to the caller’s shirt. The mobile phone can be located in a bag or anywhere in the body. The caller can dial a number even without touching a button on the mobile phone. This technology has the advantage of eliminating the radiation hitting the cerebral region.

2. PC or laptop which has enabled Bluetooth can communicate with each other and update with its latest information. This technology has helped in synchronizing the data easily.

3. It is difficult to send emails while travelling in a flight. On landing of the flight, the Bluetooth enabled laptop can send the email only when it gets in touch with the user’s phone.

4. Wireless mouse and keyboards are introduced.

5. One will be alerted on his/her mobile phone when your laptop receives the mail.

6. You can try to locate a printer via laptop. You will get the printout of that document once that printer is located.

Importance of Bluetooth in automation

When a group of two or more Bluetooth devices are sharing information together, they form a kind of ad-hoc, mini computer network called a piconet. Other devices can join or leave an existing piconet at any time. One device known as the master acts as the overall controller of the network, while the others known as slaves obey its instructions. Two or more separate piconets can also join up and share information forming what's called a scatternet.

What makes Bluetooth better than other technologies?

The short answer is because Bluetooth is everywhere, it operates on low power, it is easy to use and it doesn’t cost a lot to use. Let’s explore these a bit more.

Bluetooth is everywhere—Bluetooth can be found built into nearly every phone, laptop, desktop and tablet. This makes it so convenient to connect a keyboard, mouse, speakers or fitness band to your phone or computer. Bluetooth is low power—with the advent of Bluetooth Smart (BLE or Bluetooth low energy), developers were able to create smaller sensors that run off tiny coin-cell batteries for months, and in some cases, years. This is setting the stage for Bluetooth as a key component in the Internet of Things. Bluetooth is easy to use—for consumers, it really can’t get any easier. You go to settings, turn on your Bluetooth, hit the pairing button and wait for it start communicating. That’s it. From a development standpoint, creating a Bluetooth product starts with the core specification and then you layer profiles and services onto it. There are several tools that the SIG has to help developers. Bluetooth is low cost—you can add Bluetooth for a minimal cost. You will need to buy a module/system on chip (SoC)/etc. and pay an administrative fee to use the brand and license the technology. The administrative fee varies on the size of the company and there are programs to help start-ups.

Bluetooth Module

The Arduino-Uno board doesn’t support a Bluetooth connection on its own, which makes the idea of connecting it wirelessly to an Android device impossible. So a medium between the Arduino-Uno board and android device is needed and in this project it is a Bluetooth module specifically the HC-06 Bluetooth module.

The HC-06 is a user friendly and needs only basic knowledge and it is programmable using the AT commands. It comes only in one fixed mode either master or slave. In this project the slave module was used.

Step 5: Android

Introduction to Android

Android operating system is open source focused around Linux kernel with Java programming interface planned fundamentally for touch screen contraptions. The Android telephone was in the business sector since October 2008. Gadget producers, remote transporters and fan engineers are permitted to adjust and distribute the product under the Apache License.

Google Play is Android essential application store. There were roughly 700,000 applications accessible for Android in October 2012 and created by a vast group of Android application designer.

Android building design comprises of a few layers as demonstrated in Figure 2.1. The applications need to go layer by layer to get to the hardware. A few libraries are accessible. ARM architecture is the principle equipment platform for Android.

Features and Specifications

Android is a powerful Operating System supporting a large number of applications in Smart Phones. These applications make life more comfortable and advanced for the users. Hardware’s that support Android are mainly based on ARM architecture platform. Some of the current features and specifications of android are:

Android comes with an Android market which is an online software store. It was developed by Google. It allows Android users to select, and download applications developed by third party developers and use them. There are around 2.0 lack+ games, application and widgets available on the market for users.

Android applications are written in java programming language. Android is available as open source for developers to develop applications which can be further used for selling in android market. There are around 200000 applications developed for android with over 3 billion+ downloads. Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. For software development, Android provides Android SDK (Software development kit).

Applications of Android

These are the basics of Android applications:

• Android applications are composed of one or more application components (activities, services, content providers, and broadcast receivers)

• Each component performs a different role in the overall application behaviour, and each one can be activated individually (even by other applications)

• The manifest file must declare all components in the application and should also declare all application requirements, such as the minimum version of Android required and any hardware configurations required

• Non-code application resources (images, strings, layout files, etc.) should include alternatives for different device configurations (such as different strings for different languages)

Step 6: CONCEPT FORMATION - Parts, Tools, and Costing

Parts List

· Arduino Uno

· Breadboard

· Android Cell phone

· Android Application (Google Play Store)

· Matrix Board

· Jumper wires

· AC light bulbs

· AC light bulb holders

· AC fan

· Connector Blocks

· Copper Wire, Solid core

· AC-DC power adapter, 9v @0.5a

· TMP36 Temperature Sensor

· Self-tapping screws

· Continuous rotation Servomotor

· Project Case

· Power Connector, Panel mount

· RGB LED with common anode

· 3 x 10Kohm 1/4watt resistors

· 3 x 100ohm 1/4watt resistors

· 2 pushbuttons

· Male breakaway headers

· 1 x 10Kohm Potentiometer

· Rocker switch

· Heat shrink tubing

· HC-06 Bluetooth Module

· Relay Module

· PIR Motion Sensor

· Photoconductive Cell Sensor

Tools Required

· Soldering iron and solder

· Power Supply

· Wire stripper

· Cordless drill and drill bits

· Screwdrivers

· Rotary Tool

· Needle nose pliers

· Hot glue gun and glue sticks

· Masking tape

· Ruler

· Ink Marker

· Hobby Knife

· Computer loaded with the Arduino IDE

Costing

· Arduino Uno – R254.00

· Breadboard – on hand

· Matrix Board – R30.00

· Jumper wires – R140.00

· AC light bulbs

· AC light bulb holders

· AC fan

· Connector Blocks

· Copper Wire, Solid core – R3.48

· AC-DC power adapter, 9v @0.5a

· TMP36 Temperature Sensor – R18.05

· Self-tapping screws

· Continuous rotation Servomotor – R171.05

· Project Case – R33.00

· Power Connector, Panel mount – R4.00

· RGB LED with common anode

· 3 x 10Kohm 1/4watt resistors – R1.20

· 3 x 100ohm 1/4watt resistors – R1.20

· 2 pushbuttons – R15.00

· Male breakaway headers – R4.00

· 1 x 10Kohm Potentiometer – R7.50

· Rocker switch – R11.20

· Heat shrink tubing – R8.60

· HC-06 Bluetooth Module – R212.60

· 4 Channel Relay Module – R190.00

Step 7: System Design

The figure shows the systematic breakdown of this project. There are two forms of communication in this project, namely wireless and wired connections. The wireless communication will be made possible by the Bluetooth module. The HC-06 Bluetooth module will enable the android smartphone to communicate with the Arduino system wirelessly. The wired connections will be the office electrical appliances that will be switched on/off by the Arduino system.

Step 8: Hardware Implementation

Arduino Uno

The Arduino Uno is a microcontroller board based on the ATmega328. It has a 16 MHz ceramic resonator, 14 digital input/output pins, 6 can be used as PWM outputs, 6 analog inputs, a USB connection, a power jack, an ICSP header, and a reset button. This board is very simple and can be easily used. Everything needed to support the microcontroller is in the board. Plug it in a computer via USB cable and power using an AC-to-DC adapter or battery to power and operate the Arduino.

The difference seen in the Arduino Uno is that it does not use the FTDI USB-to-serial driver chip but, it has the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB- to-serial converter.

Bluetooth Module (HC-06, Slave)

The HC-06 model is a Bluetooth module as shown in the picture below. It is a slave module which means the connection has to be initiated by a master module. In this project the master module is the android device. The Bluetooth module is small in size and its operating voltage is 3.3V which makes it compatible with most microcontrollers with the power of 3.3V. It’s baud rate can be set using the AT commands.

· The core module HC-06 main modules, leads the interface includes VCC, GND, TXD, RXD, KEY pin high trigger to clear the pairing information re search

· LED indicates Bluetooth connection status, flash unpaired slow flash indicates paired but not slave connection, always follow machine connected

· Back plate settings LDO input voltage of 3.6~6V unpaired current is about 30mA, paired 10mA, input voltage prohibit more than 7V absolute prohibition of reverse power!

· Interface level 3.3V, can be directly connected the various SCM (51, AVR, PIC, ARM, MSP430, etc.), the 5V MCU also can be connected directly, without MAX232 cannot go through the MAX232!

· Open to effective distance of 10 meters, over 10 meters is also possible, but not of this the quality of the connection of the distance do to ensure

· The pair later when full-duplex serial use, do not need to know anything about the Bluetooth protocol, but only supports 8 data bits, 1 stop bit, no parity communication format, which is the most commonly used communication format does not support other formats.

· Support to establish a Bluetooth connection through AT commands set the baud rate, passkey, set parameters are saved after. Bluetooth connection is automatically switched to the pass-through mode.

· Wireless serial Bluetooth port with free extension cable.

· With transparent shrink tube, dust and beautiful, and there is a certain degree of anti-static capabilities.

Relay Module

A relay is a device that operates on electricity. It has a control and controlled systems. It is mostly used to control circuit automatically. Basically, it is an automatic switch to control using a low-current signal a high-current circuit.

The relay module used in this project is a 5V 4-Channels Relay module, it can be controlled directly by a wide range of microcontrollers such as Arduino, AVR, PIC, ARM and MSP430. 4 relays are included in this module, with “NC” ports mean “Normally connected to COM” and “NO” ports mean “Normally open to COM”. This module also equipped with 4 LEDS to show the status of relays.

Features

4 mechanical relays with status indicator LED

Both “NC” and “NO” ports for each relay

Specifications

Module Type: Control

Weight: 130.00g

Board Size: 9.1 x 7.2 x 2cm

Version: 1

Operation Level: Digital 5V

Power Supply: External 5V

Method of using the relay module

The power source is connected to the input circuit of the relay. When a small current flows in this circuit, the relay will activate its output circuit, allowing a much bigger current to flow which will switch on the electrical appliances. By connecting the power source to the input of the relay and the electrical appliance is required to be active it must be connected to the normally open pin (NO), otherwise it should be connected to the normally closed pin (NC).

Temperature Sensor (LM35)

A temperature sensor is a device that provides for temperature measurement through an electrical signal. A thermocouple is made from two dissimilar metals that generate electrical voltage in direct proportion to changes in temperature. An RTD (Resistance Temperature Detector) is a variable resistor that will change its electrical resistance in direct proportion to changes in temperature in a precise, repeatable and nearly linear manner.

The LM35 temperature sensor is a precision IC temperature sensor with its output proportional to the temperature (in oC). The sensor circuitry is sealed and therefore it is not subjected to oxidation and other processes. With the LM35, temperature can be measured more accurately than with a thermistor. It also possesses low self-heating and does not cause more than 0.1 oC temperature rise in still air. The operating temperature range is from -55°C to 150°C. The output voltage varies by 10mV in response to every oC rise/fall in ambient temperature. Its scale factor is 0.01V/ oC.

Motion Sensor

PIR -Passive InfraRed sensor is a device used to detect motion by receiving infrared radiation. When a person walks past the sensor, it detects a rapid change of infrared energy and sends a signal. PIR sensors are used for applications such as automatically turning on lights when someone enters a room or causing a video camera to begin operating. This passive method is not as reliable as "active" motion sensors that either bounce back a radar signal or transmit light to a photodetector in the distance

The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected.

In this project a SME digital PIR motion sensor is used. The sensor will be used to switch on the fluorescent lights only when motion is detected thus saving energy when people isn’t in the vicinity.

The SME digital PIR motion sensor is a highly integrated module popularly used for entry detection and it complies with microcontroller or DC loads. There are two adjustable potentiometers on the module. They can be used to change the trigger sensitivity and the duration of the trigger signal.

Specifications

Module Type: Sensor Weight: 15.00g Version 1.0 Operation Level: Digital 5V Power Supply: External 5V Input Voltage: DC 4.5-20V Static current: 50uA Output signal: 0,3V or 5V (Output high when motion detected) View Angle: 110 degree Distance: max 7 m Shunt for setting override trigger: H - Yes, L - No

Light Sensor (Photoconductive Cell Sensor)

Photocells are resistors that changes its resistive value (in ohms Ω) depending on how much light is shining onto the sensor face. They are very low cost, easy to get in many sizes and specifications, but are very inaccurate. Each photocell sensor will act a little differently than the other, even if they are from the same batch. The variations can be really large, 50% or higher. Therefore, they shouldn't be used to try to determine precise light levels in lux or milli-candela. Instead, only basic light changes can be detected.

Features:

· Epoxy encapsulated

· Small dimensions

· Operating temperature -25°C-+75°C.

Applications:

· Contrast control in TV sets

· Auto flash for cameras

· Room light control

· Electronic toys

· Industrial control

Step 9: Android Smartphone and Android Application

In this Project the android phone that will be used as the remote control is a Samsung Galaxy S4. The application on the smartphone that will be used is ArduDroid.

ArduDroid is a simple Android app that allows the pins on the Arduino Uno board to be controlled wirelessly from a smartphone. ArduDroid uses an easy to understand user interface to control the Arduino Uno’s digital and PWM pins. It also allows the user to send text commands to the Arduino Uno and receive data from the Arduino via the Bluetooth serial module.

In this Project the Digital Pin Function is only required to make the system work, so the Arduino-Uno Board will only be programmed to support that feature.

Step 10: Programming the Arduino Uno

In order for the Arduino-Uno board to be able to interact with the application used in this project a program needs to be written and uploaded to the Arduino-Uno.

Arduino Company provides user friendly software which allows writing any code for any function that a user requires the Arduino to perform. This code can be used and uploaded to the Arduino.

Program code

Source code for Arduino

/*

Student Name: Sameer Camroodien

Student No.: 212294644

Year: 2016

Semester: 2

*/

/////////////////////////////////////////////SECTION 1///////////////////////////////////////////

*

In this section, I will set up macro to save RAM on my microcontroller, as we know that the arduino board has a small amount of RAM.

These macros that are set up, will cause a text replace to occur before the code compile. Before the IDE sends the code to the compiler, a pre-processor will go through

and do a simple text-replace od all instance of the macros with either the integer or character assigned to it. in that case, no RAM is consumed by any of the variables.

*/

#define START_CMD_CHAR '*' //wherever START_CMD_CHAR appears in the code, it will be replaced by character '*' before compilation

#define END_CMD_CHAR '#' //wherever END_CMD_CHAR appears in the code, it will be replaced by character '#' before compilation

#define DIV_CMD_CHAR '|' //wherever DIV_CMD_CHAR appears in the code, it will be replaced by character '|' before compilation

#define CMD_DIGITALWRITE 10 //wherever CMD_DIGITALWRITE appears in the code, it will be replaced by interger 10 before compilation

#define CMD_READ_ARDUDROID 13 //wherever CMD_READ_ARDUDROID appears in the code, it will be replaced by integer 13 before compilation

#define MAX_COMMAND 20 //wherever MAX_COMMAND appears in the code, it will be replaced by integer 20 before compilation

#define MIN_COMMAND 10 //wherever MIN_COMMAND 10 appears in the code, it will be replaced by integer 10 before compilation

#define IN_STRING_LENGHT 40 //wherever IN_STRING_LENGHT appears in the code, it will be replaced by integer 40 before compilation

#define MAX_ANALOGWRITE 255 //wherever MAX_ANALOGWRITE appears in the code, it will be replaced by integer 255 before compilation

#define PIN_HIGH 3 //wherever PIN_HIGH appears in the code, it will be replaced by integer 3 before compilation

#define PIN_LOW 2 //wherever PIN_LOW appears in the code; it will be replaced by integer 2 before compilation

////////////////////////////////////////END OF SECTION 1/////////////////////////////////

/////////////////////////////////////SECTION 2////////////////////////////////////////////////

*

This is one of the critical piece of the code that I wrote because this function is called when a sketch starts. The setup function will only run once, after each power up or reset of the Arduino board.

*/

void setup()

{

Serial.begin(9600); //open serial port and set a data rate of 9600 bits per second for serial data transmission to communicate with the computer.

Serial.println("ArduDroid 0.12"); //Prints ArduDroid 0.12 to the serial port as human-readable text and adding a new-line at the end

Serial.flush(); //waits for the transmission of outgoing data to complete

}

///////////////////////////////////////END OF SECTION 2///////////////////////////////////////////

//////////////////////////////////////////////SECTION 3/////////////////////////////////////

*

This section will allow the program to change and respond consecutively by looping.

*/

void loop()

{

int ard_command = 0; //initialize the integer var to zero

int pin_num = 0; //initialize the integer var to zero

int pin_value = 0; //will hold the analog value

char get_char = ' '; //initialize the character var

if (Serial.available() < 1) // check that there is no data incoming.

return;

get_char = Serial.read(); //read incoming serial data

if (get_char != START_CMD_CHAR)

return;

ard_command = Serial.parseInt(); //return the first valid integer, skip characters and assign it to //ard_command

pin_num = Serial.parseInt(); //return the first valid integer, skip characters and assign it to //pin_num

pin_value = Serial.parseInt(); //return the first valid integer, skip characters and assign it to //8pin_value

/*-----------------Digital Data buttons from ArduDroid-----------------*/

if (ard_command == CMD_DIGITALWRITE)

{

if (pin_value == PIN_LOW)

pin_value = LOW; //set pin value to binary 0

else if (pin_value == PIN_HIGH)

pin_value = HIGH; //set pin value to binary 1

else return;

set_digitalwrite( pin_num, pin_value); //pass the values of the pin to the function //set_digitalwrite

return;

}

}

///////////////////////////////////////END OF SECTION 3//////////////////////////////////////////

////////////////////////////////////////////////SECTION 4///////////////////////////////////////////

*

This section allows control flow of the program by giving possibility to the programmer to specify code that should be executed in various conditions.

*/

void set_digitalwrite(int pin_num, int pin_value)

{

switch (pin_num)

{

case 2:

pinMode(2, OUTPUT); //sets the digital pin as output

digitalWrite(2, pin_value); //set pin ON

break; //exit the switch statement

case 3:

pinMode(3, OUTPUT); //sets the digital pin as output

digitalWrite(3, pin_value); //set pin ON

break; //exit the switch statement

case 4:

pinMode(4, OUTPUT); //sets the digital pin as output

digitalWrite(4, pin_value); //set pin ON

break; //exit the switch statement

case 5:

pinMode(5, OUTPUT); //sets the digital pin as output

digitalWrite(5, pin_value); //set pin ON

break; //exit the switch statement

case 6:

pinMode(6, OUTPUT); //sets the digital pin as output

digitalWrite(6, pin_value); //set pin ON

break; //exit the switch statement

case 7:

pinMode(7, OUTPUT); //sets the digital pin as output

digitalWrite(7, pin_value); //set pin ON

break; //exit the switch statement

case 8:

pinMode(8, OUTPUT); //sets the digital pin as output

digitalWrite(8, pin_value); //set pin ON

break; //exit the switch statement

case 9:

pinMode(9, OUTPUT); //sets the digital pin as output

digitalWrite(9, pin_value); //set pin ON

break; //exit the switch statement

case 10:

pinMode(10, OUTPUT); //sets the digital pin as output

digitalWrite(10, pin_value); //set pin ON

break; //exit the switch statement

case 11:

pinMode(11, OUTPUT); //sets the digital pin as output

digitalWrite(11, pin_value); //set pin ON

break; //exit the switch statement

case 12:

pinMode(12, OUTPUT); //sets the digital pin as output

digitalWrite(12, pin_value); //set pin ON

break; //exit the switch statement

case 13:

pinMode(13, OUTPUT); //sets the digital pin as output

digitalWrite(13, pin_value); //set pin ON

break; //exit the switch statement

}

///////////////////////////////////////////END OF SECTION 4////////////////////////////////////////

}

Step 11: Connecting the Arduino Uno and the Bluetooth Module

A connection between the Arduino-Uno and the Bluetooth module is required in order to enable the android to control the Arduino-Uno.

Firstly, the VCC pin of the Bluetooth module must be connected to the VCC port in the Arduino-Uno board. Secondly, the GND pin of the Bluetooth module must be connected to the GND port in the Arduino-Uno board. Lastly, the receiver of the Bluetooth module must be connected to the transmitter of the Arduino-Uno board and the transmitter of the Bluetooth module must be connected to the receiver of the Arduino-Uno board. Table 3.7 shows the process.

Step 12: Testing the Connection

After installing the ArduDroid app on the phone from the Google play store and connecting the Arduino-Uno board with the Bluetooth module, a test is required to ensure that the smartphone is interacting with the Arduino via the Bluetooth module.

The steps for the connection test is carried out as follows:

· Open the ArduDroid app on the android device.

· Search for Bluetooth devices in the ArduDroid app.

· Connect to the Bluetooth module.

· If the light on the Bluetooth module stops blinking it means that a connection is established. If the light on the Bluetooth Module continues to blink it means that it’s not connecting and the wiring needs to be checked.

Step 13: Connecting the Electrical Appliances to the Relay Module

Once the smartphone is connected to the Arduino the electrical appliances can be connected to the Arduino via the relay module. Flex wire and connector blocks is used to connect the positive terminal of the electrical appliances to the normally open port in the relay module as the aim of the project is to make the output active a high. The negative wire of the appliances connects to the power source. Then IN port of the specific relay is connected to the desired Arduino Uno port. The same procedure is applied for the other appliances using different relays and different Arduino Uno ports.

Once all the connections of the electrical appliances are completed and the smartphone is connected to the Bluetooth module, the electrical appliances can now be controlled wirelessly using the smartphone.

Step 14: RESULTS

The Home/Office Automation project was successful and applied in the office area at my workplace. It was cost effective and user friendly. All the staff members knew how to use the app to control the system. All the parts needed was cheap and the equipment required was owned by myself.

Step 15: PROBLEMS ENCOUNTERED

Some problems and issues were encountered during the build of this project. The Bluetooth connection between the smartphone and the Arduino-Uno board was unsuccessful in the early stages of this project. The cause of this problem was that the xbee Bluetooth module was used. The problem was solved by an online forum which suggested to use the HC-06 Bluetooth module instead of the xbee Bluetooth module.

The second problem encountered was trying to using individual relays and connecting them by soldering them to make my own relay module. It was a problem as the holes didn’t align properly with the pins of the relays. Also soldering so many pins can cause a lot of unwanted connection joints and shorts. Therefore, a relay module is used.

Step 16: FUTURE MODIFICATIONS

There are some recommendations for Future add-ons to the system. Some of them are:

· Add a wind turbine that can be built.

· Implementation of solar panels

· Use PIR motion sensors to control the lights

· Try to find a way to amplify the Bluetooth module signal to work in greater distance.

· Design and build my own android application

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017

Sensors Contest 2017

Participated in the
Sensors Contest 2017

Green Electronics Contest 2016

Participated in the
Green Electronics Contest 2016