TinyGPS and Spark Core

@redking, the web IDE is finicky about paths which is why I use CLI and DEV. I highly recommend trying CLI since you can put all the files in a single directory and compile the directory with "particle compile directory_name ". You can also flash via USB or OTA from CLI as well.

If you want to use a library in the web IDE, youā€™ll have to do so by using the library interface. Simply including them by text doesnā€™t appear to work.

Yeah I did that and its confirmed as included , must be doing something wrong here :confused:

@redking, donā€™t know what happened in your case, I tried with my test account and it is working fine.

  1. Search TinyGPS

  2. Use the Sample

  3. It is now open on your IDE

  4. Verify the application, it compiles and code is working fine.

I donā€™t know what happened in your case, can you try start from scratch?

1 Like

managed to resolve it by combining the .cpp with the headerfile to resolve the problems with my local setup.

Thanks for the help :smile:

I am using an arduino nano and a ublox neo6m GPS receiver with an oled display and have been running it for over a month inside with up to 11 satellites visible and never less than 5, brick walls and sheet iron roof.

Thanks for the post! I plan on trying this with a Photon and then migrating it to my Electron (when it arrives) and building a GPS location logging/publishing backpack for Coachella

1 Like

Hi everyone - sorry to revive an old thread - but are there any known issues with TinyGPS on a PHOTON (as opposed to a Spark or Electron)ā€¦ Iā€™ve been through this long thread and am still getting 0.0, 0.0 as lat and long. Using adafruit ultimate gps and a photon. The GPS is flashing (red) every 15 seconds: I gather that means it is getting a signal.

https://api.particle.io/v1/devices/events/?access_token= gives:

event: gpsloc
data: {"data":"0.0,0.0","ttl":"60","published_at":"2016-04-11T16:16:19.399Z","coreid":"<myCoreID>"}

Iā€™m using the TinyGPS library as is (except it polls every minute instead of 15 minutes) - have tried various variations but nothing seems to affect it. Any pointers much appreciated - have others found tinyGPS works fine on a Photon?

Hi,

I can only speak to TinyGPS++ on a Photon. Iā€™ve used it with the Adafruit ultimate GPS and it works fine as long as my code empties the UART buffer frequently enough. My code was initially naive about the amount of time it spent doing other things (screen update, temp sensor reads) and that caused it not to work. A little main loop tweaking and all was well.

Thanks Mike. Am I correct in thinking that if the 1s red blinking stops and goes to a flash (also red) every 15s then it should be spitting back Lat and Long data? Or could it be that it still hasnā€™t locked onto satellites properly? Iā€™m getting data back consistently but its all 0.0, 0.0ā€¦

In my experience once it goes into the slow fifteen second flash it always has a lock and is emitting good NMEA sentences. So that means itā€™s time to check wiring and code. Youā€™ve got the wiring correct for power obviously. I know itā€™s elementary but for completeness - GPS TX to Photon RX, GPS RX to Photon TX.

For the code, double check setup; baud rates, etc. Then there are good suggestions on this forum about echoing serial1 from the GPS out to serial on the screen for debugging.

Mike

Hey Mike

Thanks for this - I have RX>TX and TX>RX, I think thatā€™s correct. Surely if I am getting this data then the communication between Photon and GPS is working, no? (this is from https://api.particle.io/v1/devices/events/?access_token=ā€¦)

> event: gpsloc
> data: {"data":"0.0,0.0","ttl":"60","published_at":"2016-04-11T16:16:19.399Z","coreid":"<myCoreID>"}

So Iā€™m baffled. Iā€™m using standard code (the TinyGPS example code), the GPS ā€˜saysā€™ itā€™s working, but all Iā€™m getting is zero lat/longā€¦

Hi,

Wellā€¦ all I can tell from that is a properly formatted event got published. For the GPS stuff an excellent first debugging step is always to simply print to the serial terminal what came in from Serial1. It may be comms is working ok but thatā€™ll remove any doubt.

Mike

1 Like

@squidie, you can insert Serial.println after char c = Serial1.read();. You can see what characters are receiving. It should be a valid NMEA string.

1 Like

Hi - if you are still having issues, I have a photon connected to an adafruit Ultimate (using tinygps from memory) that is successfully publishing.

If you want I am happy to flick you the code.

Stan

Hey all - just to update - SUDDENLY it has sprung into life and giving me decent GPS data. I put in @krvarma 's extra line; havenā€™t even managed to track down where I can read the line it prints yet but I checked the event post and Iā€™m getting real lat and long data. Awesome. I hope it still works tomorrow - Iā€™ll let you know. But thanks for the help so far everyone.

1 Like

Hi @krvarma, just wanted to say thanks for your code on Git Hub. I struggled a bit with the Asset Tracker library so had a try of your TinyGPS code for Core. I have an electron. But it worked fine. I managed to get the google maps tracker working too. Very pleased with where I got too (but thanks to you and Mikal Hart et al for all the hard work). :clap: :+1:

2 Likes

Iā€™ve been working with the HTML that @Moors7 so graciously provided, however, Iā€™m not 100% certain that my GPS location data is in the correct format. When I run the HTML below, I get the following output:

Any idea as to what Iā€™m doing wrong?

Dashboard Publish:

Console Error:

<!DOCTYPE html>
<html>
<head>
    <title>Spark Core Location</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
        html, body
        {
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
        h1
        {
            text-align: center;
            margin-left: auto;
            margin-right: auto;
        }
        #map-canvas
        {
            width: 80%;
            height: 80%;
            margin-left: auto;
            margin-right: auto;
        }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
        var map;
		var marker;
		var loc;
        function initialize() {
            var mapOptions = {
                zoom: 3,
                maxZoom: 100,
                draggable: true,
                disableDefaultUI: false,
                center: new google.maps.LatLng(0.0, 0.0)
            };
            map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
			
//the line below was commented out which caused the error in this post: http://community.spark.io/t/tinygps-and-spark-core/4942/80?u=moors7  I now uncommented this, so it should work again
			marker = new google.maps.Marker({position: new google.maps.LatLng(0.0,0.0), map: map});
			
			//marker.setMap(map);
        }
        google.maps.event.addDomListener(window, 'load', initialize);
		
		function start() {
			var deviceID = "DEVID";
			var accessToken = "ACCTOKEN";
			var eventSource = new EventSource("https://api.spark.io/v1/devices/" + deviceID + "/events/?access_token=" + accessToken);
			eventSource.addEventListener('open', function(e) {
				console.log("Opened! Listening for updates!"); },false);
			eventSource.addEventListener('error', function(e) {
				console.log("Errored! Please check your credentials."); },false);
			eventSource.addEventListener('Location', function(e) {
				var parsedData = JSON.parse(e.data);
				var data = parsedData.data.split(",");
				
				console.log( parsedData.data);
				console.log("Latitude: " + data[0]);
				console.log("Longitude: " + data[1]);
				
				loc = new google.maps.LatLng(data[0], data[1]);
				
				marker.setMap(null);
				
				marker = new google.maps.Marker({position: loc, map: map});
				
				marker.setMap(null);
				map.panTo(loc);
				marker.setMap(map);
				
			}, false);
		}
		window.onload=start;
    </script>
</head>
<body>
    <h1>Spark Location</h1>
    <div id="map-canvas">
    </div>
</body>
</html>

@jdugat, which firmware you are using, it seems the Event Data is not in correct format. IT should be <<lat>>, <<long>> format. But in this case the event data contains some other parameter (+28 from the example).

I was told that if you wanted google maps to recognize the lat/long coordinates, you would need them in the following format:

+28 38.5417ā€™,-81 56.3664ā€™ <- if you cut an paste that in and google is your default search engine, you should be taken to the map for Disney World near Orlando, FL.

Based on that assumption, I have DEG, MM.SSSS format for my lat/long. Perhaps thatā€™s the problem.