gy-ne06mv2

gy-ne06mv2

GPS  плата и антенна. 






ESP32 > gy-ne06mv2
 GND > GND
 3.3V > VCC
 D17 > RX
 D16 > TX

 

main.py     

from machine import UART
import time

uart = UART(2, baudrate=9600, rx=16, tx=17)

satellites = 0

def convert_to_degrees(raw, direction):
    if not raw:
        return None
    
    raw = float(raw)
    degrees = int(raw / 100)
    minutes = raw - degrees * 100
    decimal = degrees + minutes / 60
    
    if direction in ['S', 'W']:
        decimal = -decimal
        
    return decimal


while True:
    if uart.any():
        line = uart.readline()
        
        if line:
            try:
                line = line.decode('utf-8')
                
                # ---- GGA (количество спутников)
                if "$GPGGA" in line:
                    parts = line.split(',')
                    satellites = parts[7]

                # ---- RMC (координаты)
                if "$GPRMC" in line:
                    parts = line.split(',')
                    
                    if parts[2] == 'A':  # есть фикс
                        lat = convert_to_degrees(parts[3], parts[4])
                        lon = convert_to_degrees(parts[5], parts[6])
                        
                        print("Latitude:", lat)
                        print("Longitude:", lon)
                        print("Satellites:", satellites)
                        print("--------------------")
            
            except:
                pass

    time.sleep(0.1)


Комментарии

Популярные сообщения из этого блога

Meshtastic ESP32 E22

LORA Upgrade E32 400M30S

Установка micropython на ESP32