Sunday, May 27, 2018

USB Stick Modem on Raspberry Pi


The use of IoT is very much in the world, many new researches or innovations using IoT as back bone or IoT technology rely on. So Raspberry Pi felt necessary to play this role. to get internet access on Raspberry Pi can use WiFi or can via LAN Adapter but what if Raspberry Pi is used on moving object. so internet is required from Telephone Operator SIM Card. for that one practical, easy and cheap way that is by using USB Stick Modem on Raspberry Pi.
before being discussed please note that the following test using Raspberry Pi 3 Model B and OS Raspbian Strech with USB Modem Stick Huawei E153. the following will be discussed how to use a USB stick as a source of internet on Raspberry Pi. here are the steps:
  1. Power On Raspberry Pi, then connect your USB stick modem to the USB.
  2. then the next step is we need to check whether the USB modem detected as Modem or CD ROM for it open terminal and type command as follows:
ifconfig -a
if the result is wwan0 then it is certain that the USB modem has been detected as Modem. like the following picture:


and for sure you can also check by doing the command:
lsusb


can be seen in the picture above there is Huawei's writings .... if not like above there is no wwan0 network so your USB modem is in CD ROM mode. for that need to do usb switch mode by further check on the following link: http://www.draisberghof.de/usb_modeswitch/ assuming we are already at the stage of USB Modem already regarded as a modem by Raspberry PI. Well we will do some installing software used.
sudo apt-get update
sudo apt-get install wvdial
do wvdial software installation with the above command, make sure not error. if you have finished installing wvdial do check with command below:
ls -al / dev / gsm *
it will detect the modem in USB0 as shown below:


meaning that the modem can already be configured and dialed. to configure it is to make editing wvdial.conf file in /etc/wvdial.conf directory, do the editing with the command as follows:
sudo nano /etc/wvdial.conf
according to the following configuration:

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
Modem = /dev/ttyUSB2
Baud = 9600

[Dialer APNname]
Phone = *99***1#
Username = thenetuser
Password = thenetpw
; Username = 9180****** (If your provider use without Username)
; Password = 9180****** (If your provider use without Password)
Stupid Mode = 1
Baud = 460800
Init3 = AT+CGDCONT=1,"IP","APNname"

when finished configuring wvdial.conf, save it with the command ctrl + o and press Y and exit with the command ctrl + x to run wvial, just need to type wvdial commands on terminal like command below:
wvdial
and a modem with a SIM card inside will connect to the internet. :)