Reviewed-on: #15
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
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
- Download and install the App SenseCraft
- Skip the user account at startup with Skipin the upper right corner
- Select the Tracker T1000
- Connect to your SenseCAP T1000-B
- In the Settingstab selectThe Things Networkas Platform underLoRa
- Copy Device EUI,AppEUIandAppKey
- Save LoRa settings
- Under Geolocationselect Geolocation Strategy asBluetooth+Wi-Fi+GNSS
- Set GNSS Max Scan Time (s)to 120
- Save Geolocation settings
- Exit App with return arrow to trigger re-init of SenseCAP T1000-B
Register SenseCAP T1000-B
- Open your Application in TTN and navigate to End devices
- Click Register end devicein the upper right corner
- 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
- Place as JoinEUItheAppEUI
- Place the DevEUI
- Place the AppKey
- Set a name for end device
- Click Register end device
- Check if new end device joins the TTN
- Place the Uplink Payload Formatter as Custom Javascript formatterfor 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! 🎉