Using AT Commands with the Huawei E303

/ Written By Reuben Balik

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 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

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:

  1. Boot up your BeagleBone, SSH to it, and login.
  2. 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:modeswitch
  3. Save the file and reboot the board by typing reboot
  4. 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.
  5. 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.

  6. 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.)
  7. To confirm that you’re actually talking to the modem, type AT . You should get an OK response. (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.

  1. 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:

  2. Exit the screen session by hitting Ctrl-A and then k (Say yes if it asks if you’re sure.)
  3. Now you can start up a PPP server with this command:
    pppd debug -detach noauth defaultroute /dev/ttyUSB0 9600 > ppp.log &
  4. You should now be online. Let’s try pinging an IP address to be sure:

Sending SMS

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:

  1. Send AT
  2. Switch into text SMS mode (easier than the other mode) by sending AT+CMGF=1
  3. 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.
  4. Type in your message at the prompt and hit Ctrl+Z to end the message.
  5. 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.
  6. Send AT+CMSS=X where X was the number from the previous step.
  7. 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:

SMS screenshot

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 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 down below or on our community forum. You can also view all of our additional tutorials here. Thanks!

Update 8/11/2015: Fixed a typo on the U2^DIAG command. 375 gets back to HiLink mode, not 376. Also added information about another version of the mode switch command.
Update 11/7/2016: Fixed a typo in the IP to use to switch modem mode on Windows.