Editing Team6 GPS

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
#REDIRECT [[NEO-6M]]
+
= NEO-6M GPS with a high-gain patch antenna =
 +
The NEO-6M is a GPS module consists of the GPS chip which is the heart of this module and an antenna required for any kind of communication. This GPS-Module can track up to 5 location updates per second with 2.5m position accuracy. What makes the NEO-6M very suitable for smartwatches is the Power Save Mode, which reduces the power consumption to just 11 mA.
 +
 
 +
== Technical Specifications ==
 +
The NEO-6M GPS is an I2C sensor, which means that the usage of the clock/data wires is possible, and it can share these pins on the microcontroller with other sensors. In the following are some more specification to gain more technical insides.
 +
 
 +
* Tracking: 22 satellites on 50 channels
 +
* Horizontal position accuracy: 2.5m
 +
* Serial baud rate: 4800-230400 (default 9600)
 +
* Operating range: -40 to 85°C
 +
* Operating voltage: 3.3V – 5V
 +
 
 +
The antenna is important for this module and handles any kind of communication. It is a high-gain patch antenna with a sensitivity of -161 dBm. It can be connected to the chip via an IPEX connector, which means it is an easy snap-fit on the module.
 +
 
 +
The NEO-6M GPS module has an LED which gives information about the fix position. The LED blinks differently based on the state of the module. No blinking means the module is searching for satellites. If the LED is blinking every second, it means the chip can see enough satellites and has found a Position Fix.
 +
 
 +
=== Pinout ===
 +
* '''VCC''' - power pin for the GPS module which can take 3-5V DC
 +
* '''TX''' - transmission pin for serial communication
 +
* '''RX''' - receiver pin for serial communication
 +
* '''GND'''
 +
 
 +
== Advantages and Disadvantages ==
 +
=== Advantages ===
 +
* Very little power consumption
 +
* 23mm x 30mm dimension – usable for smartwatches
 +
* Highest level of sensitivity
 +
* Tracking of 5 locations per second
 +
 
 +
=== Disadvantages ===
 +
* Relatively large antenna
 +
* Takes a while to find satellites in closed rooms
 +
 
 +
= How to get it to work =
 +
To get this module started you first must solder the delivered pins on the GPS module, if it is not already done. After doing so, the wiring with the Raspberry Pi Pico can start. To get the NEO-6M GPS started, there are no other libraries necessary.
 +
 
 +
== Wiring with Raspberry Pi Pico ==
 +
 
 +
{| class="wikitable" style="margin:auto"
 +
|-
 +
! NEO-6M GPS Module !! Raspberry Pi Pico
 +
|-
 +
| GND || GND
 +
|-
 +
| TX || GP4 (Pin6) - UART1 TX
 +
|-
 +
| RX || GP5 (Pin 7) - UART1 RX (not necessary to wire)
 +
|-
 +
| VCC || VCC (Pin 36)
 +
|}
 +
 
 +
== Code Example ==
 +
<syntaxhighlight lang="python" line='line'>#import relevant modules
 +
from machine import Pin, UART, I2C
 +
import utime, time
 +
 
 +
#GPS Module UART Connection
 +
gps_module = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
 +
print(gps_module)
 +
 
 +
#Used to Store NMEA Sentences
 +
buff = bytearray(255)
 +
 
 +
TIMEOUT = False
 +
 
 +
#store the status of satellite is fixed or not
 +
FIX_STATUS = False
 +
 
 +
#Store gps coordinates
 +
latitude = ""
 +
longitude = ""
 +
satellites = ""
 +
gpsTime = ""
 +
 
 +
#get gps coordinates
 +
def getPositionData(gps_module):
 +
    global FIX_STATUS, TIMEOUT, latitude, longitude, satellites, gpsTime
 +
   
 +
    #run while loop to get gps data
 +
    #or terminate while loop after 5 seconds timeout
 +
    timeout = time.time() + 8  # 8 seconds from now
 +
    while True:
 +
        gps_module.readline()
 +
        buff = str(gps_module.readline())
 +
        parts = buff.split(',')
 +
       
 +
        #if no gps displayed remove "and len(parts) == 15" from below if condition
 +
        if (parts[0] == "b'$GPGGA" and len(parts) == 15):
 +
            if(parts[1] and parts[2] and parts[3] and parts[4] and parts[5] and parts[6] and parts[7]):
 +
               
 +
                latitude = convertToDigree(parts[2])
 +
                # parts[3] contain 'N' or 'S'
 +
                if (parts[3] == 'S'):
 +
                    latitude = -latitude
 +
                longitude = convertToDigree(parts[4])
 +
                # parts[5] contain 'E' or 'W'
 +
                if (parts[5] == 'W'):
 +
                    longitude = -longitude
 +
                satellites = parts[7]
 +
                gpsTime = parts[1][0:2] + ":" + parts[1][2:4] + ":" + parts[1][4:6]
 +
                FIX_STATUS = True
 +
                break
 +
               
 +
        if (time.time() > timeout):
 +
            TIMEOUT = True
 +
            break
 +
        utime.sleep_ms(500)
 +
       
 +
#convert raw Latitude and Longitude to actual Latitude and Longitude
 +
def convertToDigree(RawDegrees):
 +
    RawAsFloat = float(RawDegrees)
 +
    firstdigits = int(RawAsFloat/100) #degrees
 +
    nexttwodigits = RawAsFloat - float(firstdigits*100) #minutes
 +
   
 +
    Converted = float(firstdigits + nexttwodigits/60.0)
 +
    Converted = '{0:.6f}'.format(Converted) # to 6 decimal places
 +
    return str(Converted)
 +
   
 +
   
 +
while True:
 +
    getPositionData(gps_module)
 +
 
 +
    #if gps data is found then print it on lcd
 +
    if(FIX_STATUS == True):
 +
        print("Printing GPS data...")
 +
        print(" ")
 +
        print("Latitude: "+latitude)
 +
        print("Longitude: "+longitude)
 +
        print("Satellites: " +satellites)
 +
        print("Time: "+gpsTime)
 +
        print("----------------------")
 +
       
 +
        FIX_STATUS = False
 +
       
 +
    if(TIMEOUT == True):
 +
        print("Request Timeout: No GPS data is found.")
 +
        TIMEOUT = False
 +
 
 +
</syntaxhighlight>
 +
 
 +
== Instruction Video ==
 +
Uploaded to Uni2Work

Please note that all contributions to Sketching with Hardware at LMU Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see My wiki:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)