Setup Huawei E1552 SMS Gateway in Raspbian using SMSTools3

Here, I was able to setup Huawei E1552 SMS Gateway in Raspbian using SMSTools3.

Requirements:

Steps:

  1. Install/Burn Raspbian to your microsd card. Instructions here.
  2. After burning/installing the image to your SD card. Install it to your Raspberry PI and configure it so you can SSH into it properly. Sadly, SSH daemon is not automatically configured to start on boot.
  3. To Enable SSH to autostart on boot… do
  4. :> update-rc.d ssh defaults
    :> update-rc.d ssh enable
  5. Restart and try to login remotely
  6. If you can not login, sshd may be configured to deny any remote root connection
  7. Got to /etc/ssh/ and edit sshd_config
  8. Look for this line…
  9. PermitRootLogin.......
  10. And change it to…
  11. PermitRootLogin yes

  12. Restart the ssh server via /etc/init.d/ssh restart
  13. Now try logging in. You should be able to ssh into your rasberry pi now using root account.
  14. Plug in the Huawei 3G USB dongle.
  15. Check if its being detected via lsusb command.
  16. :> lsusb
  17. The output should have a line that look something like…
  18. Bus 001 Device 005: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)
  19. NOTE: The dongle has 2 different “modes”. One which emulates a cdrom by default, and the other as a GSM Modem. Our goal here is to enable the GSM Modem mode.
  20. Lets install the modeswitch package for this.
  21. :> apt-get install usb-modeswitch usb-modeswitch-data
    :> cd /usr/share/usb_modeswitch 
    :> sudo tar -zxvf configPack.tar.gz
    :> cp 12d1:1446 /etc/usb_modeswitch.d/ 
    :> /etc/init.d/udev restart
  22. Take note 12d1:1446 was selected since its the ID for the dongel…. “Bus 001 Device 005: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)”
  23. WARNING: There is a bug that modeswitch will not work for Huawei usb 3g dongle, go to and edit /lib/udev/rules.d/40-usb_modeswitch.rules, look for…
  24. # Generic entry for all Huawei devices
    ATTRS{idVendor}=="12d1", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
  25. At the end… change ‘%b/%k’ to ‘%k’ . Save and exit.
  26. Now remove the dongle and re-attach it. Execute the command…
  27. :> dmesg
  28. At the bottom part there should be logs that looks like this…
  29. [   14.812344] usbserial: USB Serial support registered for GSM modem (1-port)
    [   14.813456] option 1-1.2:1.0: GSM modem (1-port) converter detected
    [   14.813925] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
    [   14.814053] option 1-1.2:1.1: GSM modem (1-port) converter detected
    [   14.814457] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
    [   14.814564] option 1-1.2:1.2: GSM modem (1-port) converter detected
    [   14.814964] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2
  30. If you see ttyUSB? then your dongle was detected!
  31. Download the smstools package… The latest package at the time of my install was smstools3-3.1.21.tar.gz
  32. :> wget http://smstools3.kekekasvi.com/packages/smstools3-3.1.21.tar.gz
  33. Follow these instructions from smstools3 install instruction page
  34. :> tar -xzf smstools?-?.?.??.tar.gz
    :> make
    :> make install
  35. After building and installing, your sms3tools installation should be complete. In /etc/init.d/, sms3 should be there. Also, send2sms should now be executable from any location. This command will execute and send your sms message
  36. Now lets configure the smsd.conf file. Go to /etc and edit smsd.conf using your preferred editor, I used vim. Modify the config base on your telco settings.
  37. devices = GSM1
    logfile = /var/log/smsd.log #debug log file
    loglevel = 7 #this logs a lot of info, change to 5 or just comment out if system is running fine.
    outgoing = /var/spool/sms/outgoing #outgoing msg located
    checked = /var/spool/sms/checked
    incoming = /var/spool/sms/incoming #sms received location
    failed = /var/spool/sms/failed #failed sms sent ( possible causes may be no connection, insufficient fund )
    sent = /var/spool/sms/sent #successful sent msg
    receive_before_send = no
    autosplit = 3
    hangup_incoming_call = yes
    incoming_utf8 = yes
     
    [GSM1]
    init = AT^CURC=0 #Huawai specific initiating command
    init2 = AT+CPMS="ME","ME","ME" #This tells the modem/dongle to save all messages( draft, incoming, sent, etc ) in the device, not in the SIM card
    device = /dev/ttyUSB2 #the device location, you have to do some trial and error here.. I had USB1 and USB2 working, USB0 didn't.
    incoming = yes
    baudrate = 19200
    memory_start = 0 #Huawei modems, this should be set to 0
    smsc = <country_code><cellnumber> #65?????????? #This will be the telco sms service center number
  38. More info here as to the command AT+CPMS=”ME”,”ME”,”ME”
  39. Now lets try if your sms gateway works. Open another terminal and lets start the smsd daemon and start logging the smstools log file.
  40. :> /etc/init.d/sms3 start
    :> tail -f /var/log/smsd.log
  41. If everything is running ok, the log should look similar to something like below…
  42. GSM1: Checking device for incoming SMS
    GSM1: Checking if modem is ready
    GSM1: -> AT
    GSM1: Command is sent, waiting for the answer. (5)
    GSM1: <- OK
    GSM1: Pre-initializing modem
    GSM1: -> ATE0
    GSM1: Command is sent, waiting for the answer. (10)
    GSM1: <- OK
    GSM1: -> AT+CMEE=1;+CREG=2
    GSM1: Command is sent, waiting for the answer. (10)
    GSM1: <- OK
    GSM1: Initializing modem
    GSM1: -> AT^CURC=0
    GSM1: Command is sent, waiting for the answer. (10)
    GSM1: <- OK
    GSM1: -> AT+CPMS="ME","ME","ME"
    GSM1: Command is sent, waiting for the answer. (10)
    GSM1: <- +CPMS: 0,23,0,23,0,23 OK
    GSM1: -> AT+CSQ
    GSM1: Command is sent, waiting for the answer. (10)
    GSM1: <- +CSQ: ??,?? OK
    GSM1: Signal Strength Indicator: (28,99) -57 dBm (Excellent), Bit Error Rate: not known or not detectable
    GSM1: Checking if Modem is registered to the network
    GSM1: -> AT+CREG?
    GSM1: Command is sent, waiting for the answer. (10)
    GSM1: <- +CREG: ?,?,????,???? OK
    GSM1: Modem is registered to the network
    GSM1: Selecting PDU mode
    GSM1: -> AT+CMGF=0
    GSM1: Command is sent, waiting for the answer. (5)
    GSM1: <- OK
    GSM1: Changing SMSC
    GSM1: -> AT+CSCA="+65??????????"
    GSM1: Command is sent, waiting for the answer. (5)
    GSM1: <- OK
    GSM1: Checking memory size
    GSM1: -> AT+CPMS?
    GSM1: Command is sent, waiting for the answer. (5)
    GSM1: <- +CPMS: "ME",0,23,"ME",0,23,"ME",0,23 OK
    GSM1: Used memory is 0 of 23
    GSM1: No SMS received
  43. Now to send your short message… type sendsms and it will ask for a number and your message. Your number should be in the format [country_code][cellnumber]
  44. :>sendsms
    Destination(s): 651234567890
    Text: <your message here>
  45. Check your logs, if everything goes smoothly, the sms you sent will be received by the destination number! 🙂
  46. Enjoy!

Sources:
Correctly configure Huawei e1552 Dongle in Raspbian
Bug
ArchLinux

Leave a Reply

Your email address will not be published. Required fields are marked *