forked from kthanigaivel/ublox-gps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgps.py
31 lines (21 loc) · 705 Bytes
/
gps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from machine import UART
import uasyncio as asyncio
# pin tx and rx
uart= UART(0,baudrate=9600,tx=Pin(0),rx=Pin(1),bits=8,parity=None,stop=1)
async def sender():
swriter = asyncio.StreamWriter(uart, {})
while True:
print('Wrote')
await asyncio.sleep(1)
async def receiver():
sreader = asyncio.StreamReader(uart)
while True:
nmea = await sreader.readline()
#print('Recieved', nmea.rstrip().decode("utf-8"))
if nmea.startswith( '$GPRMC' ) :
dic={nmea[:7]:nmea.rstrip().decode('utf-8')}
print(dic)
loop = asyncio.get_event_loop()
loop.create_task(sender())
loop.create_task(receiver())
loop.run_forever()