Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Home Automation using Arduino and MATLAB

By Salman Khan

 

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.

Screenshot of Arduino IDE demonstrating navigation to open a new file

 

Fig. 1: 

Screenshot of Arduino IDE demonstrating navigation to open a new file

Screenshot of Arduino IDE loading adioe.pde 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.

Screenshot of adioe.pde file on Arduino IDE

Fig. 3: 

Screenshot of adioe.pde file on Arduino IDE

Screenshot of uploading 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.

Screenshot of package installation on Matlab

Fig. 5: 

Screenshot of package installation on Matlab

Screenshot of running Matlab support package

Fig. 6: Screenshot of running Matlab support package

GUI Window

Step I: Open MATLAB and then open GUI window

Screenshot of opening new GUI on Matlab

Fig. 7: Screenshot of opening new GUI on Matlab

Step II: Select Blank GUI(Default) and then ok.

Screenshot of creating blank GUI on Matlab

Fig. 8: Screenshot of creating blank GUI on Matlab

Step III: Now select Push Buttons.

Screenshot of Matlab IDE highlighting a push button

Fig. 9: Screenshot of Matlab IDE highlighting a push button

Step IV: Now Assign buttons name and then Run.

Screenshot of Matlab IDE showing push buttons drawn on GUI

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.

Screenshot of created Matlab window with four push buttons

Fig. 11: 

Screenshot of created Matlab window with four push buttons

Screenshot of Matlab Code for Arduino based Home Automation System

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

Circuit-Diagram-Matlab-Arduino-Based-Home-Automation-System

Project Video


Filed Under: Electronic Projects
Tagged With: Arduino, matlab, simulink
 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Timer MC14541B wrong delay
  • simple LSB explanation please
  • Pull up via GPIO
  • Avalanche Pulser
  • Measure AC current accurateley (100mA to 10A)

RSS Electro-Tech-Online.com Discussions

  • Need a ducted soldering fan for solder smoke extraction
  • bluetooth jammer
  • Disabled son needs advice please
  • DIY bluetooth speaker
  • Someone please explain how this BMS board is supposed to work?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering