Med dette modul kan du modtage GPS informationer via en UART forbindelse
GPS
Med en UART forbindelse til dette GPS modul kan du modtage information med høj præcision hvor på jorden modulet befinder sig, hvor hurtigt det bevæger sig, i hvilket retning det bevæger sig og hvor mange satellitter det kan "se".
Tekniske specifikationer
Kreds | GY-GPS6MV2, NEO-6M |
Interface | UART |
Operativ spænding | 3-5V |
Default Baud Rate | 9600 bps |
PCB dimensioner | 25mm x 35mm |
Antenne dimensioner | 12mm x 12mm |
Kabel længde | 20mm |
Kode Eksempel
from machine import UART
from micropyGPS import MicropyGPS
def main():
uart = UART(2, baudrate=9600, bits=8, parity=None, stop=1, timeout=5000, rxbuf=1024)
gps = MicropyGPS()
while True:
buf = uart.readline()
if buf is not None:
for char in buf:
gps.update(chr(char))
print('UTC Timestamp:', gps.timestamp)
print('Date:', gps.date_string('long'))
print('Satellites:', gps.satellites_in_use)
print('Altitude:', gps.altitude)
print('Latitude:', gps.latitude_string())
print('Longitude:', gps.longitude_string())
print('Horizontal Dilution of Precision:', gps.hdop)
formattedLat = gps.latitude_string()
formattedLat = formattedLat[:-3]
formattedLon = gps.longitude_string()
formattedLon = formattedLon[:-3]
formattedAlt = str(gps.altitude)
formattedSpd = gps.speed_string()
formattedSpd = formattedSpd[:-5]
speed = gps.speed_string()
gps_ada = formattedSpd + "," + formattedLat + "," + formattedLon + "," + formattedAlt
if formattedLat != "0.0":
print("gps_ada: ",gps_ada)
return gps_ada, speed
else:
break
else:
break
if __name__ == "__main__":
print('...running main, GPS testing')
main()
Importeret bibliotek: https://github.com/inmcm/micropyGPS
Pinout
Pinout
Navn | Function |
---|---|
VCC | Positiv forsyning |
RX | RX til UART kommunikation |
TX | TX til UART kommunikation |
GND | Negativ forsyning |
Hvordan fungerer den?
Referencer
GPS modul, ESP32 og MicroPython: https://microcontrollerslab.com/neo-6m-gps-module-esp32-micropython/
Benyttet GPS modul fra github: https://github.com/inmcm/micropyGPS
Inspiration og kommentarer
Er du faldet over links eller lignende, som kan være relevant for dine medstuderende så send os en mail på nini@kea.dk