pitracker's Introduction
pitracker's People
pitracker's Issues
Not working with SIM7600
I am working with HAT Waveshare SIM7600, but It doen't work because AT commands are not the same. I have been editing the script, modifying some AT commands, but the problem is when reading the messages.
Could you help me to solve this problem?
import time
import math
import sys
from pygsm import GsmModem
# Switch GPS on
def SwitchGPSon():
print "Switching GPS on ..."
reply = gsm.command('AT+CGPS=0')
reply = gsm.command('AT+CGPS=1')
print reply
print
def SwitchGPSoff():
print "Switching GPS off ..."
reply = gsm.command('AT+CGPS=0')
print reply
print
def SendGPSPosition():
print "Getting GPS position ..."
reply = gsm.command('AT+CGPSINFO')
list = reply[0].split(",")
UTC = list[2][8:10]+':'+list[2][10:12]+':'+list[2][12:14]
Latitude = list[3]
Longitude = list[4]
Altitude = list[5]
print 'Position: ' + UTC + ', ' + Latitude + ', ' + Longitude + ', ' + Altitude
# Text to mobile
Message = ' Position: ' + UTC + ', ' + str(Latitude) + ', ' + str(Longitude) + ', ' + str(Altitude) + ' http://maps.google.com/?q=' + str(Latitude) + ',' + str(Longitude)
print "Sending to mobile " + MobileNumber + ": " + Message
gsm.send_sms(MobileNumber, Message)
# Set mobile number here
MobileNumber = "xxxxxxxxxxx"
lastmessage = 'Stop'
print "Booting modem ..."
gsm = GsmModem(port="/dev/ttyUSB2")
gsm.boot()
print "Modem details:"
reply = gsm.hardware()
print "Manufacturer = " + reply['manufacturer']
print "Model = " + reply['model']
# Try and get phone number
reply = gsm.command('AT+CNUM')
if len(reply) > 1:
list = reply[0].split(",")
phone = list[1].strip('\"')
print "Phone number = " + phone
print
print "Deleting old messages ..."
gsm.query("AT+CMGD=70,4")
print
SwitchGPSon()
print "Boot successful, waiting for messages ..."
while True:
# Check messages
message = gsm.next_message('AT+CGML')
if message:
print "loop 1"
print message
text = message.text
if text[0:5] == 'Start':
print "Start sending Position ..."
SendGPSPosition()
lastmessage = 'Start'
time.sleep(300)
elif text[0:4] == 'Stop':
print "Text was Stop. Stop sending"
lastmessage = 'Stop'
else:
if lastmessage == 'Start':
print(lastmessage+' loop2')
SendGPSPosition()
time.sleep(300)
else:
time.sleep(10)
root@PIZERO2A:/# python /pitracker/tracker.py
Booting modem ...
Modem details:
Manufacturer = SIMCOM INCORPORATED
Model = SIMCOM_SIM7600E-H
Deleting old messages ...
Switching GPS on ...
['OK']
Boot successful, waiting for messages ...
`
Thanks for your help!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.