Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you send AT GSM commands using python?

Tags:

python

modem

How do i send AT GSM commands using python?

Am able to do this quite easily using Delphi and some comport component (TComport), but how do i talk to my modem using python?

Gath

like image 974
Gath Avatar asked Mar 23 '09 06:03

Gath


People also ask

How do you write commands in Python?

1. Basic syntax: are in the format “AT<x><n>” where <x> is the command and <n> is the optional arguments. If the arguments are not passed, the default arguments are automatically used by the modem. 2.

Which command instructions are used to control a GSM modem?

They are known as AT commands because every command line starts with “AT” or “at”. AT commands are instructions used to control a modem. AT is the abbreviation of ATtention.

How do I connect SIM900A to Raspberry Pi?

You can use the UART, I2C, or SPI interfaces to connect the module serially with a controlling device. For communicating over the UART protocol, simply connect the Txd and Rxd of the module with RPi's Rxd and Txd using a 5 to 3.3V TTL Logic Shifter. Remember that SIM900A is a 5V device with a 5V UART port.


1 Answers

I do it like this with pyserial:

import serial

serialPort = serial.Serial(port=1,baudrate=115200,timeout=0,rtscts=0,xonxoff=0)
def sendatcmd(cmd):
    serialPort.write('at'+cmd+'\r')

print 'Loading profile...',
sendatcmd('+npsda=0,2')

Then I listen for an answer...

like image 87
c0m4 Avatar answered Sep 27 '22 21:09

c0m4