Self-hosted backend for LoRaWAN-based location tracking, supporting multiple location providers such as GNSS, Gateway-Triangulation, WiFi-Triangulation, and BLE-Triangulation.
Go to file
2025-01-25 18:50:25 +01:00
server use Promise.all 2025-01-25 18:50:25 +01:00
TTN add payloadformatter 2025-01-18 18:07:55 +01:00
LICENSE Initial commit 2024-12-29 21:03:50 +01:00
README.md improve readme 2025-01-18 18:54:15 +01:00

LocationHub

Self-hosted backend for LoRaWAN-based location tracking, supporting multiple location providers such as GNSS, Gateway-Triangulation, WiFi-Triangulation, and BLE-Triangulation.
We recommend using The Things Network (TTN) as middleware for relaying LoRaWAN payloads.


Table of Contents

  1. Setup
  2. TTN Integration
  3. Add a Location Tracker
  4. Testing

Setup

Prerequisites

Ensure the following dependencies are installed:

  • Node.js >= 22.11.0
  • MariaDB >= 11.6.2
  • A web server, such as nginx

Database

Customize the database name and credentials to your preference.
Follow these steps to set up the database:

  • Create new database: CREATE DATABASE dev_locationhub;
  • Create new user for database: GRANT ALL PRIVILEGES ON dev_locationhub.* TO 'dbuser'@'localhost' IDENTIFIED BY '1234';
  • Import tables: /usr/bin/mariadb -u dbuser -p1234 dev_locationhub < server/sql/tables.sql

Configuration

  • Copy the .env.template file and rename it to .env:
  • Use a strong token/secret for the webhook.
  • Add your Wigle API token to translate MAC addresses to coordinates
  • Use systemd to start the server.

TTN Integration

Create new Webhook for your application. Set base url to https://your.domain.tld and enable "Uplink message" to api /api/ttn/webhook. Add a addidtional header:

  • Type: authorization
  • Value: Bearer your-very-secure-token-from-the-env-file

Add a Location Tracker

We use the SenseCAP T1000-B from seeedstudio because of the fair price and multiple location providers. However, you can use any LoRaWAN-enabled tracker that is compatible with TTN and supports the required payload fields.

Onboard SenseCAP T1000-B

  1. Download and install the App SenseCraft
  2. Skip the user account at startup with Skip in the upper right corner
  3. Select the Tracker T1000
  4. Connect to your SenseCAP T1000-B
  5. In the Settings tab select The Things Network as Platform under LoRa
  6. Copy Device EUI, AppEUI and AppKey
  7. Save LoRa settings
  8. Under Geolocation select Geolocation Strategy as Bluetooth+Wi-Fi+GNSS
  9. Set GNSS Max Scan Time (s) to 120
  10. Save Geolocation settings
  11. Exit App with return arrow to trigger re-init of SenseCAP T1000-B

Register SenseCAP T1000-B

  1. Open your Application in TTN and navigate to End devices
  2. Click Register end device in the upper right corner
  3. Set input method to Enter end device specifics manually
  • Frequency plan: Europe 863-870 MHz (SF9 for RX2 - recommended)
  • LoRaWAN version: LoRaWAN Specification 1.0.4
  • Regional Parameters version: RP002 Regional Parameters 1.0.3
  1. Place as JoinEUI the AppEUI
  2. Place the DevEUI
  3. Place the AppKey
  4. Set a name for end device
  5. Click Register end device
  6. Check if new end device joins the TTN
  7. Place the Uplink Payload Formatter as Custom Javascript formatter for new end device

Testing

Testing Webhook

  • To test the webhook use the python script ttn-webhook-dummy.py to send prerecorded TTN Uplinks.
  • To test the script you can use while true; do echo -e "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nSuccess"; nc -l -p 8080 -q 1; done

Emulating Wigle API

  • To emulate the Wigle API use the python script wigle-dummy.py to translate MAC addresses to coordinates.

Happy tracking! 🎉