Sim 808
Thu Oct 03 2024 03:58:33 GMT+0000 (Coordinated Universal Time)
Saved by
@iliavial
#python
import serial
import time
# Set up the serial connection to the SIM800 module
ser = serial.Serial('/dev/serial0', baudrate=9600, timeout=1)
def send_at_command(command, delay=1):
"""Send an AT command to the SIM800 module."""
ser.write((command + '\r').encode())
time.sleep(delay)
reply = ser.read(ser.inWaiting()).decode()
return reply
# Enable GPS
send_at_command("AT+CGNSPWR=1")
# Check GPS status (optional)
gps_status = send_at_command("AT+CGNSPWR?")
print("GPS Status: ", gps_status)
# Get the GPS location
location_data = send_at_command("AT+CGNSINF", delay=2)
print("Location Data: ", location_data)
ser.close()
content_copyCOPY
Comments