TD1204 – How to use GPS device for geolocalization with Sigfox

The TD1204 is the GPS & Accelerometer version of the sigfox Telecom Design chip. After a previous post about the use of the accelerometers (here) I’m describing how to use the GPS module.

The embedded GPS is based on a UBX G7020 chip. This chip will give you the date, time, longitude, latitude, altitude, speed and direction of the device when activated.

Read more for programming details

Kickstart

To start using the GPS module, you will simply use this skeleton code

#include "config.h"
#include <efm32.h>
#include <em_cmu.h>
#include <em_adc.h>
#include <em_rmu.h>
#include <td_core.h>
#include <td_geoloc.h>
#include <nmea_parser.h>

#include <stdint.h>
#include <stdbool.h>

#include <td_config.h>

/* The GPSFix function is a callback function periodically called
 * by the GPS_Process
 */
static void GPSFix(TD_GEOLOC_Fix_t *fix, bool timeout)
{
    // Fix type is giving what level of information did we get
    // from the GPS system. Quality is indicating the precision of the 
    // given information. > 1000 is bad, < 1000 is acceptable, < 500 is good
    // <200 is excellent. 
    if (fix->type >= TD_GEOLOC_2D_FIX && fix->quality.hdop < 500 ) {
	lastLatitude = fix->position.latitude;
	lastLongitude = fix->position.longitude;
	TD_GEOLOC_StopFix(TD_GEOLOC_HW_BCKP);
    }
    if ( timeout ) {
	TD_GEOLOC_StopFix(TD_GEOLOC_HW_BCKP);
    }
}

void TD_USER_Setup(void)
{
   // Set the device as a Sensor transmitter
   // We are not using TD_SENSOR stuff but this call is needed
   // otherwize the GPS will not work
   TD_SENSOR_Init(SENSOR_TRANSMITTER, 0, 0);
   
   // Launch a GPS capture request with a timeout of 120s
   // The callback function is GPSFix.
   TD_GEOLOC_TryToFix(TD_GEOLOC_NAVIGATION, 120, GPSFix); 
}

void TD_USER_Loop(void)
{
   TD_GEOLOC_Process();
}

So the system has to be initialized then the TD_GEOLOC_TryToFix starts the GPS capture process. Once start, the callback function will be called in a regular basis. The GPS information will be updated asynchronously.

The fix->type variable will indicate the level of the captured information from the GPS system.

So callback after callback the information will be more and more precise. You will decide in the callback function when it is precise enough for you and decide to stop tracking or not.

After a given time, the  timeout flag will be set. There is no other action taken by the system when timeout is set. It means you have to manage it yourself and decide, as in the example, if you want to stop track after timeout.

Power mode

The GPS module have different PowerMode. To start tracking a position, you need to use TD_GEOLOC_NAVIGATION or TD_GEOLOC_POWERSAVE. Both are running GPS tracking.

  • TD_GEOLOC_NAVIGATION will generate a load of 29-32mA on the battery during all the tracking activity. The duration of a first Track will be about 60 seconds dépendending on reception conditions. The next one will be about 15 seconds.
  • TD_GEOLOC_POWERSAVE_MODE : this mode is like the previous one, the current consumption when fixing is between 27 and 32 mA but once fixed, the power consumption goes down to 10-14 mA. This option looks good for recording a path but seem to not provide a great saving for a single fixing.

When you have captured a location, you can stop or sleep the device until the next one. In this case, these mode will be used

  • TD_GEOLOC_HW_BACKUP will sleep the device but it will keep the RTC and the RAM up. So the next synchronization will be done faster. The measured total consumption is around 15uA in this mode.
  • TD_GEOLOC_SW_BACKUP should be equivalent but more efficient. But it seems to not yet implemented on the TD1204.
  • TD_GEOLOC_OFF is stopping the GPS … Next start will be longer, at the end it will be efficient only if you have a long time between 2 measure. It not sure you are saving a lot of uA by using this mode.

To be more clear with GEOLOC_OFF : if you consider that consumption is 30mA for 60s to get a cold start fix you need about 0,5mAh.This is what you need each time if you switch OFF between capture. So per Hour with a capture every 15 minutes : 2mAh

To compare, if you go with HW_BACKUP, you will have an extra consumption of 5-7uA (?) and a fix time of only 15s after the first one so you will need 0,1mAh each. So for an hour : 0,5mAh + 3×0,1mAh   = 0,8mAh. The gain will be higher the next hour …

Callback function

The callback function is regularly called by TD_GEOLOC_Process(), it is about twice a second. Each time it is called you get more and more data. Localization becomes more accurate and you get a 2D, then 3D localization.

Basically you have to wait the expected status to get your data. fix->type help you to know what is the current status of the data. A first step is to get the time, a second step is to gate the date, then you get the 2D localization and after you are getting the 3D localization.

As the callback is just a flag, you have to decide what to do in case of timeout, so free to you to stop tracking or not.

If you stop tracking, the best is to switch to TD_GOLOC_HW_BACKUP to be ready for a next fix.

Precision of the localization

The accuracy of the localization is with fix->quality.hdop This is a good variable to get the quality of the localization. A value of 1000 is really poor, 500 is good, 200 is excellent.

According to some Internet search, an estimator of the precision for civil GPS use is 7m * Hdop / 100. So in this example with a hdop of 500 the result would be a precision of 35m.

 

This entry was posted in IoT, Sigfox and tagged , , , , . Bookmark the permalink.

12 Responses to TD1204 – How to use GPS device for geolocalization with Sigfox

  1. aptids says:

    Hi Paul,

    great post! Just what I needed. Thank you!
    do you know how to convert the 12b payload to gps coordinates.
    example : 35010100a54d018a914fff0d

    • Paul says:

      Thank for your feedback. I never used the standard 12b encoding format, building my own, so I will not be a great help. By-the-way, you can take a look to the SDK code & examples, there is the source to transform the lat/long values into the 12b encoding, so you just have to revert.

  2. Yannis says:

    Hi,

    your post is really useful to me, but can i ask you where did you get the TelecomDesign librairies that you use in your project. I’m using a TD1204 in a project to send the GPS data in the SigFox network and i couldn’t find the librairies and code examples.

    • Paul says:

      Hello, to access the SDK you have to register on the telecom design github. This is described in the Telecom Design website with the exact procedure (sorry i did not remind exactly what is the process) You may have to register on TD website to get access to the documentation to get access to the SDK …

  3. Yannis says:

    Thank you for your help but I went on their github and I couldn’t find any librairy or code examples. I only found some pdf’s like the datasheet .. I registered myself on the github and I had nothing more. I contacted telecom design last weekand I’m waiting for their answer.

    • Paul says:

      You need to register indicating your github account to be validated by TD and able to access the SDK files

      • fabien says:

        I dear disk91,

        When you test TD modules do you use ftdi câble or directly GPIO serial port ?

        Because when I test my TD1204 with ftdi cable it hang very frequently (even when I use GPS) and I dont know if it’s the module that hang or the communication with the 1204.

        Only way to retrieve communication is to unplug/plug ftdi cable, unfortunaly power is cut off with this process 🙁

        Best regards.

      • Paul says:

        I use both and I did not have a such issue. Be careful, the FTDI cable generally provides 5V power supply and you have to insert a voltage regulator to get 3.3V. I do not know how you connect your circuit but it can be an explaination. By-the-way, my TD1204 connected to a FTDI cable work well and are stable as standalone.

  4. prabju says:

    hi paul

    i would like to know in TD1204 says it has inbuilt 3Axis Aceelerometer but i did not found any information in the document , am designing the PCB similar kind of TD1204 and i dont know which pin is connected exactly and i did not found what type of microcontroller are they using?

    • Paul says:

      Its is a kind of secret … lol .. TD1204 is not opensource, so you won’t find any schematics… By-the-way, the accelerometer reference is in another of my post and the connection with the EFM32 seems to be based on I2C.

  5. Ticapix says:

    Hi,

    Do you have a place where to buy the TD1204 module w/ or w/o breadboard, in EU ?

    Best regards,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.