how to send an SMS message through GSM using Mat lab software
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hi there i have already wrote the matlab code as shown below but its not working when i connect with the GSM modem. is there any one who can help me and write the correct mat lab code and i am so thank full for your kindness!!
this is the mat lab code i already write and try to test the gsm
%%%%%%%%%%%%%%%%Matlab code for sending SMS%%%%%%%%%%%%
clc;
clear all;
global BytesAvail;
global A;
global B;
tx ='AT';
tx1=char(13);
tx2=char(26);
tx3='AT+CMGS="15510961424"'; % You have to replace this with the Receiver's Phone number
tx4= ' This is a test msg '; %This is the msg body
tx5='AT+CMGF=1';
s = serial('COM6', 'BaudRate', 9600); % You have to replace this with your 3G modem's COMport number
fopen(s);
s.Terminator = 'CR';
fprintf(s,'%s', tx);
fprintf(s,'%s', tx1);
BytesAvail=s.BytesAvailable;
if(BytesAvail > 0), A=fread(s,BytesAvail,'char'); end
A;
sprintf('%c', A)
%%%%%%%%%%%%%%%Send SMS%%%%%%%%%%%%
fprintf(s,'%s', tx5);
fprintf(s,'%s', tx1);
fprintf(s,'%s', tx3);
fprintf(s,'%s', tx1);
fprintf(s,'%s', tx4);
fprintf(s,'%s', tx2);
BytesAvail=s.BytesAvailable;
if(BytesAvail > 0), B=fread(s,BytesAvail,'char'); end
B;
fclose(s)
%%%%%%%%%%%%%%%%%%%%End%%%%%%%%%%%
1 comentario
Bhargav K Naidu
el 19 de Mayo de 2016
I am working on a similar project, my code is not working can anyone please help me over and the code used by me is :
ss=serial('COM7');
ss.baudrate=9600;
fopen(ss);
ss.Terminator = 'CR'
tx ='AT';
tx1=char(13);
tx2 ='AT+CMGF=1';
tx3 ='AT+CSCS="GSM"';
tx4 ='AT+CMGS="=+919844806008"';
tx5 ='water';
tx6=char(26);
fprintf(ss,'%s',tx);
fprintf(ss,'%s',tx1);
pause(1);
fprintf(ss,'%s',tx2);
fprintf(ss,'%s',tx1);
pause(1);
fprintf(ss,'%s',tx3);
fprintf(ss,'%s',tx1);
pause(1);
fprintf(ss,'%s',tx4);
fprintf(ss,'%s',tx1);
pause(1);
fprintf(ss,'%s',tx5);
pause(1);
fprintf(ss,'%s',tx6);
Respuestas (1)
syed wasim basha
el 14 de Mzo. de 2018
Editada: syed wasim basha
el 14 de Mzo. de 2018
I too worked on the similar project,i got success by using query cmd which can write and read string to the interfacing objects. I even successfully made a call by using this code.
ob1 = instrfind('Type', 'serial', 'Port', 'COM3', 'Tag', '');
% Create the serial port object if it does not exist % otherwise use the object that was found. if isempty(ob1) ob1 = serial('COM3'); else fclose(ob1); ob1 = ob1(1); end
fopen(ob1); tx='ATD*********;'; out1 = query(ob1,tx); fclose(ob1);
i think this will help you.
1 comentario
shweta shetty
el 27 de Mzo. de 2018
I tried this but it says: "Warning: Unsuccessful read: A timeout occurred before the Terminator was reached." Can you please suggest a solution?
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!