Raspberry Pi and Huawei/Vodafone k3772 3G modem

After about a day of tinkering with sakis3g and other tools, here’s how to connect the Raspbery Pi to Vodafone RO in a few easy steps, using a Huawei / Vodafone K3772 3G modem:

1. Install usb_modeswitch:

sudo apt-get install usb_modeswitch

Modeswitch is needed because the K3772 modem also has a storage mode. It needs to be switched to the modem mode.

2. Create the usb_modeswitch configuration files:

sudo nano /etc/usb_modeswitch.conf

Add the following at the end:


DefaultVendor = 0x12d1
DefaultProduct = 0x1526
MessageEndPoint = "0x01"
MessageContent = "5553424300000000000000000000001106000000000000000000000000000$

then create this file (where 12d1:1526 are the vendor:product codes as reported by lsusb)

sudo nano /etc/usb_modeswitch.d/12d1:1526


DefaultVendor= 0x12d1
DefaultProduct=0x1526

TargetVendor= 0x12d1
TargetProduct= 0x14cf

MessageContent="55534243123456780000000000000011062000000100000000000000000000"

3. Install pppd if not already installed:

sudo apt-get install ppp

4. Configure pppd:

http://deadloop.blogspot.ro/2010/07/linux-huawei-3g-modem-ppp-vodafone.html

Create the files as per the above blog post:
sudo /etc/ppp/peers/vodafone

name vodafone
460800
noipv6
lock
crtscts
local
noccp
novj
nobsdcomp
nopcomp
noaccomp
nodeflate
nomagic
nomp
nopredictor1
defaultroute
lcp-echo-failure 0
lcp-echo-interval 0
noauth
debug
nodetach
user internet.vodafone.ro
password vodafone
connect “/usr/sbin/chat -V -v -f /etc/ppp/chatscripts/vodafone2”
noipdefault
ipcp-no-addresses
maxfail 40
persist
ipcp-accept-local
ipcp-accept-remote
noipx
usepeerdns
defaultroute
replacedefaultroute

As addition from the referred post, add the last 2 lines, and remove the novjcomp which is not supported on Pi.

Then, create the vodafone2 chat script:

sudo mkdir /etc/ppp/chatscripts
sudo nano /etc/ppp/chatscripts/vodafone2


'ABORT' 'BUSY'
'ABORT' 'ERROR'
'ABORT' 'NO CARRIER'
REPORT CONNECT
'TIMEOUT' '60'
'' 'ATH'
'OK' 'ATZ'
'OK' 'ATQ0 V1 E1 &D2 &C1'
'OK' "AT&F"
'OK' "ATE1"
'OK' 'AT+CGDCONT=1,"IP","internet.vodafone.ro"'
TIMEOUT 120
'OK' "ATD*99***1#"
'CONNECT' '\c'

Then, simply run:
sudo pppd /dev/ttyUSB0 call vodafone

If you want to make the connection start when the PI boots up, use a rc.d script:
sudo nano /etc/init.d/vodafone with this content:


#***************************************************
#! /bin/sh
# /etc/init.d/vodafone

### BEGIN INIT INFO
# Provides: noip
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: A simple script from www.stuffaboutcode.com which will start / stop a program a boot / shutdown.
### END INIT INFO

case "$1" in
start)
sleep 10
echo "connecting via ppp"
# run application you want to start
sudo pppd /dev/ttyUSB0 call vodafone &
;;
stop)
echo "disconnecting via ppp"
# kill application you want to stop
sudo pppd /dev/ttyUSB0 disconnect vodafone &
;;
*)
echo "Usage: /etc/init.d/vodafone {start|stop}"
exit 1
;;
esac

exit 0
#*********************************************************

then also run

sudo chmod 755 /etc/init.d/vodafone
sudo update-rc.d vodafone defaults

The connection will be automatically back on when the Pi reboots.

Leave a Reply

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