Getting data from TTN to Android App development

Hello experts,
I am building an app in android studio that gets data from my application in the The Things Network. The Android app should be able to display the data. It is an IoT project. I have data in TTN, android app is being built, now, my challenge is to sync that data in the app i am building. Do i need a code to do that in Android studio, or i use a solution by a third party and connect it to Android Studio?
Any suggestions on how i get the data from TTN and display in app say in real time?? Any help would be appreciated. Thank you guys.

If you only want real-time you can use MQTT subscription. If you need to get all data you’ll need to look at another option like the data integration. May-be combine them (make sure to deduplicate somehow).

1 Like

Fetching as JSON from Data Storage won’t be totally real time as you’ll have to poll, but would make for a simple implementation.

1 Like

Hello Jac,
Thanks for the reply, what if i do not really care about real time data. Your reply would be appreciated.

hello Nick,
Any notes or link as to how i can go about it?? Thanks your reply would be much appreciated.

Note that the Data Storage integration only stores 7 days of data, and sends does not send CORS headers (implying that you cannot access it from a regular browser, but fetching from an app should probably work).

Also:

1 Like

Thanks Arjan. Do you think or suggest AWS IoT integration could help me get the data(TTN) that is pushed to AWS, then from AWS i sync the data to my andriod application? What are you thoughts on this also. Thanks man.

https://www.thethingsnetwork.org/docs/applications/storage/

Under no circumstances should anyone pull the whole 7 days in one go unless they are seeding their database - they should get the last uplink timestamp, do some simple maths and request everything since then. And they should proxy it in to a database of their own.

I personally use the HTTP integration in to a mySQL database that I have my own API calls setup for - so it can all run on a small virtual server that is running the bare minimum and no MQTT Client to mange.

But I also have a multiuser desktop app where the server gets the updates from Storage (as it was simpler at the time to code the JSON requests to Storage Server as we hadn’t got as far as a rational API on our HTTP integration), and that only gets the uplinks since the last one.

Requesting only the uplinks since your last poll is desperately simple to add, I’d be quite happy for TTN to rate limit a 7d request to once every 48 hours to slow down those that can’t be bothered.

So, for @Jonathan_M, I’d highly recommend using the HTTP Integration to your own internet server that stores the data as you need it for your application and create a simple API for your app to make requests. I’d also store the data on device and only request the new uplinks to minimise network / data use on the app.

1 Like

Hi Nick, I have a similar question regarding connecting TTN with my own application. If I am only interested in obtaining the last data of the uplink and perform an action on the end devices of my LoRaWAN network. What is the procedure that I should carry out and that should I integrate in the development of my application?
Excuse my meddling

There isn’t a way of getting the last uplink, only a time range - but if you know that your device uplinks every hour, you could get the last two hours worth and discard all but the last one. If that fails, get the last 6 hours worth, repeat until you get some results back.

Preferably use either MQTT or HTTP integration to your own database on an internet hosted server and you can then just get the last uplink on file - both integrations are as close to real time as they can get.

1 Like