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
![](https://i0.wp.com/mevihub.com/wp-content/uploads/2021/03/schematic_bb.png?resize=640%2C242&ssl=1)
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.