A distributed lightning detection system built for Heltec WiFi LoRa 32 V3 boards with ESP32-S3, featuring modular architecture, comprehensive hardware abstraction, and GPS tracking capabilities.
- Lightning Detection - AS3935 sensor integration with noise filtering
- LoRa Communication - Long-range data transmission using SX1262 radio
- GPS Tracking - UC6580 GNSS support for precise location data
- OLED Display - Real-time status and data visualization
- WiFi Connectivity - Multi-network support with automatic fallback
- OTA Updates - Over-the-air firmware updates via WiFi
- Modular Design - Clean hardware abstraction for easy portability
- Comprehensive API - GPIO, I2C, SPI, PWM, ADC, Timer, Power, Memory management
- Test Coverage - 51 unit tests ensuring reliability
- ESP32-S3 Optimized - Tailored for Heltec WiFi LoRa 32 V3 hardware
- Multi-Board Support - Sender/receiver architecture
- Power Management - Sleep modes and battery monitoring
- Error Handling - Robust error detection and recovery
- Debugging Tools - Serial logging and diagnostic information
- Heltec WiFi LoRa 32 V3 - Main development board
- Heltec Wireless Tracker - GPS-enabled transmitter (upcoming)
- MCU: ESP32-S3 (240MHz, dual-core, 8MB Flash, 512KB SRAM)
- Radio: SX1262 LoRa transceiver (915MHz)
- Display: 128x64 OLED (SSD1306)
- GPS: UC6580 GNSS (L1+L5/L2 dual frequency)
- Connectivity: WiFi 802.11 b/g/n
- AS3935 Lightning sensor
- Battery voltage monitoring
- External GPIO expansion
- I2C/SPI device support
# Install PlatformIO Core
pip install platformio
# Clone the repository
git clone https://github.com/Skeyelab/LightningDetector.git
cd LightningDetector# Build
pio run -e unified
# Upload (USB serial bootloader)
pio run -e unified -t upload
# Monitor serial output
pio device monitorAfter flashing, the board boots as Sender by default. Change the role at runtime:
Web UI
- Connect to the deviceโs IP or
esp32.local - Scroll to Device Role โ click Toggle Role (sender โ receiver)
- Reboot to apply
HTTP API
curl -X POST http://<ip>/api/v1/config \
-H 'Content-Type: application/json' \
-d '{"role":"receiver"}'The choice is stored in NVS, so future boots keep the selected role.
The project includes a web-based ESP32 firmware flasher that allows you to flash devices directly from your browser without installing additional software.
- ๐ Web Interface: Flash ESP32 devices from any modern browser
- ๐ Unified Firmware: Single firmware supports both TX and RX modes
- ๐ฑ Legacy Support: Transmitter and receiver firmware flashing (backward compatibility)
- ๐ File Upload: Support for custom firmware files
- ๐ Serial Port: Direct USB connection to ESP32 devices
- ๐ Progress Tracking: Real-time flashing progress and status updates
- Visit: Web Flasher
- Connect: Plug your ESP32 device via USB
- Select: Choose Unified Firmware (recommended) or legacy transmitter/receiver
- Flash: Click "Connect & Flash" and follow the prompts
- Configure: After flashing unified firmware, use web interface to set device role
- Browser: Chrome or Edge (Web Serial API support)
- Hardware: ESP32 device in download mode
- USB Cable: Data cable (not just charging cable)
- Upload custom
.binfiles for unified, transmitter, or receiver firmware - Support for both pre-built and custom firmware
- Automatic file validation and size checking
- Recommended: Use unified firmware for maximum flexibility
// Copy and modify wifi_networks_example.h
cp wifi_networks_example.h src/wifi_networks.h
// Edit src/wifi_networks.h with your network credentials// Heltec V3 Pin Configuration (src/config/system_config.h)
#define VEXT_PIN 36 // Power control
#define OLED_RST_PIN 21 // OLED reset
#define BUTTON_PIN 0 // User button
#define LORA_NSS 8 // LoRa chip select
#define LORA_DIO1 14 // LoRa interruptThe repository is organized for easy navigation and maintenance:
ci/- Continuous Integration scriptsrun_tests.sh- Comprehensive test suiterun_static_analysis.sh- Code analysis toolsrun_tidy.sh- Clang-tidy formatting
dev/- Development and deployment scriptsflash_unified.sh- Flash unified firmware to single deviceflash_both.sh- Flash unified firmware to both devicescreate_release.sh- Create release packages
optimize/- Performance optimization toolsoptimize_clang_tidy_cache.sh- Build cache optimization
development/- Development guidesQUICK_START_RELEASE.md- Release quick startRELEASE_README.md- Release proceduresTROUBLESHOOTING.md- Common issues and solutions
deployment/- Deployment documentationOTA_README.md- Over-the-air update guideWEB_FLASHER_DEPLOYMENT.md- Web flasher setupWIFI_MULTI_NETWORK_README.md- Multi-network WiFi config
testing/- Testing documentationNEW_TESTS_NEEDED.md- Test coverage gapsSTATIC_ANALYSIS.md- Static analysis setup
project/- Project managementCURSOR_PROJECT_STATUS.md- Current project statusCI_CACHING_OPTIMIZATION.md- CI performance notes
# Execute comprehensive test suite
./scripts/ci/run_tests.sh# Hardware Abstraction Layer tests
pio test -e native -f test_hardware_abstraction
# Integration tests
pio test -e native -f test_integration
# WiFi functionality tests
pio test -e native -f test_wifi_manager# Code quality checks
./run_static_analysis.sh
# Clang-tidy analysis
./run_tidy.shโโโ src/
โ โโโ hardware/ # Hardware Abstraction Layer
โ โ โโโ hardware_abstraction.h
โ โ โโโ hardware_abstraction.cpp
โ โโโ sensors/ # Sensor implementations
โ โ โโโ gps_sensor.h/.cpp
โ โ โโโ lightning_sensor.h
โ โ โโโ sensor_interface.h
โ โโโ communication/ # Communication protocols
โ โโโ system/ # System management
โ โโโ config/ # Configuration files
โ โโโ main.cpp # Application entry point
โโโ test/ # Unit tests
โโโ docs/ # Additional documentation
โโโ platformio.ini # PlatformIO configuration
#include "hardware/hardware_abstraction.h"
using namespace HardwareAbstraction;
// Initialize HAL
initialize();
// Configure GPIO
GPIO::pinMode(2, GPIO::Mode::MODE_OUTPUT);
GPIO::digitalWrite(2, GPIO::Level::LEVEL_HIGH);// Initialize I2C for OLED
I2C::initialize(21, 22, 400000); // SDA, SCL, frequency
// Write to device
uint8_t data[] = {0x00, 0xFF};
I2C::beginTransmission(0x3C);
I2C::write(data, sizeof(data));
I2C::endTransmission();#include "sensors/gps_sensor.h"
// Initialize GPS for Wireless Tracker
GPS::Config config = GPS::getWirelessTrackerV11Config();
GPS::initializeGPS(config);
// Read GPS data
if (GPS::hasGPSFix()) {
const GPS::Data& data = GPS::getGPSData();
printf("Position: %.6f, %.6f\n", data.latitude, data.longitude);
}// Message format
struct LightningMessage {
uint32_t timestamp;
float latitude;
float longitude;
uint16_t strike_count;
uint8_t noise_level;
uint16_t battery_mv;
};- Automatic network selection
- Connection priority management
- Fallback mechanisms
- OTA update support
// Deep sleep for battery conservation
Power::sleep(Power::Mode::DEEP_SLEEP, 300000); // 5 minutes
// Wake on button press or timer// Check battery status
float voltage = Power::getBatteryVoltage();
uint8_t percent = Power::getBatteryPercent();// Debug output levels
#define LOG_DEBUG 0
#define LOG_INFO 1
#define LOG_WARN 2
#define LOG_ERROR 3- Memory usage tracking
- LoRa transmission statistics
- GPS fix quality monitoring
- Power consumption analysis
- Fork the repository
- Create feature branch (
git checkout -b feature/new-sensor) - Implement changes with tests
- Run test suite (
./scripts/ci/run_tests.sh) - Submit pull request
- Follow existing code style
- Add unit tests for new features
- Update documentation
- Pass static analysis checks
- Hardware Abstraction Layer โ COMPLETE
- Modular Architecture ๐ง IN PROGRESS
- WiFi Multi-Network Setup
- OTA Update Guide
- Troubleshooting Guide
- Static Analysis Results
- CI Caching Optimization
- Project Status
- Hardware Abstraction Layer
- GPS Integration (UC6580)
- Comprehensive Testing
- Build System Optimization
- Unified Firmware Architecture
- Web Interface & Role Management
- Web Server Performance Optimization
- AS3935 Sensor Integration
- Noise Filtering Algorithms
- Calibration Procedures
- Real-time Processing
- LoRa Network Protocol
- Message Encryption
- Multi-hop Routing
- Data Aggregation
- Storm Tracking
- Prediction Models
- Web Dashboard
- Mobile App
This project is licensed under the MIT License - see the LICENSE file for details.
- Heltec Automation - Hardware platform and documentation
- Espressif Systems - ESP32-S3 microcontroller and ESP-IDF
- RadioLib - LoRa communication library
- U8g2 - OLED display library
- PlatformIO - Development platform and toolchain
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
Built with โค๏ธ for the lightning detection community