Skip to content

gomiunik/lilora

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LiLoRa - LoRaWAN Range Tracking System

A multi-repository solution for tracking LoRaWAN signal range and coverage using LilyGo T-Watch S3, mobile phone GPS, and real-time web services.

Overview

LiLoRa combines wearable LoRaWAN hardware, mobile GPS forwarding, and cloud-based visualization to create comprehensive coverage maps for LoRaWAN networks. Perfect for testing gateway range, optimizing network deployment, and validating signal quality in real-world conditions.

Key Features

  • πŸ“ GPS Tracking: Mobile phone provides GPS coordinates to watch via Bluetooth LE
  • πŸ“‘ LoRaWAN Integration: SX1262 radio connects to ChirpStack or The Things Network
  • πŸ—ΊοΈ Real-Time Mapping: Live signal quality visualization on mobile app
  • πŸ“Š Signal Metrics: Track RSSI, SNR, spreading factor, and packet delivery
  • πŸ’Ύ Session Recording: Save and export range tests as GeoJSON/KML
  • πŸ”‹ Low Power: Optimized for extended field testing (940mAh battery)

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Mobile Phone   β”‚         β”‚  T-Watch S3      β”‚         β”‚  LoRaWAN        β”‚
β”‚  (GPS Source)   │◄───BLE───  (ESP32-S3 +     │───LoRa──►│  Gateway        β”‚
β”‚                 β”‚         β”‚   SX1262 Radio)  β”‚         β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                                                          β”‚
        β”‚                                                          β”‚
        β”‚                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”‚
        └──────WebSocket─────  FastAPI Backend │◄────Webhookβ”€β”€β”€β”€β”€β”˜
                            β”‚  (Real-time Srv) β”‚
                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                            β”‚  ChirpStack or   β”‚
                            β”‚  The Things Net  β”‚
                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Repository Structure

This project is organized as a multi-repository setup:

lilora/                          # This repository (documentation & planning)
β”‚
β”œβ”€β”€ README.md                    # Project overview (this file)
β”œβ”€β”€ CLAUDE.md                    # Development guide for Claude Code
β”œβ”€β”€ PROJECT_PLAN.md              # Detailed phase-by-phase implementation plan
β”‚
β”œβ”€β”€ lilora-firmware/             # T-Watch S3 firmware (create separately)
β”‚   β”œβ”€β”€ platformio.ini           # PlatformIO configuration
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.cpp             # Main firmware loop
β”‚   β”‚   β”œβ”€β”€ lorawan_config.h     # LoRaWAN credentials (gitignored)
β”‚   β”‚   β”œβ”€β”€ bluetooth.cpp        # BLE NMEA server
β”‚   β”‚   β”œβ”€β”€ nmea_parser.cpp      # GPS data parser
β”‚   β”‚   └── payload_encoder.cpp  # Binary encoding
β”‚   └── lib/                     # LilyGoLib, RadioLib
β”‚
β”œβ”€β”€ lilora-mobile/               # Flutter mobile app (create separately)
β”‚   β”œβ”€β”€ pubspec.yaml             # Flutter dependencies
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ main.dart            # App entry point
β”‚   β”‚   β”œβ”€β”€ screens/
β”‚   β”‚   β”‚   β”œβ”€β”€ home_screen.dart
β”‚   β”‚   β”‚   └── map_screen.dart
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ bluetooth_service.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ gps_service.dart
β”‚   β”‚   β”‚   └── websocket_service.dart
β”‚   β”‚   └── models/
β”‚   β”‚       └── range_point.dart
β”‚   └── android/ & ios/          # Platform-specific config
β”‚
└── lilora-backend/              # FastAPI backend (create separately)
    β”œβ”€β”€ main.py                  # FastAPI app
    β”œβ”€β”€ requirements.txt         # Python dependencies
    β”œβ”€β”€ models/
    β”‚   └── uplink.py            # ChirpStack/TTN schemas
    β”œβ”€β”€ services/
    β”‚   β”œβ”€β”€ decoder.py           # Payload decoder
    β”‚   └── websocket_manager.py # Connection manager
    └── Dockerfile               # Container deployment

Quick Start

Prerequisites

  • Hardware:

    • LilyGo T-Watch S3 (with SX1262 LoRa radio, 868MHz or 915MHz)
    • Android or iOS smartphone with GPS
    • LoRaWAN gateway (or access to public TTN coverage)
  • Software:

    • PlatformIO CLI (firmware development)
    • Flutter SDK 3.x (mobile app)
    • Python 3.10+ (backend service)
    • ChirpStack or TTN account

Setup Steps

  1. Register LoRaWAN Device:

  2. Flash Firmware:

    cd lilora-firmware
    # Edit src/lorawan_config.h with your keys
    pio run --target upload
  3. Configure Backend:

    cd lilora-backend
    # Using uv (recommended)
    uv sync
    uv run uvicorn main:app --host 0.0.0.0 --port 8000
    
    # Or using pip
    pip install -r requirements.txt
    uvicorn main:app --host 0.0.0.0 --port 8000
    
    # Add webhook integration in ChirpStack/TTN console
  4. Run Mobile App:

    cd lilora-mobile
    flutter pub get
    flutter run
  5. Start Range Test:

    • Open mobile app, connect to T-Watch via Bluetooth
    • Enable GPS forwarding
    • Walk away from gateway while watching signal quality
    • View real-time coverage map

Development Phases

Development is structured in 5 phases (see PROJECT_PLAN.md for details):

Phase 1: Firmware Foundation βœ…

  • LoRaWAN OTAA join to ChirpStack/TTN
  • Session persistence (NVS storage)
  • Uplink/downlink tested and working

Phase 2: Bluetooth GPS Integration βœ…

  • BLE Serial Server on T-Watch (Nordic UART Service)
  • NMEA sentence generation in Flutter app
  • GPS data encoding in LoRaWAN payload (13-byte binary format)

Phase 3: Backend Service βœ…

  • FastAPI webhook receiver (ChirpStack & TTN)
  • WebSocket broadcast manager for real-time updates
  • Payload decoder with Haversine distance calculation
  • 19/19 tests passing

Phase 4: Mobile Visualization πŸ”œ

  • Map integration with range plotting
  • Live signal metrics dashboard
  • Session recording and export

Phase 5: Enhancements πŸ”œ

  • Adaptive Data Rate monitoring
  • Multi-gateway support
  • Offline mode with sync

Technology Stack

Component Technology Purpose
Firmware PlatformIO + Arduino ESP32-S3 development
RadioLib 6.6.0 LoRaWAN stack (SX1262)
ESP32 BLE Bluetooth LE server
Mobile Flutter 3.x Cross-platform UI
flutter_blue_plus Bluetooth LE client
geolocator GPS access
Backend FastAPI + uv Async web framework
WebSockets Real-time updates
Pydantic Data validation
Network ChirpStack or TTN LoRaWAN network server

Use Cases

  • Network Planning: Map coverage before deploying IoT devices
  • Gateway Optimization: Test antenna placement and configuration
  • Interference Analysis: Identify signal dead zones and obstacles
  • Regulatory Compliance: Verify duty cycle and power limits
  • Community Mapping: Contribute to public LoRaWAN coverage databases

Hardware Specifications

LilyGo T-Watch S3:

  • ESP32-S3 dual-core @ 240MHz (16MB Flash, 8MB PSRAM)
  • SX1262 LoRa transceiver (433/868/915MHz)
  • Bluetooth 5.0 Low Energy
  • 1.54" LCD touchscreen (240x240)
  • BMA423 accelerometer
  • 940mAh battery (USB-C charging)

No GPS on watch: GPS coordinates provided by mobile phone via Bluetooth LE using NMEA protocol.

Contributing

This project is in active development. Contributions welcome!

  1. Fork the relevant repository (firmware, mobile, or backend)
  2. Create feature branch: git checkout -b feature/my-feature
  3. Commit changes: git commit -am 'Add new feature'
  4. Push to branch: git push origin feature/my-feature
  5. Open Pull Request

Troubleshooting

Common Issues

LoRaWAN Join Fails:

  • Verify OTAA keys match network server exactly
  • Enable "Resets DevNonces" in device settings (development only)
  • Check gateway is online and in range

BLE Connection Drops:

  • Ensure location permissions granted on mobile app
  • Keep phone within 10m of watch
  • Disable battery optimization for app

Backend Not Receiving Data:

  • Confirm webhook URL is publicly accessible
  • Check network server integration logs
  • Test with curl: curl -X POST https://your-backend/webhook/chirpstack -d @sample.json

See CLAUDE.md for detailed troubleshooting guide.

Resources

Documentation

Example Code

License

This project is released under MIT License. Individual components (LilyGoLib, RadioLib, Flutter, FastAPI) retain their original licenses.

Acknowledgments

  • LilyGo - T-Watch S3 hardware platform
  • Jan GromeΕ‘ - RadioLib LoRaWAN implementation
  • ChirpStack/TTN - Open-source network server infrastructure
  • Flutter & FastAPI communities - Excellent frameworks and documentation

Project Status: Phases 1-3 Complete - Firmware, mobile BLE app, and backend service all working. Ready for Phase 4 (Mobile Visualization).

Maintainer: Boris Gomiunik Created: January 2026 Last Updated: January 2026

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors