import serial
# Set up the connection to the dongle
dongle = serial.Serial(port="/dev/ttyUSB2",baudrate=9600,timeout=0,rtscts=0,xonxoff=0)
# This sends the command to the dongle
def sendatcmd(cmd):
dongle.write('AT'+cmd+'\r')
# put the dongle into text mode
sendatcmd('+CMGF=1')
# Set the telephone number we want to send to
sendatcmd('+CMGS="+08968462517"')
# Set the message we want to send
dongle.write('Pakan ikan telah habis, segera isi ulang')
# Pass the CTRL+Z character to let the dongle know we're done
dongle.write(chr(26))
# Close the connection
dongle.close()
Tidak ada komentar:
Posting Komentar