2ae6d49b72dd14ab07103e421381f497661b0944e2c30febc99b4a124fa0b979
LocationHub
Selfhosted backend for LoRaWAN based Location Tracker that support multiple location providers like GNSS, Gateway-Triangulation, WiFi-Triangulation and BLE-Triangulation. We suggest to use The Things Network (TTN) as middleware for relaying the LoRaWAN payload.
Setup
Prerequisites
- Node.js >= 22.11.0
- Maria DB >= 11.6.2
- Webserver like nginx
Database
Change name of database and credentials as you like!
- 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.templateto.envand configure as you like. - 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. You can use any LoRaWAN enabled tracker that is able to communicate with TTN and supports the needed fields in the payload data.
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.
Description
Self-hosted backend for LoRaWAN-based location tracking, supporting multiple location providers such as GNSS, Gateway-Triangulation, WiFi-Triangulation, and BLE-Triangulation.
Languages
TypeScript
54.3%
JavaScript
39.2%
Python
6.5%