Professional Documents
Culture Documents
Remote Control of A Domestic Equipment From An Android Application Based On Raspberry Pi Card
Remote Control of A Domestic Equipment From An Android Application Based On Raspberry Pi Card
Abstract—In this paper, we propose a Remote control of a automation application requires for its operation, able to
domestic equipment from an Android application based on capture information and operate a subsequent order. For this,
Raspberry pi card. Home automation has been recalled in the we must be able to transfer information between different
first stage. In the second stage an application has been developed devices. The system allows programming of automatic sources
based on the android system. The different diagrams have been of comfort and safety of energy saving: the automatic opening
presented. Different codes have been developed to allow the and closing of the shutters, automatic watering depending on
communication between the remote user, the web server, the the climate, lighting management based on the presence and
raspberry pi card and the home components. Also an interface brightness, etc. The home automation system includes three
card has been developed to assure the communication between
main compoments which are:
the home components and raspberry pi card. The application has
been installed on a Smartphone, a web server and a raspberry pi • Controller / Control Interface: as a monitor, computer, or
card to order the shutter of windows. The experimental results phone, for example, that can give orders to units that one
are successful. wishes to control (program, parameterize)
Keywords—Android system, Web server, Raspberry pi card, • A mode of transmission: wired connections (example
Electronic components. Ethernet), radio waves, infrared, etc.
904
Save manual order: Saves the manual control opening or 4) Transition-state diagram
closing in the database with the nature of the control (open /
close), its date, and with a status = -1 (command completed
successfully) .
Open manual shutter: Allows the manual user to open the
shutter manually.
Close manual shutter: Allows the manual user to close the Fig. 8. Transition-state diagram
shutter manually.
The diagram above shows the different states of a
2) The class diagram: command: the state « On hold » when the control (open /
close) sent by the user is waiting for treatment, the state
« performed » when the command is successful, and the state
« failed » when it is impossible to carry out the control of the
user.
5) Activity diagram :
3) Sequences diagrams
a) Sequence diagram of "Remote open shutter"
Fig. 6. Sequence diagram of "Remote open shutter" Fig. 10. Architecture at three levels (3-tiers)
b) Sequence diagram of subsystem "Raspberry pi" card The architecture we adopted for our application (side:
Android application, web service and database) is the three-
tier architecture, which is a stack of three levels: The
presentation of data (Level 1), Treatment business data (Level
2) and access to persistent data (Level 3).
2) Two-tier architecture (2-tier):
Fig. 7. Sequence diagram of subsystem "Raspberry pi" card Fig. 11. Two-tier architecture (2-tier)
905
We have used this architecture side « Raspberry pi » card
and the database.
3) The REST architecture:
REST (Representational State Transfer) is a type of
architecture that is used more and more to make a web service.
It is not precisely defined by a standard. REST is based on
requests transmitted by standard protocols (http, ftp,...), it
often returns a file in XML or JSON format.
4) JSON:
JSON (JavaScript Object Notation) is a data structure
format. The data are considered as objects with properties and
sub-properties. This formalism is close enough is based on
XML and JavaScript. Fig. 13. The inputs / outputs of the Raspberry pi card
RL3
Braben video games, as part of its foundation "Raspberry pi". NTE-R22-5
PH V1 N
The following photo presents the Raspberry pi card : Enternet R1 Q1
2N3392
10k VCC/VDD
220 V
RL4
R1 Q1
2N3392
10k
Sensor
GND 1/0
VCC/VDD
RL1
NTE-R22-5
Lamp
R2 Q1
2N3392
10k V1
220 V
GND
906
First, the user is prompted to enter his login and password
in order to use the application, in case the internet connection
is not present, an error message is displayed to invite him to
check its connection internet. If there is not a connection
problem, “Please wait” message appears, in this case the
system checks the validity of the login and password, if they Fig. 18. The shutter current state
are incorrect, an error message invites him to check them.
After authenticate correctly, the user is redirected to the
main interface (Fig. 16) where it can choose « Help » to see
the instructions to know more information about the
application, or command its shutter (Fig. 17).
Fig. 19. Successful opening
907
} change the state of this command to -1 (that is to say
}); command completed successfully).
….} //library gpio
Note: myTaskOuvrir is a class type AsyncTask
import com.pi4j.io.gpio…..
(Asynchronous task). It allows for asynchronous tasks. In our
//To open the shutter
case, it will be responsible for displaying the « Please wait »
message, recover the value of the HTTP request sent by the // create gpio controller
client (example « Open »), preparing the response as JSON final GpioController gpio = GpioFactory.getInstance();
(example « The shutter is opening successfully »), and finally // provision gpio pin #01 as an output pin and turn on
reveal the response as is shown in Fig. 19. final GpioPinDigitalOutput pin =
gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01,
3) Extract code to command shutter (open) in the REST "MyLED", PinState.HIGH);
Web Service: // turn off gpio pin #01
We used the PHP language to develop the web service and pin.low();
the XAMPP to test it on the local network before the host on
the Internet. IV. CONCLUSION
function api_post($var) This work deals with smart home. The remote control
{ includes software and hardware components such as web
switch ($var) server, smart phone, Raspberry pi card and an interface card.
{ Many codes have been developed and stored in the web
case ("Open") : server, smart phone and the raspberry pi card. An interface
card has been realized to update signals between the actuator
….
sensors and the raspberry pi card. The application has been
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
installed and tested. This work can be generalized to remote
… command of multiple domestic equipments. In addition, it
$sql = 'INSERT INTO ordershutter '. may be more autonomous, more practice, and quite scalable
'(nat_comm,date_comm) '. saw the giant step and progress in the areas of technology and
'VALUES ( "Open", NOW() )'; communication in our time.
…
sleep(7);
$req =mysql_query("SELECT * from ordershutter ORDER References :
BY num_cmd ASC"); [1] Li, B., Hathaipontaluk, P., and Luo, S., “Intelligent oven in smart home
while ($row=mysql_fetch_array($req)) { environment,” International Conference on Research Challenges in
Computer Science (ICRCCS ’09), pp. 247–250, Shanghai, 28–29
$state_cmd=$row['state_cmd'] ; December 2009.
} [2] Choi, J., Shin, D., and Shin, D., Research on Design and Implementation
if ($state_cmd==-1) of the Artificial Intelligence Agent for Smart Home Based on Support
{ Vector Machine, Berlin/Heidelberg: Springer, p. 417, 2005.
$msgr=array('response'=>' The shutter is opening [3] Chen, C.-Y., Tsoul, Y.-P., Liao, S.-C., and Lin, C.-T., “Implementing
successfully '); the design of smart home and achieving energy conservation,”7th IEEE
International Conference on Industrial Informatics (INDIN 2009), pp.
}….} } 273–276, Cardiff,Wales, 23–26 June 2009.
mysql_close($conn); [4] Li, J., Da-You, L., and Bo, Y., “Smart home research,” Proceedings of
break; the Third International Conference on Machine Learning and
case ("close") : Cybernetics, vol. 2, pp. 659–663, Shanghai, 26–29 August 2004.
….. [5] Bartram, L., Rodgers, J., &Woodbury, R.Smart homes or smart
occupant? Supporting aware living in the home. In Proc. HCI-
} INTERFACT 2011.
} [6] Pearson Education France – L'Art du développement Android, 2e éd. –
?> Mark Murphy) 2010
[7] Jean Engels., « «corrigé des exercices de l’ouvrage PHP 5 – Cours et
4) Extract from java code programming Raspberry pi exercices », Editions Eyrolles, 2005.
Card using gpio [8] Li Ma, Lei Gu1, and Jin Wang1,” Research and Development of Mobile
Application for Android Platform”, International Journal of Multimedia
and Ubiquitous Engineering Vol.9, No.4 (2014), pp.187-198.
We have developed a Java application that runs on the
[9] Ameena Saad Al-Sumaiti, Mohammed Hassan Ahmed, and Magdy M.
Raspberry pi card, this application has been programmed to A. Salama, “Smart Home Activities: A Literature Review”, Electric
remotely access every x seconds to MYSQL database to verify Power Components and Systems, 42(3–4):294–305, 2014
the existence of a new command (sent by the remote user) [10] Morris ME, Adair B, Miller K, Ozanne E, Hansen R, et al., “Smart-
awaiting processing. Home Technologies to Assist Older People to Live Well at Home”, Sci
Journal of Aging Science, Volume 1, issue 1, 2013
In case there is a new command (open / close) registered,
this application allows one hand to perform the processing of
the order, and also to re-access the database after treatment to
908