Sunday, September 6, 2020

Working with GSM module in Raspberry Pi 3

Last few days I had tried my hands on working with GSM module with Raspberry PI 3. I had Raspberry PI 3B device on which I have used SIM  800 module having RPI GSM ADD-on V2.3. My PI device have native Raspbian buster as OS. Trying set up the SIM with the GSM module take bit of time connect to internet. I am using an Airtel 4G SIM for internet connection I need to search a bit on Google to set up the GSM module for an active internet connection and start browsing. Listing here the steps I have used.  

Hardware Used:

1.       Raspberry PI 3 B

2.       GSM module SIM 800

3.       Airtel SIM

4.       7”” inch Waveshare LCD for display

5.       USB charger for (5V 1 amp for Raspberry PI)

6.       Two additional USB charger for power supply to GSM Module and LCD)

7.       Keyboard and mouse

Connection:  Put the SIM in the SIM holder of the GSM module. Place the GSM module on top of Raspberry PI using 32 pins.  Connect the LCD to raspberry pi using the cable

APN SET UP:  All of you must know what APN is. It is access point name of your operator. Since I have used an Airtel SIM, I know the APN name. It is airtelgprs.com. If you have a different operator you, please note the APN that we will later use for setting PPP configuration.

PPP Configuration and installation: PPP stands for point to point protocol, which basically used for node to node communication using serial interface in PC. We will use PPP and serial connection to access internet in Raspberry pi.

To install PPP software, open the terminal. Enter the following two commands one after another.

sudo apt-get update

sudo apt-get install ppp screens elink

After successful installation of PPP software, you need to setup PPP peer configuration. For this we need login as root. By default, in raspberry pi you logged in as default user pi. At least in my case I had logged in as user pi. So, to log in as root user type the following command on the terminal and enter.

sudo -i

After logging in as root use cd command as shown below to move peers directory.

cd /etc/ppp/peers/

Now create a new file and name it anything you like and remember the name. Use any editor you want. I have used nano editor as shown below to create a file called airnet

sudo nano airnet

Enter the following text as shown below.

#airtelgprs.com is the APN for Airtel connection. Note in the above line put APN name of your operator after -T.

connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T airtelgprs.com"

# For Raspberry Pi3 use /dev/ttyS0 as the communication port:

/dev/ttyS0

# Baudrate

115200

# Assumes that your IP address is allocated dynamically by the ISP.

noipdefault

# Try to get the name server addresses from the ISP.

usepeerdns

# Use this connection as the default route to the internet.

defaultroute

# Makes PPPD "dial again" when the connection is lost.

persist

# Do not ask the remote to authenticate.

noauth

# No hardware flow control on the serial link with GSM Modem

nocrtscts

# No modem control lines with GSM Modem

Local

There are few other parameters available for setting up the configuration and you can try those. But the above lines are sufficient for the configuration Now save the file and close it

Edit cmdline.txt file:

 Now use the following command to edit the cmdline.txt in the boot directory.

sudo nano /boot/cmdline.txt

Remove all reference to console in this file as shown below

Before Edit: dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=07312df9-02 rootfstype=ext4 elevator=deadline fsck. repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

After Edit:  dwc_otg.lpm_enable=0 root=PARTUUID=07312df9-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Edit hciuart.service file: Apart from changing cmdline.txt file we need some minor change in the hciuart.service file in the /lib/system/system folder using below command.

Sudo nano /lib/systemd/system/hciuart.service

Use “#” to comment out the line having below text.

After = dev-serial.device

Execstart = /usr/bin/bt-uart

Add the new line shown below.

Execstart = /usr/bin/hciattach/dev/ttyS0 bcm43xx 460800 noflow-

Save the file and close the editor

Edit config.txt file:  Open the config.txt file using any editor. I have used the following command to edit config.txt

sudo nano /boot/config.txt

Add the following lines at the bottom of the config.txt file and save the file

dtoverlay=pi3-miniuart-bt

enable_uart=1

force_tourbo=1

Check Connection

Run ifconfig command from terminal to check connection type available on your raspberry pi. You will find “eth”, “lo” and “wlan”. Now type the following command on the terminal to create a new connection

sudo pon airnet.

Now again run the ifconfig command on the terminal. Now you will see a new section called PPP0 with an IP address. Your network LED will blink quickly and continuously on your GSM module showing the connection is on.

Now you can open your web browser in your raspberry pi 3 device and browse websites.

If you want to disable or close the PPP connection, use the following command.

sudo poff airnet

Refernce: 

1. https://www.instructables.com/id/Raspberry-Pi-With-a-GSM-Module/

2. https://www.rhydolabz.com/wiki/?p=16325#:~:text=Make%20the%20connections%20as%20shown,get%20registered%20to%20the%20network.

No comments:

Post a Comment