====== Connect with a 3G modem with command line ====== I have a modem Huawei E1752Cu HSPA, and I want it to connect to the internet. ===== Detect the vendor and the product ===== After connecting the modem, perform a lookup of the syslog. It will show you the vendor and the product: Feb 28 21:18:39 raspi kernel: [ 1432.602724] usb 1-1.2: new full-speed USB device number 12 using dwc_otg Feb 28 21:18:39 raspi kernel: [ 1432.737215] usb 1-1.2: New USB device found, idVendor=12d1, idProduct=1004 Feb 28 21:18:39 raspi kernel: [ 1432.737239] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 Feb 28 21:18:39 raspi kernel: [ 1432.737250] usb 1-1.2: Product: HUAWEI Mobile Feb 28 21:18:39 raspi kernel: [ 1432.737259] usb 1-1.2: Manufacturer: HUAWEI Technologies So, in my case the vendor id is 12d1 and the product is 1004. ===== Install usb_modeswitch ===== # apt-get install usb-modeswitch ===== Configure the product and the vendor ===== Then open the modem definition file, which in my case is ''/usb/share/usb_modeswitch/configPack.tar.gz'' and then copy one existing similar to ours. In my case, I've found the 12d1:1003, so I've copied it to create my own configuration of modeswitch: cp 12d1:1003 /etc/usb-modeswitch.d/12d1:1004 So, after that we will see that the modem is recognized. ===== Install wvdial and ppp ===== The configuration for me resulted as: [Dialer Defaults] Modem Type = USB Modem Phone = *99# ISDN = 0 Username = "pepephone" Password = "pepephone" Stupid Mode = 1 New PPPD = yes Modem = /dev/ttyUSB0 Baud = 460800 Init1 = ATZ Init2 = AT+CPIN="YOUR-PIN-CODE-HERE" Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init4 = AT+CGDCONT=1,"IP","gprs.pepephone.com" Auto DNS = 1 Dial Command = ATDT Carrier Check = yes Stupid Mode = 1 This was the most difficult part, because It requested me to guess what the configuration optimum for the modem. In "Modem", you have to select the device of the modem, after it is connected. The date "Phone", "Username", "Password", and Init*. The Init* sequence cost me because you have to guess the at commands that suits your modem. ===== Send an sms ===== There are many ways to send an sms. You can send it directly, write first the message into the memory of the modem, etc... **Direct sending** AT+CMGF=1 # say the modem to operate in sms mode OK AT+CMGS="669807321" # send a message directly > text your message here, and end the message with ^Z (control+z) AT+CMGF=1 # say the modem to operate in sms mode AT+CMGW="669807321" > A simple demo of SMS text messaging. +CMSS: 1 # the ID of the message in memory AT+CMSS=1 # send the message with id = 1 ==== Read a message ==== To list all the messages in the memory: ==== Delete a message ==== To delete a message: AT+CMGD=2