Main Menu

Secondary Menu

Sigfox GPS Tracker

Introduction: Sigfox GPS Tracker

You may have wondered how GPS trackers work. At the end of this tutorial, you will be able to have a fully functional GPS tracker that sends data to your server. The use cases are endless, from tracking your pets or your shipments to tracking your motorbike, your boat or your drone. Feel free to share what you are tracking, it might give others great ideas!

What will be covered by this tutorial?

We will be using the TD1205P device (it should work also with TD1204 but I haven't tested and it has a different shape) from Telecom Design using Sigfox network.

Note that at the time I wrote the tutorial, the TD1205P was not officially released. We had the chance to test it before its official release.

Thus, we will see how to get started with Telecom Design SDK, how to download the sources, configure your laptop. We will also see how GPS works and how to request a GPS fix, how Sigfox works, how to encode the GPS fix into a Sigfox message (12 bytes) and send it, how to use the Sigfox bidirectional functionality to configure your device, how to set a callback in Sigfox's backend to send the data to your server.

What is Sigfox?

Sigfox is a connectivity solution dedicated to the Internet of Things. The operated network is currently operating in +22 countries, on every continent. Focused on tiny messages (up to 12 bytes) & low energy consumption, it currently powers 7 million devices. Various Sigfox-compatible technical solutions are available, from different silicon vendors.

Subscriptions to the Sigfox service are free for developers ( development kits & evaluation boards). Otherwise, they range between 1€/month & 1€/year depending on the volume commitment.

This project uses a TD1205 device from Telecom Design.

Ready to get started? Let's go!

Any skills required?

In my point of view, if you follow this tutorial, you should be able to reproduce it. However, knowing some basics of C programming will be a real plus. We will see in details what the code does and I commented the code to understand every step. Do not hesitate to leave a comment for the parts you don't understand if I haven't been clear enough.

This tutorial is quite long but will cover every step.

Who am I?

My name is Louis Moreau, I'm an intern at Sigfox. My role is to create prototypes and PoC using Sigfox network. I want these projects to be fun and instructive. I want to show you that it is easy to develop the first steps of your ideas. I will try to make this tutorial as complete as I can. Do not hesitate to ask me for more details if needed.

Contribution

I would like to thank Telecom Design (manufacturer of the device) and especially Jérôme Guerin, his precious time helped me to resolve many issues.

In order to have a fully functional device, you will also need a battery. You can use a LiPo or a small battery (no more than 3.7V).

Step 2: Get Started With Telecom Design SDK

These next parts are surely the hardest parts. I had many troubles to get started with the TD SDK. Not to mention that it is only for Windows OS... However, as I encountered many of the issues related on the td-next community forum, I will try to be as clear and illustrative as possible.

Now you should have access to the private Github repository. When you have a look at the README.md documentation, here is what it is said.

The first parts are pretty simple, I did not get any trouble. However, when it came to the compiling part I found it way harder. I'll do a dedicated step for the compilation where I will try to add many screenshots.

Select the original firmware and click on acquireIn my case, this method did not work... I had some different errors such as "could not initialize COM port" or "SRAM error". Don't worry there are other ways :)

Another way:

Open the program under:C:\TD\TD_RF_Module_SDK-v6.0.0\energymicro\energyAware Commander\eACommander.exe

You have to solder the evaluation board as it is described (see the pictures for a visual -> don't judge me about my soldering skills please)

Right now you should have a fully functional TD1205P. Now we will access it using AT commands and send our first Sigfox message. Ready?

Step 4: Send Your First Sigfox Message

Before we try to compile anything, we will do one first test to check if everything works fine.

Note that if you already have uploaded a custom firmware it won't work, but you still can upload again the official firmware to make these tests (see the previous step). The names of these firmware are "like td120X_modem_SOFTXXXX.bin"

We will try to send a simple Sigfox message saying 01CAFE (in hex). We will try to do so using the AT commands:

Plug the FTDI cable to your laptop

Check on which COM port the FTDI cable is: Go to "Windows" and search "device manager"

Open the C:\TD\TD_RF_Module_SDK-v6.0.0\putty\putty.exe program

Click on serial radio button

Go to the serial tab

Set the parameters as they are in the screenshot (Baud rate: 9600, parity: none and flow control: none)

Click on "Open"

Now, plug the TD1205P to your EVB.

On the Putty terminal:

Hit AT&V, you should see the result with some information (as you may see on the screenshot).

Now hit AT$SF=01CAFE the result should be "OK".

Let's see what your message look like in Sigfox backend.

Step 5: View Your Message in Sigfox Backend

If you don't have an account yet, please contact subscribe@sigfox.com

It has not been automatized yet but hopefully, it should become easier in the near future...

Once you have access to your devices, go to "device" and select your device by clicking on its id.Then, you will see its information, on the left-hand menu, click on "message". Here you go you should see the message sent by the device.

Now I would suggest that you stop for a coffee, next parts are going to be tricky... But please come back!

Step 6: Import Project

In the "Import" dialogue, unfold the "Git" folder by clicking on the "+" sign left to it, select the "Projects from Git" item and click on the "Next >" button

In the "Import Projects from Git", select the "URI" icon ad click on the "Next >" button

Enter The Github repository URL "https://github.com/luisomoreau/sigfox_gps_tracker.git" in the "URI" field

Enter your Github username and password in the "User:" and "Password:" fields, respectively and click on the "Next >" button

Check the "Master" branch box and click on the "Next >" button

Enter "C:\TD\TD_RF_Module_SDK-v6.0.0\workspace" in the "Directory:" field and click on the "Next >" button

Check the "Import existing projects" radio button and click on the "Next >" button

Click on the "Finish" button.

You can also create a workspace called "Tutorial"and add the project to this workspace.

Step 7: Compile the Sources

Ok right now comes the hard part. I had many troubles while compiling. I will try to overcome most of the issues and how to solve it.

Add the environment variables

With the exception of the binary-only static libraries in the "libtddrivers" and "libtdrf" projects, all deliverables are presented in source form only, and must be compiled to obtain an executable firmware. To compile properly you must add the GCC path into your Eclipse environment variables by opening:

Window -> Preferences -> C/C++ -> Build -> Environment -> Add...

Please add the PATH variable with the following value:

"C:\TD\TD_RF_Module_SDK-v6.0.0\gnu\bin;"

and "C:\TD\TD_RF_Module_SDK-v6.0.0\gnu\arm-none-eabi\bin"

At first, I had imported only the first path "C:\TD\TD_RF_Module_SDK-v6.0.0\gnu\bin" as it was suggested in the Telecom-Design' s Github repository but I had some troubles when compiling. Thus I strongly advise to add both paths. (See screenshot for the error logs)

Edit 10th October 2016: It appears that eclipse stores some cached data, try to clean the projects first and you should be able to compile it without adding any environment variables...

Compiling for TD1204 and TD1205

I haven't tested these devices but you should be able to make it work if you follow the official procedure:

In order to avoid unnecessary rebuilds of the common libraries, it is best to set the right build configuration for all these libraries: unfold the "Common_Libraries" working set in the Project Explorer panel on the left side, then select all the projects by clicking on the first one in the list, pressing the "SHIFT"key, then clicking on the last one in the list

Click on the small downwards arrow right next to the "Hammer" icon in the top menu bar and select the right build configuration corresponding to your board: "TD1204 or TD1205""GCC Release (EFM32G210F128)" for a stripped down firmware

Open the file "sigfox_gps_tracker.c"

Click again on the small downwards arrow right next to the "Hammer" icon in the top menu bar and select the same build configuration as for the libraries above ("TD1205P")

Compilation of the "sigfox_gps_tracker"project and all the required dependencies will take place, which can be monitored in the "Console" tab of the bottom panel.

Compiling for TD1205P

The TD1205P was not officially released when I wrote the tutorial, you should be able to compile the project for the TD1205P with this project (configuration is included in this repository). However, if you wish to go back from scratch, few tricks will be needed.

Then if we take this project as an example, here are the steps required to compile it:

In order to avoid unnecessary rebuilds of the common libraries, it is best to set the right build configuration for all these libraries: unfold the "Common_Libraries" working set in the Project Explorer panel on the left side, then select all the projects by clicking on the first one in the list, pressing the "SHIFT"key, then clicking on the last one in the list.

Click on the small downwards arrow right next to the "Hammer" icon in the top menu bar and select the right build configuration corresponding to your board: "TD1205P""GCC Release EZR" for a stripped down firmware.

Unfold the "Tutorial" working set in the Project Explorer panel on the left side, then select the "sigfox_gps_tracker" project

Click right on the project and select "Properties".

Go to C/C++ build -> Build variable. Make sure that the TD1205P appear. If not you can create it by clicking on "Manage Configuration" -> "New" -> add "TD1205P Release" and copy the "TD1508" configuration. Then go to "Settings"->"Preprocessor" and replace the revision with "MODULE_REVISION=REVISION_TD1205P". Make sure you do it for both preprocessors tab (under assembler and compiler).

Click on OK

Open the file "sigfox_gps_tracker.c"

Click again on the small downwards arrow right next to the "Hammer" icon in the top menu bar and select the same build configuration as for the libraries above ("TD1205P")

Compilation of the "sigfox_gps_tracker"project and all the required dependencies will take place, which can be monitored in the "Console" tab of the bottom panel.

The same procedure can be used for all the example projects when required.

Other encountered issue

Note that this may occur only with the TD1205P version.

I had an error with the _cs3_interrupt_vector_em (see screenshots) and it took me a pretty long time to solve. I proposed a pull request on Github official repository to solve this. I don't know neither if it will be accepted nor when. Thus, to solve it you can follow the very simple procedure:

Step 8: Code Explanation

What is the code doing?

Basically, we wanted a GPS tracker that sends the GPS coordinates every hour. However, we were not certain about the battery consumption, thus we wanted to be able to configure the device to send the coordinates every 2, 3, 6, 24 hours if needed (after our tests).

We did not want either to let the GPS switch on for a too long time if no GPS fix was available. Thus we wanted to be able to configure the GPS timeout.

We wanted to know the battery level, the speed and the precision hdop and the number of satellites received) .

We also wanted to be able to encrypt the Sigfox payload if needed.

Payload encoding

Here is how the payload is encoded:

Byte 0: Lat

Byte 1: Lat

Byte 2: Lat

Byte 3: Lat

Byte 4: Long

Byte 5: Long

Byte 6: Long

Byte 7: Long

Byte 8: Voltage between 0 and 3825 with a 15mV step

Byte 9: Hdop on the first 2 bits (0 if <1; 1 if < 2; 2 if <5; 3 if >5) Number of satellites received on the 2 next bits (0 if <3, 1 if <6; 2 if <8; 3 if >8)

Byte 10: Acquisition time between 0 and 75s with a 5s step on the 4 first bitsSpeed in km/h between 0 and 155km/h with a 5km/h step on the 4 last bits

Byte 11: Empty

Code

Now let's have a deeper look into the code in sigfox_gps_tracker.c, especially at the comments for a better understanding:

Step 9: Flash Project to the Device

You can debug the project using Putty (same method as in the reset the device step) and enable DEBUG variables in the project (Set the variable to 1 - ligne 78).

Software

If it does not work, please try to reset your device.

Unlike some dedicated embedded Interactive Development Environments (IDEs), Eclipse does not come with fixed Flash/Debug commands or menu buttons: they need to be added explicitly on a project by project basis.

Fortunately, these Flash/Debug "Launchers" can be imported or duplicated to other projects easily:

Open the "File" menu and select the "Import..." item.

In the "Import" dialogue, unfold the "Run/Debug" folder by clicking on the "+" sign left to it, select the "Launch Configurations" item and click on the "Next >" button

Enter "C:/TD/TD_RF_Module_SDK-v6.0.0/Github/TD_RF_Module_SDK/Eclipse Launchers" in the "Browse..." field, check the box in front of the "Eclipse Launchers" item and click on the "Finish" button

All the default Flash/Debug "Launchers" will be added to the top menu "Bug" and "Green Circle with With Right Arrow and Briefcase" icons

If required, you can edit these "Launchers" by choosing the "Debug Configurations..."or "External Tools Configurations..." entries in the menu obtained by the small downwards arrow right next to the corresponding "Bug" or "Green Circle with With Right Arrow and Briefcase" icon

In the dialogue windows that opens, you can edit a given configuration directly and click on the "Apply" and "Close" buttons, or you can duplicate it by right-clicking on it and selecting the "Duplicate" entry in the contextual menu that pops up

Then, to flash a firmware to the TD12xx/TD15xx board:

Select the desired project in the Project Explorer panel on the left side

Right-click on the project and select the "Build Configurations > Set Active >" and the desired build configuration as explained above

Optionally click on the "Hammer" icon in the top menu bar to build the project

Click on the small downwards arrow right next to the "Green Circle with With Right Arrow and Briefcase" icon and select "Flash Selected Project" in the contextual menu.

Hardware

Depending on how you want to supply power to the device, use the switch on the EVB (see screenshot of the documentation):

The upper position will supply power from the FTDI cable

The lower position will supply power from the EFM32 board

No jumper will use the power from the device (Battery, Lipo, etc...)

Be careful not to put the jumper when the device is powered by an external source otherwise, it may damage your device!!

Step 10: View the Geolocalisation

Now that our device can send data, let see how to see the geolocalisation on Sigfox Backend:

Go to "Device Type"

Click on your device type

You should arrive on the information tab. Click on "edit" upper right corner

Change the display type to "Geolocalisation" "Default (root)"

Save

Go to "Device"

Select your device

Scroll down on the information tab until you see "See the device track on map"

Click on it, you will see your device last positions on a map

You can also go to message and see the latitude and longitude

Step 11: Bravo

Let your imagination guide you.

Now you can connect and track your dog, your bike, your car or whatever you want.

You just need to solder a small battery (be careful not to overstep 3.7V) and let your device live its life!

Do not hesitate to share what you made. I'll be glad to answer your question. Feel free to contact me!

We haven't discussed the part where you send a callback to your own server. I wrote a small part on this on my first tutorial "Sigfox Talking Plant" (step 7). Go and have a look if you are interested ;)

Thank you for your attention. I know this tutorial is not the easiest I made. Bravo if you've reached the end!!!

Epilog Challenge 9

Paper Contest 2018

Science of Cooking

Tips

Questions

23 Comments

I have a problem with the reset of the device with the original firmware (Step 3).

In the "Easiest way", I configured all the fields as you did in the image, but when I click on acquire, directly appears the Synchronising message and nothing happens. The program didn't works.

So, I also tried the other way. I did all the steps as you did and when I click on the Flash EFM32 button, the program starts to load, but in 24%, the load stops and appears an "Unable to read from SRAM" message.

What should I do at this point? Should I solder the EVB as you did? Or it is another type of failure?

But 1024 is much better - it just thinner. It fits perfectly to laptop. Just 2 weeks ago I lost my laptop from my home, I was protected with Pray, but still no single tracks - professionals! It could be good idea to use accelerometer as well - if it still on the table, then it's enough to send one packet just per day max. Also DAC inputs as tamper of case or computer working condition and outputs for turn pc on and off. Battery may be really tiny or even capacitor - it lasts like "forever" by datasheet, and may charged from PC source as well.