Lopy with pytrack, how connect/use GPS?
-
@zceld I appear to be having a similar issue that you were having, with a LoPy4 and PyTrack.
My error however is "I2C bus error"..I've updated the PyTrack to 0.0.8 (tried via Windows 10 and Debian) and LoPy4 to 1.14.0.b1, ran "os.mkfs('/flash')" and re-uploaded the files from a ZIP download of the Git (https://github.com/pycom/pycom-libraries).
This is what I get (I added the "print(e)" in pycoproc.py which is returning "I2C bus error"):
@zceld - was there anything else you did other than update PyTrack via your Mac?!
-
I am happy to inform you that with this code I have at least managed to obtain coordinates without failure:
Code:
import machine import math import network import os import time import utime from machine import RTC from machine import SD from machine import Timer from L76GNSS import L76GNSS from pytrack import Pytrack # setup as a station import gc 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 = Pytrack() l76 = L76GNSS(py, timeout=30) chrono = Timer.Chrono() chrono.start() #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()))
Result:
Thank you very much to all of you who have had to endure my clumsiness and have helped me especially: @seb and @livius, include @crumble ! :-)
taking advantage of the post with the doubts and problems that I have had, I will shortly upload a guide in Spanish (since it is already in English) on the subject to facilitate other people.
-
@zceld
Well finally it seems that with this code at least try to get the GPS coordinates.On the other hand now comes another problem and it seems that it runs out of memory. What do you think? the idea of operation is to collect the signal from the gps of a vehicle and send it to LoRa. I understand that if it is due to lack of memory, it will be necessary to program something to clean the cache or something that increases when using the program, not?
CODE:
import time
from L76GNSS import L76GNSS
from pytrack import Pytrackpy = Pytrack()
l76 = L76GNSS(py, timeout=30)
while (True):
coord = l76.coordinates()
print(coord)
time.sleep(1)I am waiting for new news. Thank you very much for your patience
-
It seems that at least you have tried a couple of times, get the coordinates!
After I forget this, I would not know how to fix it:
Afterwards he does not let me try it anymore:
-
okay! it seems that the update of the pytrack was not effective for windows despite the screenshot showed that yes, because now at least we can call the class Pytrack ().
The problem when running the main.py that in my case is called main3.py but that it is the same program as this one:
Well now the fault is as follows:
At least we have already advanced! ;-)
-
@seb
I am also trying to update from this PC again as I mentioned and it is a Mac, but this command that indicates the guide does not accept it:
https://docs.pycom.io/chapter/pytrackpysense/installation/firmware.htmlI update this part above to show you that I finally got back to update the board through the Mac:
<-------------- current topic: ------------------->
Well I have made the changes, updated the file in the pycom.
I have tried again the previous and even the main.py but it still fails. I will also try to update the pytrack with Mac.@seb said in Lopy with pytrack, how connect/use GPS?:
if self.read_fw_version() < 6:
raise ValueError('Firmware out of date (Version: {})'.format(self.read_fw_version()))
-
Ah, thats annoying, because the error happens when trying to create
py
and fails we cant then use it later. I am afraid you will have to edit the library some more:if self.read_fw_version() < 6: raise ValueError('Firmware out of date')
to
if self.read_fw_version() < 6: raise ValueError('Firmware out of date (Version: {})'.format(self.read_fw_version()))
I will make some changes to the library on github once we solve this to make this easier in the future.
-
@seb
Thank you very much for all the support, I have made the indicated and I keep saying the same.
-
I upvoted some of your posts, the limit should now be much shorter.
ok sorry, can you try running this instead:
from pytrack import Pytrack py = Pytrack() py.read_fw_version()
-
@seb yes! Sorry, as I gave an error I was trying and I sent you a test here you have the complete test.
You will also have to apologize for taking a long time to answer the forum, it does not allow me to respond faster.:
-
you typed that in wrong, its
py
notpycom
-
true !, according to the console and the screenshot I answered that it had been updated successfully. I will also do it again from this pc that is different. For trying, I lose nothing.
-
Thats odd, its showing that the firmware version is outdated but you showed me the screenshot of you updating it. Can you please run the following in the REPL after the error:
py.read_fw_version()
and post back what it returns?
-
ok, I added the line of code you indicated and updated the file on the board:
I check that the lines of code are in the uploaded file:
Bien, pues pruebo de nuevo a ejecutar el main.py:
Result:
-
Hi,
Thanks for confirming all of that. To debug this further could you change the following two lines of code in
pycoproc.py
so we can see in more detail what error is occurring:108 except Exception: 109 raise Exception('Board not detected')
to
108 except Exception as e: 109 print(e) 110 raise Exception('Board not detected')
-
Well, since you told me in the procedure to update it. Therefore I have the 'pytrack' and 'pycom' plate:
I understand that the board is well connected because I connect with it by the usb from pytrack to Atom and it responds to all commands os. , for example pycom.heartbeat (False) and the LED goes off. I also upload a short video and show you the directory listings.
video/gif:
https://imgur.com/a/eQl9hDirectory:
Everything you need I'll show you to know or reach the solution.
-
That error message means the library was not able to detect the Pytrack. Are you sure you have connected your module to your pytrack board properly, are all the pins pushed in fully? Have you updated the firmware on your Pytrack board to the latest available? (note: this is not the same as the firmware of the main pycom module)
-
@seb
Hello again!I followed your steps and used 'os.mkfs (' / flash ')'
I have copied again the codes of the page:
https://github.com/pycom/pycom-libraries/tree/master/pytrack/libFrom here I copied the three files and also the main.
I tried to run and this error came out:
So I went to download that library to see if that solved that.
I copied it from here:
https://github.com/pycom/pycom-libraries/tree/master/lib/pycoprocI have uploaded the library to the device and that problem seems to have
been solved.
Then he stopped in the following:
There is something that I do not understand or that I do not do well, I do not think it is so difficult. Therefore I wanted to try to execute the code directly in the Atom console so following the example that you have put me:
and neither.So, I do not know what exactly each program is for. That is to say for example this file:
https://github.com/pycom/pycom-libraries/blob/master/pytrack/main.pyI understand that it serves to run from Atom and I print on screen the data obtained from the GPS module ?. It would be more or less what I'm looking for since what I need is for this plate to be carried by a vehicle and while it is on, keep the GPS position every 30 seconds.
For example, the microGPS file does not know what it is for. I was just testing everything I found to refer to the GPS to see if I could get data.
But I have to admit that I'm stuck. I do not know what I do wrong or what else to try.
-
@zceld
go to advice provided by @seb (remember that this clear your device flash completly)
and if you need to usemicroGPS.py
then you need to change line inL76GNSS.py
nmea += self._read().lstrip(b'\n\n').rstrip(b'\n\n')
and feed microGPS object with chars from nmea e.g.
create first microGPS object somwhere in the file `L76GNSS.py` that it will be accessible (best is add it as property) mgps = MicropyGPS() ..... nmea = self._read().lstrip(b'\n\n').rstrip(b'\n\n') for c in nmea: sentence = mgps.update(c) if sentence: do_something_here
-
That error means that there is something wrong with
/flash/lib/L76GNSS.py
, Can you please reformat your device by running the following in the REPL:import os os.mkfs('/flash')
And then download a fresh copy of all the files from git to make sure they are not currupt, you should have:
main.py
lib/L76GNSS.py
lib/pytrack.py
lib/pycoproc.py