9

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

Gath
  • 569
  • 2
  • 8
  • 7

2 Answers2

15

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...

c0m4
  • 4,343
  • 10
  • 35
  • 40
4

I don't know if there is an AT module, but you can use pyserial to communicate with a serial port.

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194