This repository was archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 370
/
Copy pathpytrack_2.py
68 lines (58 loc) · 1.53 KB
/
pytrack_2.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
#
# Copyright (c) 2020, Pycom Limited.
#
# This software is licensed under the GNU GPL version 3 or any
# later version, with permitted additional terms. For more information
# see the Pycom Licence v1.0 document supplied with this file, or
# available at https://www.pycom.io/opensource/licensing
#
import machine
import math
import network
import os
import time
import utime
import gc
import pycom
from machine import RTC
from machine import SD
from L76GNSS import L76GNSS
from pycoproc_2 import Pycoproc
pycom.heartbeat(False)
pycom.rgbled(0x0A0A08) # white
time.sleep(2)
gc.enable()
# setup rtc
rtc = machine.RTC()
rtc.ntp_sync("pool.ntp.org")
utime.sleep_ms(750)
print('\nRTC Set from NTP to UTC:', rtc.now())
utime.timezone(7200)
print('Adjusted from UTC to EST timezone', utime.localtime(), '\n')
py = Pycoproc()
if py.read_product_id() != Pycoproc.USB_PID_PYTRACK:
raise Exception('Not a Pytrack')
time.sleep(1)
l76 = L76GNSS(py, timeout=30, buffer=512)
pybytes_enabled = False
if 'pybytes' in globals():
if(pybytes.isconnected()):
print('Pybytes is connected, sending signals to Pybytes')
pybytes_enabled = True
# sd = SD()
# os.mount(sd, '/sd')
# f = open('/sd/gps-record.txt', 'w')
while (True):
coord = l76.coordinates()
#f.write("{} - {}\n".format(coord, rtc.now()))
print("{} - {} - {}".format(coord, rtc.now(), gc.mem_free()))
if(pybytes_enabled):
pybytes.send_signal(1, coord)
time.sleep(10)
"""
# sleep procedure
time.sleep(3)
py.setup_sleep(10)
py.go_to_sleep()
"""