2

right now I am kind of digging into the topic of using the RPi to read/write SMS and if possible use it make/receive Phone calls.

I have this Router (Huawei E5786), Model E5786s-32a. It seams to support GSM/GPRS etc. and I am asking myself if it is possible to use it as a GSM Modem, such that I can make calls…

I can connect to it via USB and lsusb yields:

Bus 002 Device 007: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard

Anyway, I am just digging into that right now so my question is: Can I use that device as »modem« for phone calls and sms, or wont it be possible? How I figure that out?

1 Answer 1

2

I never tried said router before but I did make it work with a Huawei Mobile Broadband E153 dongle.

Setting up a USB 3G/4G modem on a Raspberry Pi is not a simple task, at least not for me. It took me a lot of trial and error to get everything up and running..

The main problem is that most USB modems act as two devices - a USB storage device and a USB modem. When plugged in to the Raspberry PI the device is usually in USB storage mode. There is a program called usb modeswitch that we can use to do the switching.

The other missing part is a way to connect to the cellular network with the USB modem from the Raspberry. For this you will use the classic ppp and wvdial programs.

Installing required Softward on Raspbian

sudo apt-get update sudo apt-get install ppp usb-modeswitch wvdial cu

Getting Modem Switching Codes

Then you need to get the codes of the USB device in USB storage mode and USB modem mode.

Connect your USB modem and reboot the Raspberry PI without LAN or Wifi connection Once rebooted open a terminal window and enter:

lsusb

The output will look similar this below. Your modem should be listed as one of the USB devices. Note the numbers underlined. These are the device vendor and product codes.

enter image description here

Make a note of these numbers if you want to make a presistent port name for the device later. In my case with the huawei modem, these IDs are 12da:1000.

Now reboot the machine. Once rebooted open a terminal window and enter again:

lsusb

The output will look similar to the figure below. Your modem should be listed and if you are lucky the second set of numbers would have changed. This is usb modeswitch doing it’s job and switching the device to USB modem mode. enter image description here

Make a note of the new numbers. In this case it is 19d2:2002. This value will be used later in the TargetProduct value.

Creating custom usb modeswitch config file

Now you need to create a custom config file for usb modeswitch on the Raspberry PI because on a cold boot the device is not always active yet when usb modeswitch runs on startup and the device is left in USB storage mode.

We will extract some more information for our usb modeswitch config file so that we can do the switching manually.

Open a terminal window and open the usb modeswich configuration file:

sudo nano /etc/usb modeswitch.conf

Add the following lines the following, replacing the codes 19d2 and 2002 with the codes you noted in the previous step, at the end of the file. Then save and exit:

TargetVendor=0x19d2
TargetProductList="2002"
StandardEject=1
NoDriverLoading=1
CheckSuccess=20
MessageContent="55534243123456780000000000000011062000000100000000000000000000"

You can search for your modem device switch codes in here

Creating the wvdial config file

The next step is to create a config file for wvdial so you can connect to your service provider.

Open a terminal window and command: sudo nano /etc/wvdial.conf Append the file with the following lines:

These configuration values are for Etisalat Egypt, you have to alter them to make them work with another service provider

[Dialer etisalat]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","etisalat"
Password = { }
Phone = ∗99# #here goes your service provider internet access point
Modem Type = Analog Modem
Stupid Mode = 1
Baud = 9600
New PPPD = yes
Modem = /dev/modem00 
ISDN = 0
Username = { }

Connect to the internet

If everything goes as planned, now you are able to connect to the Internet using our configured Modem by writing: sudo wvdial Etisalat

Sending SMS using Huawei Modem

To interface with modem through terminal, We gotta need an application called cu. To send a sms message to 201000xxxxxx, enter the following commands at the command prompt:

#opens a AT+ connection to the modem
cu − l /dev/modem01
#using text mode not PDU:
AT+CMGF=1
#writing the receiving number
AAT+CMGS="01000xxxxxx"r
#write your message and then press **ctrl + z** to send

References:

  1. https://hristoborisov.com/index.php/projects/turning-the-raspberry-pi-into-a-sms-center-using-python/
  2. http://www.developershome.com/sms/atCommandsIntro.asp
1
  • Wow! I would not have expected such a detailed answer! Thanks a lot! I will give it a shot!
    – philipp
    Commented Oct 13, 2017 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.