Cheap Bluetooth Solution for Smart Controlled Home Devices

: The aim of this paper is to build a Bluetooth based system to connect various home devices to mobile devices such as smart phones and tablets. This system will allow users to control their home devices from their mobiles. This project tries to create a cheap solution for such tasks using Bluetooth technology. The home devices are connected to an Arduino microcontroller that is programmed to control various functions. Some of the functions include turning the lights on and off with various levels and changing fan speeds for indoor climate change. The controller itself is connected to an Android operated smart phone and its functions are controlled wirelessly via Bluetooth wireless technology. The phone will communicate with the microcontroller by using an Android mobile application that meets the system interaction requirements with the microcontroller. A code will be sent to the microcontroller to receive commands from the android application to control the devices accordingly.


Introduction
Modern technology allows for building many embedded systems that use microprocessors, wireless connection and smart phone technologies to make our daily life easier. A small system can be built to help those who need it in operating their home devices. The system needs to be simple to use, functional and customizable, so that it can handle future improvements to its hardware and software. High level programming abilities and knowledge of microchips and smart phones are needed to achieve this goal.
The challenges that will be encountered in building such a system are determining the correct and most suitable combination of hardware and software required to build the system. First, an appropriate microcontroller needs to be integrated into the existing home devices that are going to be controlled. Second, a good system of communication also needs to be implemented in this project to allow users to interact with the device with minimum difficulties. Finally, an easy and a straightforward interface needs to be built in order to allow the user to control the system effortlessly. Once all of these steps are achieved, this will provide an outstanding and simple interface that allows users to fully utilize the system conveniently.
Our objective is to build a system that allows users to control home devices via a mobile application wirelessly. This system will connect Arduino microcontroller board to different home devices such as lamps, fans and others. An Android powered mobile application is developed to be used on the user's smart phone to control the system. Bluetooth technology is used as a suitable communication method to communicate between the microcontroller and the user's mobile device inside each room.
The advantage of our system is that it provides a cheap control solution. Existing users' mobile phones are used. It also uses cheap hardware such as multi-purpose Arduino microcontroller.
The rest of this paper is divided as follows: A literature review, followed by the hardware system design, then the software design and finally the conclusion.

Literature Review
There are several systems that propose similar solutions to wirelessly control a home device. Some of their ideas were implemented using similar components that are intended to be used in the project and some of them use other technologies and components. Nonetheless, each system has its advantages and disadvantages according to the design that is intended to be built in our project. This section gives a brief review on various home control devices.
First, the LittleBits (Bdeir and Richardson, 2015) is a wireless lightening solution with simple interface that allows users to switch on or switch off their lights wirelessly via a smart phone or tablet device. The wireless lighting project allows a user to control lights in a room wirelessly using IR transmitter module, USB module to power the project, bright LED as an indicator for working functions of the circuit and a CloudBit that uses Wi-Fi connection to receive a signal to activate the light switch an advantages of LittleBits is the ease of use and the relative simplicity of its building process. Since it sends its IR signal to an AC switch, it can be used to control any electronic device that is connected to the switch to be turned on and off. No further study is needed to the devices' communication methods or its components, to be able to achieve the goal of turning devices on and off. On the other hand, it needs to use Wi-Fi communication for its CloudBit module which needs Internet to be configured on the first use. It also uses IR transmitter and receiver to activate the AC switch. Hence, IR needs to be positioned in a way that is directed to the AC switch which powers the light. Consequently, this might create inconvenience for some users when adjusting or remodelling their furniture in the room. This also might limit the options of the distribution of the furniture especially in large rooms. And since IR signals can be blocked and supposedly directional, occasional obstacles like people passing or accidentally putting miscellaneous in the way may falsely indicate a system malfunction to some users until they notice that obstacle.
Second, Nest thermostat (Wollerton, 2015) is a device that allows users to wirelessly control their house's temperature via Wi-Fi. The Nest system is based on a programmable microcontroller integrated into the Nest thermostat itself which allows users to control its functions and program it by the application that can be installed on many devices such as computers, smart phones and tablet devices via Wi-Fi. It is simply connected to the house's AC control unit and Wi-Fi network and can work with any computer or smart phone device connected to the same network. The application allows users to change the temperature and control the device itself. Users can also see power consumption rates; peak consumption times which will help users control their power usage and allow them to save power costs and become more environmentally friendly.
Wi-Fi was chosen in the Nest system since the idea of this system is to allow users to control the air conditioning system from various rooms in the house. The Nest system requires the house to have a Wi-Fi network distributed throughout the required rooms which can be expensive and complicated to implement for many users because Wi-Fi networks need routers, access points and repeaters to be able to cover large areas.
Third, Philips (2015) is a device that let the user control light bulbs via the user's smart phone or tablet device and allows him to switch the lights on or off via the internet. It is designed to help users control their household devices from anywhere via the internet. There are two main parts in Philips hue. The first part is the bridge that is connected to the light bulbs via ZigBee and communicates with the phone via the internet. The second part is the Philips Hue light bulbs which are connected and controlled wirelessly via ZigBee to the Philips Hue. This system is only limited to light bulbs. It is also expensive and requires an Internet connection.
Fourth, Blynk (Doshi et al., 2017) is an application that is available for iOS and android which lets the user connect to Raspberry Pi or Arduino through the Internet. The application itself is customizable by making the user build a Graphical Interface inside the application according to his or her needs. After building the Graphical Interface, the user can then connect to Arduino or Raspberry Pi to control the attached devices.
The advantage of this application is that it connects to the hardware through the internet, so the user can control the devices anywhere in the world. The disadvantage is that an Internet connection should always be available. Another disadvantage is that Blynk requires programming skills. The user must download the Blynk library and write the application in order to connect to Arduino or Raspberry Pi. Blynk also requires a server that communicates with both the Application and the hardware. This last requirement adds an additional cost whether it is a local server or a Cloud server.
Finally, Logitech harmony (Melfi, 2018) is an automated home control system that controls devices via a remote control that sends signals to a hub which controls everything. The system can also be controlled via a smartphone application available for Android and iOS devices. It enables users to program their Logitech hub to control various home devices via a smart device or the Logitech remote that comes with the system wirelessly.
The hub translates the signals received from the remote or smart device into programmable IR, Bluetooth or Wi-Fi signals that control the home devices. The remote can also be used to control IR (or RF devices in some models) devices directly if needed, but it has to be in the hub's range. Furthermore, the hub can be controlled over the internet via the smartphone application which allows the user to control the system outside his or her house.
The system can be connected to your lights, door locks, home television, stereo set, computers and so on. Buttons on the provided remote can be programmed to do certain tasks such as turn on the lights or unlocking a door. The buttons can also be used to activate certain profiles which have certain setting. For example a movie profile button will turn on multiple devices such as the TV and home theatre systems while also diming the lights for a cinema effect. Custom schedules can also be programmed to suit chronological events such as weekly family movie night and so on. The benefits of this system are that it is easy to use, programmable to suit many devices, having buttons that do multiple tasks and the fact that it is relatively small. However, there are some issues regarding the smartphone application which can be complicated for common users. Moreover, the smartphone application has limited functions and does not have as many features as the remote that comes with the device. The system is also relatively expensive for the home control models which can control up to fifteen devices.
To sum up, work has been done to help people to remotely control devices in their homes. Each work has his advantages and disadvantages. In the following Table 1, a comparison is done among the checked systems. In the next section, we will explain our system's hardware design, followed by another section to explain the built software.

Hardware System Design
An important matter for building the project is to choose the correct combination of hardware and software that interact with each other via a suitable communication method to control the system. The system should be secure, inexpensive, efficient and suitable for a medium to a large sized room. Many different communication methods, microcontrollers and mobile platforms were analyzed and compared to choose the correct combination of hardware, software and communication method. We finally chose Arduino microcontroller android as a mobile platform android Studio as a software development tool and Bluetooth as a wireless communication technology.
The system is designed using two Arduino microcontrollers that will be connected to two household devices, along with Bluetooth modules and an Android powered smart phone that has an application designed to control the signals sent via Bluetooth to the microcontrollers. The two Arduino microcontrollers will be programmed to control certain devices in certain ways depending on the data carried in the Bluetooth signal sent from the Android smart phone. Figure 1 below describes the system's structure.

Arduino UNO Microcontroller
The Arduino UNO (Hadwan and Reddy, 2016) is a small microcontroller board with an ATmega328P processor with a clock speed of 16 MHz and it has an operating voltage of 5V and input voltage between 7-12V.The Arduino Uno have a 32 KB flash, a 1 KB EEPROM storage and 2 KB SRAM storage. This module has 1 UART port and it uses a regular USB connection to connect to the computer or operate with AC-to-DC adapter. This Arduino module have 6 analog pin from A0 to A5 (all of them for taking an analog input) and it has 14 digital pins from pin 0to pin 13. Pin 0 and 1 are RX, TX and pin 3, 5, 6, 9, 10 are PWM (Pulse Width Modulator) pins.

4-Channel AC Dimmer Module
4-Channel AC Dimmer module (ModeLighting, 2013) is a module that can control the phase of an AC signal. It contains two Triacs (Triode AC switch) and a zero crossing detector. The Triac is a semiconductor device that is bidirectional to take advantage of the both positive and negative side of a sinusoidal wave.
The module working voltage ranges from 110V to 240V, so it is suitable in most homes of all regions. It auto detects 50 and 60 Hz of the AC signal and can be programmed to work with 100 Hz. (inmojo.com) It is compatible to work with any Arduino or Raspberry PI boards. The most important feature of this module is that it isolates the lower voltage side that is being used with Arduino and the higher voltage side connected to the home powered (AC) devices.
The way the module works is that it takes a pulsing signal from Arduino to one (or multiple) of the module's Triac gate input pins labelled "CH1, CH2, CH3 and CH4" and control the phase of the AC signal coming from its AC load input gate (that is connected to the room electricity source). This processed signal is then passed through corresponding output channel out of the four outputs. By that the phase chosen by the Arduino code is what dims and controls the intensity of the brightness of the lights and intensity of the fan rotation.

Bluetooth HC-05 Module
The HC-05 Bluetooth module (GME, 2019) supports SPP (Serial Port Protocol) communication method and is designed for transparent wireless serial connection setup. It uses 2.4GHz radio signal via its transceiver. The module is qualified to support Bluetooth V2.0+ and has a low power consumption of 1.8V in operating state and 1.8 to 3.6V for I/O. It supports UART interface with programmable baud rate and its default baud rate is 38400. Nonetheless, it supports 9600, 192000, 38400, ■■ 57600, 115200, 230400 and 460800 baud rates. HC-05 module also features master and slave mode. It indicates those modes through the module's small LEDs attached to it. Red and blue blinking to indicate master and slave paired and red only blinks when otherwise (iteadstudio.com, para. 1). Devise 1 e.g., lights

Fig. 1: System structure for Bluetooth remote controlled devices
Devise 2 e.g., fan Arduino 1 Arduino 1 ■■ As hardware Fig. 2 shows, it has 6 pins that can be connected to the breadboard: GND, VCC, RXD, TXD, KEY and STATE. TXD is the transfer pin of the module and should be connected to the RX pin of the receiving end module (Arduino in this project). RXD pin is naturally connected to the TX pin of the sending module (also Arduino's RX pin). KEY pin serves as a setup pin for the module when connected to VCC to enter the module's AT MODE. Several commands can be sent to the module to configure its functionality like master/slave mode and reset pairing password. It is important to mention that the default factory password for the module is "1234" and it can only accept 4 bit passwords if the need to change the password arises.

Hardware Implementation
To implement this project's prototype, each room will need one Arduino Uno module. It is considered to be the brain of the hardware that controls room devices. Arduino Uno is tagged with the RX (receive) and TX (transmit) letters on its pin 0 and pin 1 respectively. Although these pins are tagged with these functions, other digital pins (2-13) can also do the same function. It is just practical to have them tagged to be used conventionally for this purpose among developers. In this project, the conventional pins were used to connect to the Bluetooth HC-05 module for serial communication. The Bluetooth module is responsible of receiving the commands from the user Bluetooth capable device and transmits them via its TX pin to the RX pin of Arduino Uno.
The message is then received by Arduino and processed through the code downloaded on its microcontroller. After processing the instruction in Arduino Uno, an output is sent to the AC dimmer module through the digital pins that are connected to the Arduino. For example, Fig. 2 shows pin 7 of Arduino is connected to CH1 of the dimmer module. Messages received from the controlling device can be interpreted in Arduino Uno to change the state (on/off) and dim the fan in the room. However, pin 6 is connected to CH2 of the AC module to control the fan of the room. The AC dimmer module has four AC output channels to be controlled by Arduino. The module has one AC input channel that is connected to the rooms electricity supply and it then supplies any of its four channels with AC power according to messages received from Arduino Uno pins.
The dimmer module function is not limited to dimming the lights; it can be used as a switch or leveler to the speed of fan. Furthermore, each channel can be connected to more than one light or fan to be controlled in parallel. With this methodology, many scenarios can be implemented to control the room devices. A desired function, like scheduling the work of the device, can be coded onto Arduino Uno and can then be passed to the AC output channel to control the connected device. The hardware functionality in its present design offers a lot of controlling options by just manipulating the code and enhancing it to suit a desired outcome.

Software Design
The software is divided into three parts: The workflow, Bluetooth configuration and the graphical user interface. The workflow in section A explains how the interaction between software and hardware is done at both sides of the system: The client side (user) and the server side (microcontroller and device).

Software Workflow
The application first starts and scans for available devices via Bluetooth. After the application selects a device, it requests pairing to that device. On the other side, the Arduino program starts and broadcasts its signal through Bluetooth and waits for request. If the application's request has not been accepted, the application goes back to scan for devices. If the Arduino program accepts the application's request, the Arduino program displays the status of the devices attached to it on the android application, so that the application can control them accordingly.
Each time when the Arduino program receives commands from the application, it updates the status on the android application. After that the application decides if it wants to continue sending commands on the Arduino or not. If it does, it continues normally. If not, it disconnects from the device and decides whether to search for another device or end the program. After the Arduino program receives commands and update status, it always checks if the device is still connected. If it is, it displays the status again on the android application, if it is not, it goes back to broadcast the signal and wait for connection requests.

Bluetooth Configuration
In order to configure the Bluetooth module, a specific code should be downloaded to the Arduino while it is connected to the Bluetooth module to enter AT command mode (Cotta and Devidas, 2016). This mode allows the developer to configure the Bluetooth module by sending a specific command to the serial port in the Arduino software.
One of the options that the developer can change is the name of the device, since the user will have many devices; the user need to have a unique name for each device, "AT+NAME = "Room 1"" is a command that changes the name of the module to "Room1".
Another option that the developer can change is the device's role. There two roles: Master or slave. Since the user need to connect to the device, the slave role is the best choice. "AT+ROLE" command will change the device's mode.

■■
For security, changing the password will be needed, to suit the user's needs "AT+PSWD = "0000"" is used to change the password to "0000".
"AT+ORGL" is another command that will reset the module to its default state as a slave with a password of "1234" and a name of "HC-05" (Cotta and Devidas, 2016).
After configuring the Bluetooth module according to the user's need, the graphical user interface is built to interact with the user.

Graphical User Interface
Once the application is started, the user is greeted with the an empty screen with a "Paired Devices" button ( Fig. 3). Once the user clicks the button, a list of paired devices appears on a list form so that the user chooses the desired device. After selecting the desired device, the screen changes to a tab style screen for either controlling the lights or controlling the fans (Fig. 4). The light control tab consists of an ON and an OFF buttons with a seek bar. The "ON" and "OFF" buttons turn the lights on and off. The "seek" bar gives the user more control over the light by controlling light intensity levels (dimmer). The fan control tab consists of radio buttons to control 4 different levels of fan speed as well as level 0 which is basically turning off the fan. Both of the "Disconnect" buttons in both tabs disconnects from the Bluetooth and goes back to the first screen.

Conclusion
In conclusion, the final result of the project is a simple system for the user to control devices in a room from his mobile device using Bluetooth wireless communication. Most adult people are using mobile phones and tablets, most of which already have Bluetooth technology build into it. This project will make use of these smart devices and extend their functionality to make the user able to control room devices. This is believed to serve people as a cheap luxurious option for smart home device control.
The system was applied to two devices as an initial step. As future work, the system will be enhanced to include most home electrical and electronic devices. The software will also be enlarged to include such a variety of devices.

Ethics
This article is original. The author declares that there are no ethical issues that may arise after publication of this manuscript.