Raspberry Pi integration with GSM/GPRS SIM800A

Nataraj
3 min readFeb 17, 2022

Let see how to integrate GSM/GPRS SIM800A to Raspberry Pi

GSM/GPRS module: SIM800L GSM/GPRS Module is shown in Fig.4.It is used for sending, receiving SMS, making and receiving voice calls.

I assume that you would know how to connect the SIM900A to Pi

Steps

  1. Install the SimCard in the sim slot
  2. Connect the SIM800A to Pi GPIO pins
  3. Configure the ppp deamon in Pi (Steps are explained below)
  4. Use minicom or similar software to access the device (similar to our old modems) use AT commands to operate (attached the references)

Install and configure PPP in Raspberry PI

dmesg | grep tty #to get to know the terminal interface
sudo raspi-config->Interfacing Options->Serial->Serial login shell disable,Serial interface enabled

apt install ppp

vi /etc/ppp/peers/rnet
#imis/internet is the apn for idea connection
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

sudo pon rnet
ifconfig # you should be able to see the PPPx interface with an IP assigned

tail -f /var/log/syslog | grep pppd

Once you have configured the serial port you can access the device using minicom or similar program. Connect to the Serial Interface using minicom

minicom -D /dev/ttyS0 -b 115200

OPERATOR SELECTION:
AT+COPS=?
AT+COPS?
For voice call
ATD<mobilenumber>; (ATD730100000)

Hangup
ATH

Redial Last Number
ATDL
Receive Incoming call
ATA

TO SET A PARTICULAR BAUDRATE:
AT+IPR=? {To view the baud rate values}
AT+IPR=0 {To set the modem to autobauding mode}

AT+CLIP=1

SMS
Enable text mode
AT+CMGF=1
AT+CMGS=”0000000000"
CtrlZ

To unlock Sim Pin
AT+CPIN=1234

Reference
AT+CSQ?
AT+CSQ
AT+IPR
AT+CFUN=1

AT+CRC SET CELLULAR RESULT CODES FOR INCOMING CALL INDICATION:

AT+CRC=?
+CRC: (0–1)
OK
AT+CRC?
+CRC: 0
OK
AT+CRC=1
OK
+CRING: VOICE

READ OPERATOR NAMES.
AT+COPN=?
OK
AT+COPN
+COPN: “472001”,”DHIMOBILE”
+COPN: “60500
+COPN: “502012”,”maxis mobile”
+COPN:
+COPN: “502013”,”TMTOUCH”
+COPN
+COPN: “502016”,”DiGi”
+COPN: “502017”,”TIMECel””
+COPN: “502019”,”CELCOM GSM”

GPRS COMMANDS:

AT+CGATT ATTACH/DETACH FROM GPRS SERVICE
AT+CGDCONT DEFINE PDP CONTEXT
AT+CGQMIN QUALITY OF SERVICE PROFILE (MINIMUM ACCEPTABLE)
AT+CGQREQ QUALITY OF SERVICE PROFILE (REQUESTED)
AT+CGACT PDP CONTEXT ACTIVATE OR DEACTIVATE
AT+CGDATA ENTER DATA STATE
AT+CGPADDR SHOW PDP ADDRESS
AT+CGCLASS GPRS MOBILE STATION CLASS
AT+CGEREP CONTROL UNSOLICITED GPRS EVENT REPORTING
AT+CGREG NETWORK REGISTRATION STATUS
AT+CGSMS SELECT SERVICE FOR MO SMS MESSAGES
AT+CGCOUNT GPRS PACKET COUNTERS

Gsm Testing Code

#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)

Serial Testing Code

# Serial.py

import serial
import time

port = “/dev/ttyAMA0” # Raspberry Pi 2
#port = “/dev/ttyS0” # Raspberry Pi 3

def readLine(port):
s = “”
while True:
ch = port.read()
s += ch
if ch == ‘\r’:
return s

ser = serial.Serial(port, baudrate = 1200)
print “starting”
while True:
time.sleep(1)
print “sending synch”
ser.write(“A”)
rcv = readLine(ser)
print “received:”, rcv

--

--