Introduction

Hi guys, in this article we will see how to interface GSM Module with Raspberry pi and send SMS using python.

Components Required

  • Raspberry Pi (with OS installed SD card) – 1
  • GSM module (SIM800) – 1
  • TTL Converter – 1
  • Jumper Wires

Schematic Diagram

Code

import serial as io

gsm = io.Serial("/dev/ttyUSB0",9600, timeout=0.5)
gsm.flush()

def sendSms(msg):
    print("Sending SMS\n")
    gsm.write(b'AT+CMGF=1\r\n')
    sleep(0.5)
    gsm.write(b'AT+CMGS=\"')
    serialcmd = args["mobile"]
    gsm.write(serialcmd.encode())
    gsm.write(b'\"\r\n')
    sleep(0.5)
    data = msg
    gsm.write(data.encode())
    gsm.write(b'\x1A')
    sleep(3)

sendSms("Hello mevihub.com")

Thanks for reading this article for any assistance or doubts comment below.

Leave a Reply

Your email address will not be published.

%d bloggers like this: