0% found this document useful (0 votes)
20 views

GSM Interfacing Doc

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

GSM Interfacing Doc

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Raspberry Pi : How to access the Internet using GSM / GPRS Modem (SIM800)

Hardware Requirements

Raspberry Pi 4

GSM/GPRS Modem

5v 3A power source (For GSM modem

Serial Communication in Raspberry Pi 4

Open the LX teminal and type:

dmesg | grep tty

This command will list the available UART modules, as shown in the figure:

The list will show, ttyS0 – UART corresponding to the GPIO header.
#GSM TESTING CODE
import serial
import os, time
# Enable Serial Communication
port = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=1)
# Transmitting AT Commands to the Modem
# '\r\n' indicates the Enter key
port.write('AT'+'\r\n')
rcv = port.read(10)
print( rcv)

Run the code and if the connections are all working good, then we will receive
an OK acknowledgement in the python shell.

PPP Configuration
PPP or Point to Point Protocol establishes a Node to Node communication using
serial interface. We make use of this, while accessing serial data connection on a
PC. Here, using the serial connection, proper commands and PPP, we are about to
access the internet on Pi.
APN
An Access Point Name (APN) is the name of a gateway between a GSM/GPRS
network and the internet. The APN of the cellular network that we are using,
must be know to us. You can either ask it out on google or contact the service
provider. In this example, we have used IDEA connection and for the APN we
asked it on Google.
Installation
The first step is to disable the kernel’s use of the hardware serial connection. By
default, when the Raspberry Pi boots, it will use the serial connection to produce
messages from the kernel and it will confuse the GSM modem. Follow the steps
below

From Menu Select Preferences –> Raspberry Pi Configuration.

In this window, Select the interfaces tab and disable the serial option.
The next process is to install PPP Software. Make a suitable internet connection
on the RPi by means of an Ethernet cable or WiFi. Open the LX Terminal and type:
sudo apt-get update
sudo apt-get install ppp screen elinks

After the installation we have to create a new PPP peer configuration. For this
operation, we should login as root by entering sudo -i in the terminal and navigate
to the peers directory,
cd /etc/ppp/peers/
Now open a new file rnet in a text editor by executing:
nano rnet
Copy the code shown below to the new file.
#code start
#imis/internet is the apn for idea connection
connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T imis/internet"
# For Raspberry Pi4 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
#code end
From the above file, two parameters must be changed which depends on the
modules used. In the beginning command, connect, after the section -T, the APN
of the service provider should be given. Here we have used the APN of Idea
(imis/internet).
Then comes the communication port, as we have used Pi 4 in our exapmle , the
port name is /dev/ttyS0. Save the configuration file by pressing ctrl+x.

In the above file, with in the line connect, a chat script is mentioned. To see this
file, enter:
<strong>nano /etc/chatscripts/gprs</strong>

This will open a new file, which is not needed to be edited and this explains how a
GPRS connection is created. If the SIM card needs a PIN to unlock, un comment
the line AT+CPIN=1234 and set the pin instead of 1234. Save the file and exit.
Next is to establish the connection. Before that make sure, all the steps described
above are executed with no errors and proper wiring connections are also made.
Type, sudo pon rnet for creating the connection and it will exit with no response
shown in the Lx terminal but the PPPD should be setting up the connection. To
show the log for PPPD type,
<strong>cat /var/log/syslog | grep pppd</strong>

It will shows more messages and if the connection was established successfully,
we can see the messages at the end as shown in the figure:
In the terminal type ifconfig and enter.
A new section PPP0 can be seen with the IP 192.200.1.21. In the modem the blue led will blink fast
continuously as the connection in ON. To close the connection, type: sudo poff rnet.

You might also like