How to get my device's data to a Raspberry Pi?

I have a gps tracker which send position through TTN.
I Would like to have this position to arrive in real time into a rapsberry and be stored in a text file.
I would like to prerferably use python or php in my raspberry.
What is your susggestion to have the position to arrive into the raspberry. Should I use HTTP integration, mqtt, …

thank you

For one’s own server (like a Raspberry Pi), those are indeed the two options. As you don’t seem to understand the difference:

  • An HTTP web server along with the HTTP Integration needs you to carefully open up your Pi to the internet (some settings in your modem/router) to allow TTN to connect to it, and needs you to set up the integration in TTN Console.

  • An MQTT client for the MQTT Data API connects to TTN itself, so does not need the Pi to be accessible over the internet. Also, many Pi’s come with Node-RED installed, which has built-in support for MQTT. This does not need any configuration in TTN Console (though you could add an extra application Access Key for this specific client).

Both options need to be running at all times.

I’d use MQTT.

If you’ve got Node-RED installed then I’d dive into that, as it makes it easy to run it in the background at all times, does not need much programming skills, and has good debug “nodes” to see what’s going on. There’s a lot to be found on the internet about that, including writing to a database rather than just a file. (But use the built-in Node-RED MQTT Input; do not use the archived TTN Node-RED library.)

If you don’t have Node-RED installed, then the Pi will still have Python available, so a Python MQTT client could be made to write to a file. (But use the bare Paho client; do not use the discontinued TTN Python SDK.) Or probably easier if you don’t have much programming skills: the command line mosquitto_sub client could simply be run in the background and pipe its output to a file.

1 Like

Thank you.
I finaly opted for mqtt python and i works just fine.

I’m leaping in here because I have the same issue. Do you need a paid-for TTN account in order to use MQTT or can you do it from a free account? I ask because I don’t seem to have any MQTT options in the list of available integrations in my free account. Thanks.

MQTT isn’t really an “integration” to which data would need to be pushed, but more of a default to which you could subscribe on desire.

It’s been a while, but my understanding is that if you subscribe to the correct topics on the correct broker with the correct credentials, you’ll start getting a live feed of your data.

Note the “live” - with limited exception what you miss by not being subscribed is for the most part, gone.