15 November, 2019

Send the right data to your platform

Compose a custom message from the incoming data and feed it into the consuming application.

GPS trackers and IoT sensors collect dozens of parameters, not all of which bring value to the given project. We want to suggest a scheme that will let you filter out the unnecessary parts of the dataflow and compose a message with the right set of parameters, right parameter names, and the right format for the consuming application, thus eliminating excessive traffic and data manipulation efforts on your side.

Let us tell you how to utilize flespi MQTT functionality to handle data transformations and generate the desired output.

customize message and send to your platform scheme

1. Channel for connected device

You have to create an appropriate channel based on the device protocol and point your device to its IP:port.

2. Your custom script

This is the most important and flexible part of the scenario — here you perform any manipulations on the data depending on the task at hand. 

We have a few examples for you to get a better understanding of what and how should be organized (you can use them as templates and tweak to your needs):

  • This script excludes private data from the messages (as per GDPR requirements)

  • This one substitues identification string which allows to merge messages from two different devices into one unit (e.g. a truck and a trailer).

  • And this one injects additional parameters into the message.

The script also serves as an MQTT client that subscribes to original messages from the flespi channel (see 1 above) and publishes the processed messages into the MQTT channel (see 3 below).

3. MQTT channel

MQTT channel subscribes to the specified topic(s) on the specified MQTT broker and expects messages to come as valid JSON objects with a compulsory ident value (make sure to account for that when operating the data in the script). The channel will readily accept your customized messages and make them available to your application.

Note that you can also specify the parameter names mapping scheme to align the naming convention to the one used inside your project.

4. Access methods

Now that you have properly structured messages, it’s time to feed them to your application for any calculations, analysis or another value-add that it is supposed to provide. 

One way is to use flespi REST or MQTT API to get the messages in your solution. This way you can request the specific subsets of messages or messages for a specific timeframe.

Alternatively, flespi can push the messages into your application via a specialized stream as they arrive in the MQTT channel.

***

In the end, what you get is a simple and straightforward workflow that can be altered to easily incorporate the changing requirements of the receiving application. In addition, you are freed from loads of integration works with the hardware and just code the necessary data transformations into a ready-made template.

Think where your projects consume useless data with no particular reason and help them inhale some fresh air.