By Abdul Rehman
Adafruit has a very good explanation about GPS interfacing. You may follow that tutorial or continue here.
To view, the available USB to TTL converter devices use the following command
If you had installed pyserial then you may list all your available COM ports using this command via python
python -m serial.tools.list_ports
Pyserial short Intro is a good place to get started with PySerial Library. One thing to remember while coding in Raspberry Pi 3 model is to use the naming convention difference from PI 2 model
port = "/dev/ttyAMA0" # Raspberry Pi 2 #port = "/dev/ttyS0" # Raspberry Pi 3
Deeper detail about serial communication as well as GPS string parsing code is available at the python-example website. From that link, we used this code to run and parse our GPS data
import serial port = "/dev/ttyAMA0" # Raspberry Pi 2 #port = "/dev/ttyS0" # Raspberry Pi 3 def parseGPS(data): # print "raw:", data if data[0:6] == "$GPGGA": s = data.split(",") if s == '0': print "no satellite data available" return time = s[0:2] + ":" + s[2:4] + ":" + s[4:6] lat = decode(s) dirLat = s lon = decode(s) dirLon = s alt = s + " m" sat = s print "Time(UTC): %s-- Latitude: %s(%s)-- Longitude:%s(%s)\ -- Altitute:%s--(%s satellites)" %(time, lat, dirLat, lon, dirLon, alt, sat) def decode(coord): # DDDMM.MMMMM -> DD deg MM.MMMMM min v = coord.split(".") head = v tail = v deg = head[0:-2] min = head[-2:] return deg + " deg " + min + "." + tail + " min" ser = serial.Serial(port, baudrate = 9600, timeout = 0.5) while True: data = ser.readline() parseGPS(data)
To reboot raspberry PI
sudo shutdown -r now
Install minicom terminal to view the available data from serial port
sudo apt-get install minicom
The use this command to run minicom
minicom -b 9600 -o -D /dev/ttyUSB0
This article explains the above-mentioned minicom installation process.
To Exit from minicom: click Ctrl- A, Z then X.
Minicom has a very bad user interface. Next best Option you have is “Screen Serial Consol”. You may install screen console using this command
sudo apt-get install screen
to run screen console use this command
sudo screen /dev/ttyUSB0 9600
To exit from screen console you can press
Ctrl + A then Ctrl + D . Doing this will detach you from the screen session which you can later resume by doing screen -r .
Cutecom is a GUI based serial monitor. You can install this by typing
sudo apt-get install cutecom lxterminal -e 'cutecom'
It shows output like this
16 April 2020
09 April 2020
05 April 2020
04 April 2020
03 April 2020
FYP Solutions Powered By Impressive Business WordPress Theme