sohotcall

SIM800L Python AT Command Send SMS

Oct 15th, 2018
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ sudo pip3 install pyserial
  2. $ sudo python3
  3. >>> import serial
  4. >>> phone = serial.Serial('/dev/ttyUSB0', 115200, timeout=5)
  5. >>> phone.write(b'AT\r'); phone.read_until('~~PULU~~')
  6. 3
  7. b'AT\r\r\nOK\r\n'
  8. >>> phone.write(b'AT+COPS?\r'); phone.read_until('~~PULU~~')
  9. 9
  10. b'AT+COPS?\r\r\n+COPS: 0,0,"EXCELCOM"\r\n\r\nOK\r\n'
  11. >>> phone.write(b'AT+CMGF=1\r'); phone.read_until('~~PULU~~')
  12. 10
  13. b'AT+CMGF=1\r\r\nOK\r\n'
  14. >>> phone.write(b'AT+CMGS="+6281234567890"\r'); phone.read_until('~~PULU~~');
  15. 25
  16. b'AT+CMGS="+6281234567890"\r\r\n> '
  17. >>> phone.write(b'Aku siap, aku siap\nLalalala\r'); phone.write(bytes([26])); phone.read_until('~~PULU~~')
  18. 28
  19. 1
  20. b'Aku siap, aku siap\nLalalala\r\n> \r\n+CMGS: 0\r\n\r\nOK\r\n'
RAW Paste Data