How to send SMS messages to Matlab using AT commands? Do not use mail gateways

Problems:

  • I can use hyperterminal to send SMS via COM9. Things are good.
  • But I can't use the AT commands in Matlab correctly to do the same. I can’t even go through the first β€œAT” step. The error I received is "Unexpected error: Unexpected error: An error occurred while recording." It seems to come from fprintf. Help!

Here are the codes:

try s = serial('COM9','BaudRate',9600); fopen(s); tx='AT'; tx1=char(13); tx2=char(10); fprintf(s, '%s', sprintf('%s%s%s', tx, tx1, tx2)); out = fscanf(s); disp(out); fclose(s); catch aException fclose(s); error(message('MATLAB:serial:fprintf:opfailed', aException.message)); 
+4
source share
1 answer

You have completed the serial communication part correctly. In the AT command set, to check the operation of the device, it is enough if you send "AT" and the line. Also, you simultaneously submitted both a carriage return and a line. This can create a problem. Also, while writing MATLAB code for the first time, try sending characters individually, as in Hyperterminal. This will solve your problem.

There will be no problems from the point of view of MATLAB when the connection is created successfully.

+1
source

Source: https://habr.com/ru/post/1490124/


All Articles