Hi - The issue is just that the 'console' reverts to Serial1 (which you have the GPS on when USB is disconnected).
Just add USB.setConsole(1) to onInit() and you'll be sorted - it forces the console to stay on USB.
Also, I would:
Rename oninit to onInit (it's case sensitive)
Remove the call to oninit() and save() from your code, and just type save() on the left-hand side after upload.
That'll make sure onInit() is called just once on startup (it's done automatically after the save()). If it gets called twice (once before save and once after) then you'll end up with 2 sets of GPS modules added and so two sets of identical readings added to the file.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi - The issue is just that the 'console' reverts to Serial1 (which you have the GPS on when USB is disconnected).
Just add
USB.setConsole(1)
toonInit()
and you'll be sorted - it forces the console to stay on USB.Also, I would:
oninit
toonInit
(it's case sensitive)oninit()
andsave()
from your code, and just typesave()
on the left-hand side after upload.That'll make sure
onInit()
is called just once on startup (it's done automatically after thesave()
). If it gets called twice (once before save and once after) then you'll end up with 2 sets of GPS modules added and so two sets of identical readings added to the file.Hope that helps!