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

CODE for GSM Interfaced With Raspberry Pi to Make a Call

This document contains Python code for interfacing a GSM modem with a Raspberry Pi to make a phone call. It utilizes the serial communication library and GPIO pins to send AT commands to the modem for configuration and dialing. The code includes commands for setting up the modem and initiating a call to a specified phone number.

Uploaded by

impact2017batch
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)
3 views

CODE for GSM Interfaced With Raspberry Pi to Make a Call

This document contains Python code for interfacing a GSM modem with a Raspberry Pi to make a phone call. It utilizes the serial communication library and GPIO pins to send AT commands to the modem for configuration and dialing. The code includes commands for setting up the modem and initiating a call to a specified phone number.

Uploaded by

impact2017batch
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/ 2

CODE FOR GSM Interfaced with

Raspberry Pi to Make a Call


import serial
import RPi.GPIO as GPIO
import os, time

GPIO.setmode(GPIO.BOARD)

# Enable Serial Communication


port = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=1)

# Transmitting AT Commands to the Modem


# '\r\n' indicates the Enter key

port.write(str.encode('AT'+'\r\n'))
rcv = port.read(10)
print (rcv)
time.sleep(1)

port.write(str.encode('ATE0'+'\r\n')) # Disable the Echo


rcv = port.read(10)
print (rcv)
time.sleep(1)

port.write(str.encode('AT+CMGF=1'+'\r\n')) # Select Message format as Text


mode
rcv = port.read(10)
print (rcv)
time.sleep(1)

port.write(str.encode('AT+CNMI=2,1,0,0,0'+'\r\n')) # New SMS Message


Indications
rcv = port.read(10)
print (rcv)
time.sleep(1)

port.write(str.encode('AT'+'\r'))
print(port.read(20))
time.sleep(1)
port.write(str.encode('ATE0\r'))
print(port.read(10))
port.write(str.encode('ATD9066773211;\r'))
port.write(str.encode('ATH\r'))
time.sleep(10)

You might also like