Using GPS kills all data logging

Inquiry and support for Freematics products
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Using GPS kills all data logging

Post by lukeau »

I've got the OBD-II Adaptor (with BLE & GPS) successfully streaming OBD-II data to the iOS app & logging to SD card with the latest commit:
https://github.com/stanleyhuangyc/Freematics/commit/eb9f2bddcb43e90a950cfdb646e027c8741fb367

I can't get any GPS to log or stream any data when I turn on GPS logging in config.h. Definitions I'm using are:

Code: Select all

// enable(1)/disable(0) GPS module
#define USE_GPS 1
#define LOG_GPS_NMEA_DATA 0
#define LOG_GPS_PARSED_DATA 1


With these options turned on, the adaptor creates the CSV file in the FRMATICS directory, but the CSV file is empty, not even OBD-II data is being logged.

I've since tried troubleshooting by commenting out all of the GPS related code in datalogger.ino, then reintroducing piece by piece to debug. It seems that logging stops as soon as an the instance of TinyGPS is created:

Code: Select all

#if USE_GPS && LOG_GPS_PARSED_DATA
    TinyGPS gps;
#endif


Also, I noticed that the code includes the TinyGPS library, but the github repo library folder has TinyGPSPlus. Which one is it supposed to be?

Has anyone been able to get GPS logging working? Any help is appreciated, I just want to get the standard firmware working as advertised for now...

thanks

Luke
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Using GPS kills all data logging

Post by stanley »

Can you try this configuration first:

Code: Select all

#define LOG_GPS_NMEA_DATA 1
#define LOG_GPS_PARSED_DATA 0
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Re: Using GPS kills all data logging

Post by lukeau »

NMEA sentences are logging. Tried to attached CSV file, but filetype not permitted.

Line 911:

Code: Select all

21,$GPRMC,054822.300,A,3747.7397,S,14502.1661,E,0.13,0.00,260914,,,A*7C

Line 1094:

Code: Select all

22,$GPGGA,054827.800,3747.7398,S,14502.1662,E,1,8,1.14,28.0,M,-4.0,M,,*69

First valid transit data (line 911), about 43 sec after start (good).
First valid fix data (line 1094), about 48 sec after start (good).
8 satellites. HDOP 1.14 (good).
UTC date & time are ok.
GPS position is in error (by about 34 km). Showing a position of -37.477397, 145.021661. Actual position at this point is -37.795663, 145.036148.
Every position report is offset by this much, making me think it is an error with the GPS chip (almanacs, etc are wrong). I plotted the points, they take the shape of the first few minutes of my route perfectly, but in a random location 34km away! Problem is replicated on additional trips.

Q. Is there a way to force a cold start on the GPS to try and reset it?

Logging cuts out after a few minutes. In this test, I drove for about 20 minutes, and the log file is only about 6 minutes long (357 sec adding up the timestamps). Problem is replicated with additional trips.
Q. What could be making the logging stop after only a few minutes?
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Re: Using GPS kills all data logging

Post by lukeau »

With

Code: Select all

#define LOG_GPS_NMEA_DATA 1
#define LOG_GPS_PARSED_DATA 0

turned on, all data logging only works for a very short period of time - anywhere from 1 to 25 sec of GPS reporting in the log file (I'm looking at the UTC fields in the log data).
I also tried turning streaming off:

Code: Select all

#define ENABLE_DATA_OUT 0

But this did not help logging.

Is the device running out of memory with GPS logging turned on perhaps?

We've had the device for weeks now, and still can't get basic OBDII/GPS logging working...
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Using GPS kills all data logging

Post by stanley »

Did you modify the datalogger sketch or just used ours?
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Re: Using GPS kills all data logging

Post by lukeau »

Stanley,

Great work on all of this so far.

I'm using the latest sketch available at https://github.com/stanleyhuangyc/Freematics/tree/master/firmware_v2/datalogger
I have set LOG_GPS_NMEA_DATA 1 and LOG_GPS_PARSED_DATA 0
I think the NMEA GPS logging was stopping after a short period because of the GPS reporting rate being too fast, so I uncommented lines 267-269 in datalogger.ino and slowed the GPS update rate to 1 Hz as follows:

Code: Select all

            write("ATSGC ");
            write(PMTK_SET_NMEA_UPDATE_1HZ);
            receive();

Now the raw NMEA data logs correctly, although there sometimes numerous lines in the CSV file with 'NO DATA'.

The parsed data still does not work. Turning on parsed data results in empty CSV files being created with no contents. Is it something to do with the creation of the instance of the TinyGPS object?
sixchristoph
Posts: 9
Joined: Tue Oct 07, 2014 7:53 pm

Re: Using GPS kills all data logging

Post by sixchristoph »

Hi Luke, Hi Stanley,

I agree to Luke, great work so far! But I guess I am suffering from the same GPS problem.

Turning off the GPS I can logg data as configured (I chose to log only PID_RPM, PID_SPEED, PID_ENGINE_LOAD, PID_MAF_FLOW, PID_COOLANT_TEMP) every 1000ms. Just tried for a couple of minutes and it seems to work (even though it generates quite a lot of additional 0kB files as well for one trip?).

As soon as i try to enable GPS it kills all the data logging. The only thing I get on my SD is a single entry as follows:
12123,$GPGGA,140342.320,,,,,0,0,,,M,,M,,*49

5900

Bugfix as you described didn't work for me. Neither #define LOG_GPS_NMEA_DATA 1, #define LOG_GPS_PARSED_DATA 0 nor setting the PMTK_SET_NMEA_UPDATE_1HZ.

When GPS is turned off I see the blue led flashing each second when a dataset is stored on the SD card, if I enable GPS there is no blue led flashing at all.

I put all the files I use in appendix (configured to just logg OBD data). I also used the original datalogger_v2 sketch and libraries but that did not work either, also not when using your suggestions as discussed here.

I am not an expert at all, so help would be appreciated very very much!
Would need to have 15 to 20 of them in a fleet rather soon :?
Thanks, Christoph
Attachments
datalogger.zip
(23.72 KiB) Downloaded 946 times
sixchristoph
Posts: 9
Joined: Tue Oct 07, 2014 7:53 pm

Re: Using GPS kills all data logging

Post by sixchristoph »

Hi, I can probably report some progress, but one issue remains.

Not using GPS, the adapter logs OBD data as configured, I turn on the ignition and it starts immediately, turning off stops, ignition on starts again and so on…. I have just checked for a couple of minutes but it seemed to work.

Enabling the GPS I now managed to log one single trip (OBD + GPS) also. I therefore used the original datalogger_v2 sketch, and uncommented lines 267-269 in datalogger.ino and slowed the GPS update rate to 1 Hz.
The config was like this:

#define ENABLE_DATA_LOG 1
#define ENABLE_DATA_OUT 0
#define USE_SOFTSERIAL 1
#define STREAM_FORMAT FORMAT_BIN
#define STREAM_BAUDRATE 9600
#define VERBOSE 0
#define SD_CS_PIN 10
#define LOOP_INTERVAL 500 /* ms */
#define USE_ACCEL 0
#define USE_GPS 1
#define LOG_GPS_NMEA_DATA 1
#define LOG_GPS_PARSED_DATA 0

In my previous post, when nothing was logged some parameters where different:
#define ENABLE_DATA_OUT 1
#define USE_SOFTSERIAL 1
#define STREAM_FORMAT FORMAT_CSV
#define LOOP_INTERVAL 1000 /* ms */

I don’t know if the devise is running out of memory or anything else happens but now it works.

The remaining issue is, that the adapter now only logs one single trip. I start the engine and plug it into the obd port -> it always starts logging immediately. It then stops when the ignition is turned off.
If I again turn on the ignition it does not start logging any more.

It also did not always start logging when I plugged it into the obd port during ignition off and waited for a longer period of time. Probably this was the problem before as well? Something seems to freeze the device?
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Re: Using GPS kills all data logging

Post by lukeau »

Hi Christoph

I can log unformatted NMEA streams ok, but turning on Parsed GPS still results in zero byte CSV files.
I have tried all sorts of settings - from the defaults to GPS update rates, but have not been able to isolate what causes the zero byte files.
I also get zero byte files occasionally when logging unformatted NMEA data.

In summary: I have not been able to get the GPS logging working as advertised despite a month of trying different things out.
Perhaps Stanley could provide some help or advice here - the datalogger sketch produces inconsistent results with raw NMEA stream, and no results with formatted GPS data.

thanks

Luke
lukeau
Posts: 13
Joined: Fri Sep 26, 2014 12:24 pm

Re: Using GPS kills all data logging

Post by lukeau »

Hi Stanley

Are you able to help with the parsed GPS data bug? Our freematics development has stalled...

thanks

Luke
Post Reply