Last updated: February 5, 2020
Many of our customers using the Huawei E303 want to move beyond the HiLink feature of the modems described in our other tutorials and gain more low-level control by using AT commands. This method is more complicated, but can allow you to programmatically send SMS or disconnect the radio.
This Huawei E303 AT Commands tutorial was created on the BeagleBone Black, but most of the steps will apply to any Linux system and there are some notes for Windows users at the end.
- Switching the Huawei E303 into Serial Mode
- Creating a PPP Session
- Sending SMS
- Other Useful Commands
- Notes on Windows
- Other Useful Links
Switching the Huawei E303 into Serial Mode
Before sending any AT commands to the modem, you need to switch it from the default HiLink mode into serial mode. Follow these instructions to get to that point:
- Boot up your BeagleBone, SSH to it, and login.
- We need to disable USB mode switching so that the modem doesn’t get stuck in HiLink mode when we plug it in. To do this, edit the file /etc/usb_modeswitch.conf and set DisableSwitching to 1. Here’s what it should look like if you’re using the nano editor:
- Save the file and reboot the board by typing reboot
- Plug in the USB modem and type lsusb. You should see a line in the output like this:
Bus 001 Device 002: ID 12d1:1f01 Huawei Technologies Co., Ltd.
- The 12d1:1f01 indicates that the modem is in storage mode and we need to switch it to serial mode. To do that, type this command:
usb_modeswitch -v 0x12d1 -p 0x1f01 -V 0x12d1 -P 0x1001 -M "55534243000000000000000000000611060000000000000000000000000000"
To confirm that it worked, type lsusb again. The line should now show:
Bus 001 Device 003: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
Note: Some users have reported that this only works with the -I flag on the command. If the modem doesn’t switch into 12d1:1001 mode, try rerunning the above command with -I.
- Now we need to connect to the modem . Type screen /dev/ttyUSB0. This will give you a blank screen session. Note that to disconnect and exit screen you need to type Ctrl+A and then k (There are many other utilities besides screen that will work for this as well, including minicom, but screen is included in the BeagleBone OS image.)
- To confirm that you’re actually talking to the modem, type AT . You should get an OKresponse. (If you can’t see what you’re typing, type ATE1 to turn echo on.)
Creating a PPP Session
Once you have access to send AT commands, you can use the Linux PPP daemon to establish an internet connection.
- Type the following commands exactly. You’ll want to wait for an “OK” response after each one so don’t copy and paste this whole block at once.
If all goes well, your window should look like this:
- Exit the screen session by hitting Ctrl-A and then k (Say yes if it asks if you’re sure.)
- Now you can start up a PPP server with this command:
pppd debug -detach noauth defaultroute /dev/ttyUSB0 9600 > ppp.log &
- You should now be online. Let’s try pinging an IP address to be sure:
Using AT commands you can easily send an SMS message from your device. (Note that SMS may incur additional charges.)
Starting from your screen session connection to the modem:
- Send AT
- Switch into text SMS mode (easier than the other mode) by sending AT+CMGF=1
- Prepare the message by sending AT+CMGW="+<phone number="">" The phone number includes the country code so to send an SMS to the US number 773-555-1234 you would send the command AT+CMGW="+17735551234". If it worked, you should get a >prompt.</phone>
- Type in your message at the prompt and hit Ctrl+Z to end the message.
- After you hit Ctrl+Z you should get a message back in the format +CMGW: X where X is a number. This number is needed in the next step.
- Send AT+CMSS=X where X was the number from the previous step.
- If all goes well you should get a +CMSS response followed by an OK. Your SMS should have sent!
Here’s a screenshot of a complete transaction:
Other Useful Commands
There are tons of commands for controlling various aspects of the modem behavior. Here is just a small sample:
- ATI gives some useful information about the modem
- AT^U2DIAG=0 will force the modem into serial modem mode every time it’s plugged in. Use AT^U2DIAG=375 to get back into HiLink mode
- AT+CFUN=7 will turn off the radio and AT+CFUN=1 will turn it back on
Notes on Windows
Connecting to the modem to send AT commands on Windows is a little more complicated. When the modem is connected and is in HiLink mode you can go to the URL http://192.168.1.1/html/switchProjectMode.html in any browser and the modem will switch into serial mode. However, this is only half of the solution. You need to install the Huawei Mobile Partner software and then you need to actually edit some of the driver files that it comes with in order to get Windows to mount the modem on a COM port. Instead of putting all of those instructions right here, there’s already a great tutorial for editing these files at another site.
Other Useful Links
I’d recommend the following links for more information on all of this. There is some great information out there on other useful AT commands and tips for automating and scripting the whole process.
I HOPE THIS WAS HELPFUL. AS ALWAYS, LEAVE ANY COMMENTS OR QUESTIONS ON OUR COMMUNITY FORUM. THANKS!