Good python beginners course? Interested in software/hardware side more so.

Associate
Joined
11 Jul 2011
Posts
754
I've been watching a few beginner guides online to python i've got the jist of some of the basics (sort of) But i'd like some examples based on software/hardware things. As of right now i am working on a GPS with a sim868 module i've got it working and parsing the data like i want but thats from scraps of code around the internet. If i am honest i'd like to understand what it is actually calling and doing also.

So i could use some kind of learning based off that to make it more interesting.. Any ideas?



Cheers.

Heres my code if anyone is interested.

Code:
#!/usr/bin/python

import serial, time, pynmea2


#Enable Serial Communication
ser = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=1)
#Transmitting AT Commands to the Modem
#\r indicates the Enter key

ser.flushOutput()
ser.flushInput()

ser.write('ATE'+'\r') #Check to see if modem is responding
str = ser.readline()
print str
time.sleep(5)


ser.write('AT+CGPSOUT=32'+'\r') #Outputs raw NMEA data
str = ser.readline()
print str
time.sleep(3)


ser.write('AT+CGNSPWR=1,AT+CGPSSTATUS=?'+'\r') #Turns on the GPS power

while str.find ("Location Not Fix") > 1:
    print ('Waiting for a fix - ',str)
    ser.flushInput()
    ser.flushOutput()
    time.sleep(15)
    str = ser.readline(100)



ser.write('AT+CGNSTST=1'+'\r') #Starts sending data to UART
str = ser.readline()
print str
time.sleep(5)


#Parsing Raw NMEA data through pynmea2

ser.flushInput()
ser.flushOutput()
def parseGPS(str):
    if str.find("GGA") > 0:
        data = pynmea2.parse(str)
        print "Timestamp: %s -- Lat: %s %s -- Lon: %s %s " % (data.timestamp, data.latitude, data.lat_dir, data.longitude, data.lon_dir)


while True:
    str = ser.readline()
    parseGPS(str)
 
Get on Facebook and go over to the Python Programming Language or Python Programming Society groups, PPL is the more active and advanced groups. The admins can be a little, well, ****ish at times (I'm a mod there and an admin on PPS) but generally, if you follow the rules you'll be fine. Both groups are linked.
 
Back
Top Bottom