Skip to content

Instantly share code, notes, and snippets.

@thanhson1085
Last active July 14, 2021 00:23
Show Gist options
  • Save thanhson1085/71708306643c106cbccb to your computer and use it in GitHub Desktop.
Save thanhson1085/71708306643c106cbccb to your computer and use it in GitHub Desktop.
Send SMS from USB 3G viettel using Raspberry PI https://sonnguyen.ws/send-sms-from-raspberry-pi-with-usb-3g/
import serial
def send_text(number, text, path='/dev/ttyUSB1'):
ser = serial.Serial(path, timeout=1)
ser.write('AT+CMGF=%d\r' % 1)
ser.write('AT+CMGS="%s"\r' % number)
ser.write('%s\x1a' % text)
print ser.readlines()
ser.close()
send_text('098xxxxxx', 'hey how are you?')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment