alvarowolfx / gcloud-lora-ttn

Integration between Google Cloud and The Things Network
25 stars 6 forks source link

The Things Network Integration with Google Cloud

Process uplink messages from TTN on Google Cloud, storing Realtime data on Firebase, historical data on BigQuery and visualize the data through a web app.

Web App URL : Access Here

Run on Google Cloud

️ ⚠️️️️THIS IS A WORK IN PROGRESS ⚠️

Architecture

LoRa End Node: Lora Node

Data arriving on The Things Network: The Things Network Dash

Realtime Data on Firebase: Data Firebase

Query Data on Bigquery: Data on Bigquery

Monitor data on a WebApp : Web App

BOM - Bill of Materials

Gateway

LoRa End Node

Upload firmware with PlatfomIO

I recommend installing the Visual Studio Code (VSCode) IDE and the PlatformIO plugin to get started using it. Just follow the step on the link below:

https://platformio.org/platformio-ide

To deploy to the board, just open the firmware folder and you can use the “Build” and “Upload” buttons on PlatformIO Toolbar. All libraries and dependencies will be downloaded.

TODO: Add wiring

Google Cloud Setup

Bigquery Table

Deploy Backend

We have two options here, using Cloud Run and Google Cloud Functions.

Deploy Using Cloud Run

Just follow the steps and fill the GCP_PROJECT variable with your Google Cloud Platform project ID.

Run on Google Cloud

After deploying the server on Cloud Run, you can get it's url on GCP Console (link) and select the service ttn-gcp-lora that we just deployed. Them copy the URL will look like https://{project-id}-{some-random-hash-string}.a.run.app. The endpoint that handles TTN requests it /uplink, we are going to use this to setup TTN integration.

Deploy Cloud Function

This step will deploy a HTTP Cloud Function made with Golang. I made a script deploy.sh that is on the functions folder, that you can use to do that.

After deploying the cloud function, you can get it's url that will look like https://{project-region}-{project-id}.cloudfunctions.net/HandleTTNUplink that handles TTN data and another one that will look like https://{project-region}-{project-id}.cloudfunctions.net/HandleDeviceHistoryQuery that returns device history to be used by the UI.

The Things Network Setup

TTN Integration 1 TTN Integration 2 TTN Integration 3

Deploy Web UI on Firebase

References