Skip to content

Instantly share code, notes, and snippets.

@mgarg1
Last active October 23, 2021 19:48
Show Gist options
  • Save mgarg1/6d6674cb772a1fd36b06d02bb1f27b4d to your computer and use it in GitHub Desktop.
Save mgarg1/6d6674cb772a1fd36b06d02bb1f27b4d to your computer and use it in GitHub Desktop.
my experiment with GSM HAT
import serial
import os, time
import RPi.GPIO as GPIO
#SERIAL_PORT = "/dev/ttyAMA0"
SERIAL_PORT = "/dev/ttyS0"
BAUD_RATE = 9600
GPIO.setmode(GPIO.BOARD)
# Pyserial Doc : https://pythonhosted.org/pyserial/pyserial_api.html
with serial.Serial(SERIAL_PORT,baudrate=BAUD_RATE, timeout=1) as port:
print('sending AT..')
#port.write(b'AT\r')
port.write(b'AT+CNUM\r')
port.flush()
#port.write(b'AT+CMGF=1\r')
rcv = port.read(1000)
print('recvd response')
print(rcv.decode("utf-8"))
time.sleep(1)
#port.write(b'ATD919660813119\r')
#print('calling...')
#time.sleep(30)
#port.write(b'ATH\r')
#print('Hang call...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment