GUI Based Home Automation System Using Arduino and MATLAB
GUI Based Home Automation System Using Arduino and MATLAB
GUI Based Home Automation System using Arduino and MATLAB (/microcontroller-
projects/gui-based-home-automation-using-matlab-and-arduino)
By Saddam 8 Comments (/microcontroller-projects/gui-based-home-automation-using-matlab-and-arduino/#comments)
We all are familiar with the word Automation, where the human interaction is minimal and things can be controlled automatically or remotely. Home
automation is very popular and demanding concept in the eld of Electronics, and we are also making our best efforts to make this concept easily
understandable and manageable as Electronics Projects. We have previously developed several types of Home Automation Projects with a working
Video and Code, please check:
Ads by Google
MATLAB Download
And in this project,we are going to build our next home automation project using MATLAB and Arduino, which is GUI Based Home Automation System
Using Arduino and MATLAB
Components:
Arduino UNO
USB Cable
ULN2003
Relay 5 volt
Bulb with holder
Connecting wires
Laptop
Power supply
PVT
Working Explanation:
In this project, we are using MATLAB with Arduino to control the Home appliances, through a Graphical User Interface in Computer. Here we have
used wired communication for sending data from computer (MATLAB) to Arduino. In computer side, we have used GUI in MATLAB to create some
buttons for controlling home appliances. For communication between Arduino and MATLAB, we rst need to install the MATLAB and Simulink Support
for Arduino or Arduino IO Package. To do so follow the below steps or check the video below:
Thats how we make the Arduino, communicate with MATLAB. Above method is suitable for MATLAB R2013b or earlier versions, if you are using the
higher version of MATLAB (like R2015b or R2016a), you can directly click on Add-ons Tab in MATLAB and then click Get Hardware Support Packages,
from where you can install Arduino packages for MATLAB.
After installing les, now you can create a GUI for Home Automation Project. Basically in GUI, we are creating Push Buttons for controlling the home
appliances from computer. Buttons can be created by going into Graphical User Interface in New menu in MATLAB. Further we can set the name and
colours of these buttons, we have created 8 buttons, in which six to ON and OFF three home appliances and two buttons to ON and OFF all the
appliances simultaneously.
Now after creating the buttons, when you click on Run button in that GUI window, it will ask you to save this GUI le (with extension . g), also known as
g le. As soon you saved the le, it will automatically create a code le (with extension .m), also known as M le (see below screen shot), where you
can put the Code (given in Code section below). You can download the GUI le and Code le for this project from here: Home_Automation_system. g
(http://circuitdigest.com/sites/default/ les/Home_Automation_system. g) and Home_Automation_system.m
(http://circuitdigest.com/sites/default/ les/Home_Automation_system.m)(right clickand select Save link as...), or you can create them yourself like we
have explained.
After coding you can now nally Run the .m le from the code window, you will see Attempting connection.. in the command window. Then a Arduino
successfully connected message appears, if everything goes well. And nally you will see previously created GUI (buttons) in GUI window, from where
you can control the home appliances by just clicking on the buttons in your Computer. Make sure that Arduino is connected to Arduino via USB cable.
Here in this project we have used 3 bulbs for demonstration, which indicates Fan, Light and TV.
Working of the wholeproject, from installing the Arduino MATLAB support package to Turn On or OFF the appliance, can be understood at the Video at
the end.
Circuit Explanation:
Circuit of this project is very easy. Here we have used an Arduino UNO board and Relay Driver ULN2003 for driving relays. Three 5 volt SPDT Relays are
connected to Arduino pin number 3, 4 and 5, through relay driver ULN2003, for controlling LIGHT, FAN and TV respectively.
Ads by Google
MATLAB Software
MATLAB SIMULINK
(/fullimage?
i=circuitdiagram_mic/GUI-Home-Automation-using-MATLAB-arduino-Circuit-Diagram.png)
Programming Explanation:
When we press any button from the GUI window then it sends some commands to Arduino and then Arduino do that operation. After installing Arduino
MATLAB IO support package, we can access Arduino from the MATLAB by using the same Arduino functions, with some little variation, like:
In MATLAB we will use this function with the help of an object or variable like,
a.digitalWrite(pin, HIGH);
In this project, there is no Arduino code except the Arduino MATLAB support package code or le. As explained earlier that code le (.m le) is
automatically generated while saving the GUI le (. g le). There is already some code prewritten in .m le. Basically these are Callback functions for
Push buttons, means we can de ne what should happen on clicking on these Push Buttons.
In MATLAB code, rst we initialise serial port and make it an object by using a variable. And then we can start programming like Arduino using the
variable.
clear ar;
global ar;
ar=arduino('COM13');
ar.pinMode(3, 'OUTPUT');
ar.pinMode(4, 'OUTPUT');
ar.pinMode(5, 'OUTPUT');
ar.pinMode(13, 'OUTPUT');
In the call back function of each button, we have written the related code for On or OFF the respective Home Appliances, connected to Arduino via Relay.
Like for example, Callback function for Light ON is given below:
Likewise we can write the code in the Callback functions of all the buttons, to control the other connected Home Appliances, check the full MATLAB Code
below (.m le).
Ads by Google
Gui Software
MATLAB For
Code:
function varargout = Home_Automation_system(varargin)
% HOME_AUTOMATION_SYSTEM MATLAB code for Home_Automation_system. g
% HOME_AUTOMATION_SYSTEM, by itself, creates a new HOME_AUTOMATION_SYSTEM or raises the existing
% singleton*.
%
% H = HOME_AUTOMATION_SYSTEM returns the handle to a new HOME_AUTOMATION_SYSTEM or the handle to
% the existing singleton*.
%
% HOME_AUTOMATION_SYSTEM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HOME_AUTOMATION_SYSTEM.M with the given input arguments.
%
% HOME_AUTOMATION_SYSTEM('Property','Value',...) creates a new HOME_AUTOMATION_SYSTEM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Home_Automation_system_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Home_Automation_system_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
clear ar;
global ar;
ar=arduino('COM13');
ar.pinMode(3, 'OUTPUT');
ar.pinMode(4, 'OUTPUT');
ar.pinMode(5, 'OUTPUT');
ar.pinMode(13, 'OUTPUT');
% --- Outputs from this function are returned to the command line.
function varargout = Home_Automation_system_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to gure
% eventdata reserved - to be de ned in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Video:
GUI Based Home Automation Project using Arduino and MATLAB
EasyEDA: Free PCB Design Software, Start to design your own PCB circuit easily (https://easyeda.com)
JLCPCB for PCB Prototyping: Only $2 for 10pcs 10x10cm PCBs, 2-3 days delivery (https://jlcpcb.com)
LCSC Parts: Save 50% on cost, Wide selection in-stock, Same day shipping (https://lcsc.com)
Wireless GSM Based Home Largest Z-Wave Smart Phone
Funamentals Automation System Offering - Fast Controlled Home
eBook - Free from... using Arduino:... Shipment - Best... Automation...
Ad electronicdesign.com circuitdigest.com Ad ekitzone.com circuitdigest.com
Comments (8)
reply (/comment/reply/265/1856)
Tejo Susiratmoko
Suitable ... interested in using
Mar 25, 2016
reply (/comment/reply/265/2032)
dana
(/)
Dear Saddam,
I have been searching for weeks on a way to link between Arduino and GUI
I have created a GUI of two push buttons and an edit box.When i click one of the buttons it would increments and the other would decrements..I
13 need to connect these two buttons to two pushbuttons on Arduino, that is when I push the button of Arduino it would increment or decrement in
Shares
GUI.
I would really really appreciate your help.
8
Thank you
Apr 02, 2016
1
reply (/comment/reply/265/2854)
1 Hussein Ali
Pls can you give me the matlab gui le because i need it and i am not familiar with matlab coding
May 12, 2016
reply (/comment/reply/265/3163)
Abhishek
Link to Download the GUI le (. g) is already given in Working Explanation, with the name Home_Automation_system. g. Right click on
that link and Click on "Save link as..."
May 28, 2016
reply (/comment/reply/265/11888)
Vipul
Error using HOME_AUTOMATION_SYSTEM>HOME_AUTOMATION_SYSTEM_OutputFcn (line 77)
Failed to open serial port COM4 to communicate with board Uno. Make sure there is no other MATLAB
arduino object for this board. For troubleshooting, see Arduino Hardware Troubleshooting.
Error in gui_mainfcn (line 264)
feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
Error in HOME_AUTOMATION_SYSTEM (line 42)
gui_mainfcn(gui_State, varargin{:});
I am getting this error while running this program please help
Mar 12, 2017
reply (/comment/reply/265/14833)
abhinav
I would like to know what do you mean by PVT in components required.
May 31, 2017
reply (/comment/reply/265/15866)
Abhishek
PVT is terminal block with screw on relay module block.
Jul 06, 2017
reply (/comment/reply/265/15761)
vamshi teja
after showing aurdino connected successfully ..when we click on push buttons its working properly.but after some period of time its showing an
error of .."Error while evaluating uicontrol Callback"..and all the push buttons are been disabled..please sort it out
Jul 03, 2017
Leave a comment
Your name *
E-mail *
The content of this eld is kept private and will not be shown publicly.
Subject
Comment *
Save Preview
RELATED CONTENT
LATEST POSTS
(/microcontroller-projects/stepper-motor-control-with-potentiometer-arduino)
(/electronic-circuits/piezoelectric-transducer-circuit-diagram)