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
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.
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.
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With