Last active
July 14, 2021 00:23
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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