In present time home office appliance controlling is common thing. Today for controlling home/offices appliances, machineries in companies/industries uses different types of automation systems like DTMF controlled, GSM controlled and many others. So here this project is made for interfacing MATLAB (Graphic User Interfacing) and Home/office/industries automation using Arduino and MATLAB.
Here MATLAB is interfaced with Arduino through serial communication. In this arduino is burned with an ARDUINO IO (Also Known As: “TETHERED” MATLAB SUPPORT PACKAGE FOR ARDUINO). This package allows using an Arduino connected to the computer to perform Analog and Digital Input and Output, (and command motors) from MATLAB. For this project reader should have knowledge about getting start with arduino.
Circuit Description: Circuit of this home automation system is very simple. Digital Pin number 10 of Arduino Pro Mini is directly connected to LED used as light lamp and small fan used as selling is connected to pin number 11 of arduino and ground of both appliances connected to arduino ground. And arduino is connected with computer over serial communication. Here I used FTDI burner for serial communication.
Programming part of this system is also very easy. There are two program files for this project one for arduino and second for MATLAB. Arduino MATLAB program file is easily available on internet. And MATLAB program you can build. Before programing you have to make a user graphic interface (GUI) window in MATLAB. This GUI automatically creates a program file. Now you can write program as you wish. But here I have programed for LED and Fan only.
Ex.
Globle a;
A=arduino(‘COM27’);
a.pinMode(9, ‘OUTPUT’);
Steps for uploading MATLAB support package for Arduino:
The adioe.pde sketch is the server program that will continuously run on the microcontroller (Arduino) board. It supports forMATLAB commands arriving from the serial port, executes the commands, and, if needed, returns a result. Like a Digital Output and an Analog Input for MATLAB.
Step I:From the Arduino IDE, go to File > Open, locate the file adioe.pde, (in the ArduinoIO/pde/adioe folder) and open it.
Fig. 1:
Screenshot of Arduino IDE demonstrating navigation to open a new file
Fig. 2: Screenshot of Arduino IDE loading adioe.pde file
Step II:Connect the Arduino, make sure that the right board and serial port are selected in the IDE, (Tools/Board and Tool/Serial Port) then select File -> Upload to I/O Board and wait for the “Done Uploading” message.
Fig. 3:
Screenshot of adioe.pde file on Arduino IDE
Fig. 4: Screenshot of uploading adioe.pde file on Arduino IDE
Package installation in MATLAB
Package installation in MATLAB (to be done only once):
When installing the Arduino IO package on your operating system it isimportant that users have the right to access the serial port and modifythe pathdef.m file.
Step I:
Run MATLAB as administrator (just one time for the purpose of installing the package) by right-clicking on the MATLAB icon and selecting “Run as Administrator”. This will allow the updated path to be saved.
Step II: Then from MATLAB, launch the “install_arduino” command, this will simply add the relevant ArduinoIO folders to the MATLAB path and save the path.
Fig. 5:
Screenshot of package installation on Matlab
Fig. 6: Screenshot of running Matlab support package
GUI Window
Step I: Open MATLAB and then open GUI window
Fig. 7: Screenshot of opening new GUI on Matlab
Step II: Select Blank GUI(Default) and then ok.
Fig. 8: Screenshot of creating blank GUI on Matlab
Step III: Now select Push Buttons.
Fig. 9: Screenshot of Matlab IDE highlighting a push button
Step IV: Now Assign buttons name and then Run.
Fig. 10: Screenshot of Matlab IDE showing push buttons drawn on GUI
Step V: now you will see two windows. One for buttons and second for program.
Fig. 11:
Screenshot of created Matlab window with four push buttons
Fig. 12: Screenshot of Matlab Code for Arduino based Home Automation System
Step VI: Now write your Program in previous window whatever you want to do with your system or arduino. In that window write commands for button1, button2, button3 and button4.
Components and Software
Components Used:
1. LED
2. Fan
3. Arduino
4. FTDI Burner
Software Required:
1. MATLAB
2. Arduino IDE
Project Source Code
### function varargout = GUI(varargin) % GUI MATLAB code for GUI.fig % GUI, by itself, creates a new GUI or raises the existing % singleton*. % % H = GUI returns the handle to a new GUI or the handle to % the existing singleton*. % % GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUI.M with the given input arguments. % % GUI('Property','Value',...) creates a new GUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GUI_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GUI_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 % Edit the above text to modify the response to help GUI % Last Modified by GUIDE v2.5 17-Jul-2014 15:32:47 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GUI_OpeningFcn, ... 'gui_OutputFcn', @GUI_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before GUI is made visible. function GUI_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GUI (see VARARGIN) % Choose default command line output for GUI handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GUI wait for user response (see UIRESUME) % uiwait(handles.figure1); clear a; global a; a=arduino('COM27'); a.pinMode(13, 'OUTPUT'); a.pinMode(9, 'OUTPUT'); % --- Outputs from this function are returned to the command line. function varargout = GUI_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a; a.digitalWrite(13, 1); % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a; a.digitalWrite(13, 0); %delete a; % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a; a.digitalWrite(9, 1); % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a; a.digitalWrite(9, 0); ###
Circuit Diagrams
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.