Team6 GPS

From Sketching with Hardware at LMU Wiki
Jump to navigation Jump to search

NEO-6M GPS with a high-gain patch antenna[edit]

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[edit]

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[edit]

  • 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[edit]

Advantages[edit]

  • Very little power consumption
  • 23mm x 30mm dimension – usable for smartwatches
  • Highest level of sensitivity
  • Tracking of 5 locations per second

Disadvantages[edit]

  • Relatively large antenna
  • Takes a while to find satellites in closed rooms

How to get it to work[edit]

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[edit]

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[edit]

 1 #import relevant modules
 2 from machine import Pin, UART, I2C
 3 import utime, time
 4 
 5 #GPS Module UART Connection
 6 gps_module = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
 7 print(gps_module)
 8 
 9 #Used to Store NMEA Sentences
10 buff = bytearray(255)
11 
12 TIMEOUT = False
13 
14 #store the status of satellite is fixed or not
15 FIX_STATUS = False
16 
17 #Store gps coordinates
18 latitude = ""
19 longitude = ""
20 satellites = ""
21 gpsTime = ""
22 
23 #get gps coordinates
24 def getPositionData(gps_module):
25     global FIX_STATUS, TIMEOUT, latitude, longitude, satellites, gpsTime
26     
27     #run while loop to get gps data
28     #or terminate while loop after 5 seconds timeout
29     timeout = time.time() + 8   # 8 seconds from now
30     while True:
31         gps_module.readline()
32         buff = str(gps_module.readline())
33         parts = buff.split(',')
34         
35         #if no gps displayed remove "and len(parts) == 15" from below if condition
36         if (parts[0] == "b'$GPGGA" and len(parts) == 15):
37             if(parts[1] and parts[2] and parts[3] and parts[4] and parts[5] and parts[6] and parts[7]):
38                 
39                 latitude = convertToDigree(parts[2])
40                 # parts[3] contain 'N' or 'S'
41                 if (parts[3] == 'S'):
42                     latitude = -latitude
43                 longitude = convertToDigree(parts[4])
44                 # parts[5] contain 'E' or 'W'
45                 if (parts[5] == 'W'):
46                     longitude = -longitude
47                 satellites = parts[7]
48                 gpsTime = parts[1][0:2] + ":" + parts[1][2:4] + ":" + parts[1][4:6]
49                 FIX_STATUS = True
50                 break
51                 
52         if (time.time() > timeout):
53             TIMEOUT = True
54             break
55         utime.sleep_ms(500)
56         
57 #convert raw Latitude and Longitude to actual Latitude and Longitude
58 def convertToDigree(RawDegrees):
59     RawAsFloat = float(RawDegrees)
60     firstdigits = int(RawAsFloat/100) #degrees
61     nexttwodigits = RawAsFloat - float(firstdigits*100) #minutes
62     
63     Converted = float(firstdigits + nexttwodigits/60.0)
64     Converted = '{0:.6f}'.format(Converted) # to 6 decimal places
65     return str(Converted)
66     
67     
68 while True:
69     getPositionData(gps_module)
70 
71     #if gps data is found then print it on lcd
72     if(FIX_STATUS == True):
73         print("Printing GPS data...")
74         print(" ")
75         print("Latitude: "+latitude)
76         print("Longitude: "+longitude)
77         print("Satellites: " +satellites)
78         print("Time: "+gpsTime)
79         print("----------------------")
80         
81         FIX_STATUS = False
82         
83     if(TIMEOUT == True):
84         print("Request Timeout: No GPS data is found.")
85         TIMEOUT = False

Instruction Video[edit]

Uploaded to Uni2Work