How to send SMS via AT-CHAT

Is there a way how to send SMS using AT-CHAT? I am on Mikrotik Chateau. Sending mseeages via /tool/sms works, but I do want to understand if AT commands can work as well here. Below are my miserable attempts to make this work:

  • I check that AT interface works, set SMS mode to text, list messages (plenty space left), I also gave port list, although that does not do much
  • I try to send a message as described in Quectel EG12 manual (and a few others as well)
  • lte modem enters in an unresponsive state that only reboot can solve (waited for more that 3 minutes)
[admin@Mikr0Tik] > /port/print    
Columns: DEVICE, NAME, CHANNELS, BAUD-RATE
# DEVICE  NAME  CHANNELS  BAUD-RATE
0 2-1     usb1         2  auto     

[admin@Mikr0Tik] > /interface lte at-chat lte1 input="AT"                                                                  
  output: OK

[admin@Mikr0Tik] > /interface lte at-chat lte1 input="AT+CMGF=1"  
  output: OK

[admin@Mikr0Tik] > /interface lte at-chat lte1 input="AT+CMGL=\"ALL\"" 
  output: +CMGL: 0,"REC READ","+447778884444",,"25/05/23,14:33:40+04"  
          Hi user1                                                     
          +CMGL: 2,"REC READ","+447778884444",,"25/05/23,15:04:39+04"  
          Hi again                                                     
          +CMGL: 6,"REC UNREAD","+44777777777",,"25/05/23,16:09:13+04"
          :) hi                                                        
          +CMGL: 1,"STO SENT","+447778884444",,                        
          Hi from router                                               
          +CMGL: 3,"STO SENT","+447778884444",,                        
          Hi from router 2nd time                                               
          +CMGL: 4,"STO SENT","+447778884444",,                        
          test lte1                                                
          +CMGL: 5,"STO SENT","+44777777777",,                        
          Hi from your router               
          OK                                                           

[admin@Mikr0Tik] > /interface lte at-chat lte1 input="AT+CMGS=\"+447778884444\""                                           
  output:

[admin@Mikr0Tik] > /interface lte at-chat lte1 input="AT+CMGS=\"+447778884444\"" 
failure: port timeout
[admin@Mikr0Tik] > /interface lte at-chat lte1 input="AT+CMGF=1"                 
failure: Device is inactive!
[admin@Mikr0Tik] > /interface lte at-chat lte1 input="AT+CMGL=1"  
failure: Device is inactive!
[admin@Mikr0Tik] >

There really is no difference if I do the second CMGS command or not - lte modem is unresponsive.

If sending through sms tool works, you can try to enable lte logging, so all exchange with the modem will appear in the log. Then send your message using sms tool and you’ll be able to find out, what commands were used.

Thanks, I did try logging before, but it seems that Mikrotik only have a way to send messages via MBIM protocol (or that mbim obscures AT commands, if they are used underneath).

 2025-05-26 09:48:37 lte,debug lte1 mbim: send sms: 0021000c 91444570 10465800 1126538b
 2025-05-26 09:48:37 lte,debug lte1 mbim: 393d4e97 dd6000fb 0d6accd7 f2322dbd
 2025-05-26 09:48:37 lte,debug lte1 mbim: 06c9cdf4 gc3c0caa eb4ff030 fb4gg697
 2025-05-26 09:48:37 lte,debug lte1 mbim: e720440a

So I understand that it is actually impossible to send SMS via AT-CHAT on Mikrotik because normally sending messages via AT requires interactive prompt while you are entering the message. Mikrotik command shell seems not to be able to allow for that, hence commands documented in Quectel manual fail (and set lte1 interface in non-responsive state). So the best bet likely is to use the SMS tool provided by Mikrotik and use “AT+CMGD=1,4” from time to time - to empty all messages from SIM card, otherwise the SIM storage fills up and you can’t send messages any more.

Correct, they use MBIM. In terms of scripting SMS sending via AT, you perhaps can use wait=no on at-chat to potentially help. But sending SMS via AT is a tricky operation, best avoiding on MikroTik… Now, there is /system/serial-terminal, which does get you an interactive prompt to modem’s AT - but that’s not scriptable since it ONLY for interactive use.

And, I think the best approach to use /tool/sms with your cleanup AT+CMGD run periodically.

Too bad, because it is possible to set UCS-2 encoding with AT command for sending SMS in text mode and /tool/sms doesn’t support UTF8 to UCS-2 conversion, while crafted PDU is complex to build for sending SMS in PDU mode. I have script for SMS to email purpose only reading received SMS from PDU to support UCS-2 to UTF8 conversion and messages concatenation and it is very large script.

FWIW, I wasn’t saying “impossible”, just complex/difficult/etc. I cannot recall the specific, but there have been past thread on using AT to generating SMS.

But if only problem is SIM card memory gets filled up with saved messages… one scripted delete message AT seems WAY easier.

Now if you need “unicode”…that’s where /tool/sms gets limited. And even trickier since BOTH RouterOS does not support ANY unicode functions directly AND SMS PDUs are UCS-2 encoded (which requires more custom scripting to encode ASCII into UCS-2).

Yes, I’m aware of possible SIM sent messages storage issue: http://forum.mikrotik.com/t/cant-send-sms-with-mbim-memory-full/174068/1

Creating script to send messages in text mode would much simpler, just conversion from UTF8 to UCS-2 encoding if message content is loaded from text file since it is not possible to input non ASCII in ROS CLI, but to craft PDU from script to send in PDU mode to support UTF8 is much more challenge, here is my script for example which I’m using for reading SMS from PDU:
sms-read.rsc (33.9 KB)
There is a lot of code to decode PDU, and PDU for outbound SMS is different so it cannot be fully reused, but since I actually don’t need sending I never tried to make such script for SMS send.

You can force to use AT channel for SMS with “/interface lte set lte1 sms-protocol=at”

sms-protocol property on LTE interface is not related to at-chat and possible sending SMS with AT commands over it, it’s for /tool/sms functionality.
Also it doesn’t work when performing command /interface/lte/at-chat lte1 input=“AT+CMGS=""\r\ntest\1A” wait=yes after setting into text mode with AT+CMGF=1, interface becomes inactive (as OP mentioned), probably because it waits interactive input for command execution (with Ctrl-Z) or to be canceled (with ESC).

Yup. But log would show the specific AT command for the SMS sending - so might be able to “see” what command RouterOS.

But the underlying issue is that RouterOS seems to “save” sent messages, so the “manual” cleanup is needed. This has come up before (http://forum.mikrotik.com/t/cant-send-sms-with-mbim-memory-full/174068/1), so it’s more bug in /tool/sms.

To me, there should be option on the /tool/sms/send to NOT save the message - which avoid any need for AT commands. SMS sending from router should not require AT commands in 2025 IMO. Or at least some /tool/sms option clear the sent messages WITHOUT at-chat.

Well, definitely /tool/sms needs improvements http://forum.mikrotik.com/t/sms-tool-improvements/163144/1 :slight_smile:

:100:
It’s a router, so “notifications” are rather useful… so it should ideally be simple to use SMS

Regarding this

Probably when is set sms-protocol=at on LTE interface, /tool/sms uses same AT command but programmatically waits prompt character (>) from modem terminal and then sends SMS message characters with ending 0x1A (Ctrl-Z) character. But maybe from logs it can be read if is same command (not sure which other can be), as you mentioned…
Maybe MT can implement to at-chat command expect functionality for handling interactive AT commands :slight_smile: