How to send and receive SMS Messages on Quectel module

This is demo video of how to send/receive SMS via AT command. DUT used in this demo is EC25-V.
Welcome to raise your questions here.

Tips: ASCII code of CTRL+Z is 0x1a

1 Like

This is demo video of how to send/receive SMS via AT command. DUT used in this demo is EC25-V.
Welcome to raise your questions here.

Tips: ASCII code of CTRL+Z is 0x1a

i’m a newbie using ec25-e, I do the same way but i can’t input the message after “>”, could you tell me where i’m wrong?

Please give more detail about what you’re doing.

If command echo is on (ATE1), do you see the text characters echoed?

Are you terminating the text with <ctrl-Z> correctly?

yes i set ATE1 and see the echoed text, after input my number in the command AT+CMGS=" " and send, then i write the sms and ctrl+z but it doesn’t appear on the QCOM, the ESC still can cancel, then it return +CMS ERROR: 350

How are you entering the <ctrl-Z>?

Interactively, by pressing “z” while holding the <Ctrl> key down? Or by entering the character into software or an application?

after doing these steps in QCOM, and i click after the message and press CTRL+Z as you said, then after a while, +CMS ERROR: unknown error appears, am i miss any initial setup for the module before sending sms?

Capture
could you tell me instead of sending Ctrl+Z on the keyboard, what should i send if using uart?

To me, this makes it look like the <ctrl-Z> character is getting to the modem, but the modem is unable to submit the SMS to the SIM’s message centre for some other reason.

Are you able to send SMSs when using this SIM in another device?

thank you, i somehow made it with another SIM, but i have a problem that instead of sending Ctrl+Z on the keyboard, what should i send if using uart connect to stm32 microcontroller?

<ctrl-Z> is ASCII character 0x1A (26 decimal, 32 octal). In Linux scripting, that’s \x1a or \032

In other languages, it might be given as chr(26) or ^z

1 Like

Hello! I tried creating a script inside the file system of the RM520N-GL (/tmp directory) and Im stumped at this part.

# Send the AT command to set the message format to text mode
echo -en "AT+CMGF=1;+CNMI=2,1;+CMGS=\"09xxxxxxxxx\"\r\n" | microcom /dev/ttyOUT2
sleep 1

# Send the message
echo -en "$message\032"

First of all, we made ttyd work on RM520N-GL so no problem there. I can execute AT commands just fine. Now on the problem. When I try manually run:

echo -en "AT+CMGF=1;+CNMI=2,1;+CMGS=\"09xxxxxxxxx\"\r\n" | microcom /dev/ttyOUT2
> this is a test message\032
*nothing happens*

the “>” appears and I can type the message. However appending \032 to message doesn’t seem to emulate the ctrl + z needed. It just stuck after the message input and nothing happens. How can I possibly do it?

@Rus
Something you need to know:
AT command should end with “\r” and so the “AT+CMGF=1” won’t work.

Here is an example I just tested.
echo -ne “at+cmgs="09xxxx"\r” > /dev/ttyUSB2; sleep 2; echo -ne “test result” > /dev/ttyUSB2 ; sleep 1; echo -ne “\032” > /dev/ttyUSB2

I tried recreating yours but using smd11 since this is the available port inside the module.

echo -ne "AT+CMGF=1\r" > /dev/smd11
sleep 1
echo -ne "AT+CNMI=2,1\r" > /dev/smd11
sleep 1
echo -ne 'AT+CMGS="09938931024"\r' > /dev/smd11
sleep 1
echo -ne "test message" > /dev/smd11
sleep 1
echo -ne "\032" > /dev/smd11

Again, same problem. The escape character was not being executed properly making it stuck with > test message.

I tested on Ubuntu with module connected via USB and it works fine.
/dev/smd is not the usual uart.
/ # stty -F /dev/smd7
stty: /dev/smd7: Inappropriate ioctl for device
/ # stty -F /dev/smd11
stty: /dev/smd11: Inappropriate ioctl for device

You cannot open it with microcom.
Since it is OpenLinux project, you can API to send AT and SMS.

The things is, I want to run the script inside the module itself and make a simple front end that can send phone number and message as parameters. I can send AT commands using smd7 and smd11 but maybe it’s not really applicable for SMS. Thanks for the response!

You are right. You can’t open it with microcom. However you can use socat to create a tty dev on the AP (emulate a serial device) to use to bridge to smd11, smd7, or at_mdm0. You can then use microcom with the ttyOUT dev that was created.

Here’s 3 systemd service units that work together to make it work. Here you can see how smd11 —> ttyOUT

(@Rus mentioned ttyOUT2 which I have used smd7 with)

[Unit]
Description=Socat Serial Emulation for smd11
After=ql-netd.service

[Service]
ExecStart=/usrdata/socat-at-bridge/socat-armel-static -d -d pty,link=/dev/ttyIN,raw,echo=0,group=20,perm=660 pty,link=/dev/ttyOUT,raw,echo=1,group=20,perm=660

Add a delay to prevent the clients from starting too early

ExecStartPost=/bin/sleep 2s
Restart=always
RestartSec=1s

[Install]
WantedBy=multi-user.target

[Unit]
Description=Read from /dev/smd11 and write to ttyIN
BindsTo=socat-smd11.service
After=socat-smd11.service

[Service]
ExecStart=/bin/bash -c “/bin/cat /dev/smd11 > /dev/ttyIN”
ExecStartPost=/bin/sleep 2s
StandardInput=tty-force
Restart=always
RestartSec=1s

[Install]
WantedBy=multi-user.target

[Unit]
Description=Read from /dev/ttyIN and write to smd11
BindsTo=socat-smd11.service
After=socat-smd11.service

[Service]
ExecStart=/bin/bash -c “/bin/cat /dev/ttyIN > /dev/smd11”
ExecStartPost=/bin/sleep 2s
StandardInput=tty-force
Restart=always
RestartSec=1s

[Install]
WantedBy=multi-user.target

1 Like