gy-ne06mv2
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)

Комментарии
Отправить комментарий