Multiple Data Feeds
How to record data from third-party feeds on your LoRaWAN, MQTT or API devices by speaking directly to the Datacake API.
Do you use Datacake for your LoRaWAN devices and feed the data via an LNS?
But did you know that you can also feed the data in parallel via other interfaces into the same device, even if they do not originate from the LNS?
Yes, you can! And this is not only possible with LoRaWAN but also with other types of devices.
The reason for this is that every device on Datacake is first an API device and therefore can also be fed with data via our rest-API but also MQTT interface, even if in parallel a LoRaWAN adapter automatically feeds the data via the payload decoder.
The following interfaces are available:
- Traditional REST API
- GraphQL API
- MQTT API
With the above interfaces, you talk directly to the database. Data that is inserted through these interfaces, therefore, does not go through the payload decoders either.
By the way, your LoRaWAN Payload Decoder on Datacake does nothing else. At the end of the run, the payload decoder also uses the REST API to write the data to the database then finally.
If you need payload decoders for API or MQTT as well, then you should create a generic API device.
The simplest variant for the parallel back feed of data into the respective Datacake device is via MQTT. You can find helpful information about this in the configuration view of your Datacake device.
Navigate to the configuration of your device and look for the MQTT section. There you will find a button that shows a modal with MQTT information when clicked.
On the modal you will recognize the following text.
The device will publish its measurements on the broker
mqtt.datacake.counder the topic
dtck/mclimate-vicki-19/983d51f5-6d38-4dcc-afc7-59e6aff062f4/+.To record measurements, publish to
Depending on which device you open on your page, the information will look different. They contain your device's product ID and device ID, but the structure is the same.
You can now use these topics to:
- Start subscriptions to incoming readings.
- Write measured values via MQTT into a database field of the device.
We will now deal with the latter.
First, you must connect to the internal Datacake MQTT broker using an MQTT client (standalone, Node-RED or Cake Red). For this, you need an API key, which also has rights for the respective device, not only read but also write rights.
A detailed guide can be found in the following article.
If the connection to the broker is established, you can now use MQTT to write measured values to your respective device. To do this, simply publish a message to the topic specified in the modal.
As you can see, the last element in the Publish-Topic is enclosed in brackets. This is a placeholder for the field. So please enter here the identifier of the field (as you find it in the database).
Then as payload, send as plain text the value which you want to write here to the database. For temperature, for example:
Or as a boolean, e.g.:
1(Booleans must be translated to 0 = False or 1 = True)
In parallel to using the MQTT Api, our Rest API can also be used. The principle is identical here. You write the data via API into the respective database field via HTTP post.
Have a look at the following documentation.
Another guide shows you how to use the REST API to feed data.
Writing measured values via MQTT or REST API also triggers downstream processes.
Rules are evaluated in exactly the same way as the normal device feed (via LoRaWAN, MQTT or API Payload Decoder).
For outgoing webhooks, it is a little bit different. These offer the option to trigger at various events, including:
- Payload Decoder Output
- Database Measurement Change
If data is written to the database via the MQTT or REST API interface, then outgoing webhooks are only triggered if Database Measurement Change is enabled.
Please pay attention to infinite loops when triggering a write operation with outgoing webhooks, for example. We will disable the device if this happens.
Last modified 3mo ago