A secure, long-range wireless communication system using ESP8266 and LoRa SX1278 modules with military-grade AES-128 encryption
Features • Hardware • Installation • Usage • Documentation
|
|
- 📱 Serial Interface: Easy debugging and message input via UART
- 🔌 Multi-MCU Support: ESP8266, ESP32, Arduino Nano/Uno compatible
- ⚡ OTA Ready: Over-The-Air update capability
- 🎯 Plug & Play: Simple serial communication for other MCUs
| Component | Specification | Quantity |
|---|---|---|
| ESP8266 | NodeMCU / Wemos D1 Mini | 2+ |
| LoRa SX1278 | 433MHz Module | 2+ |
| Jumper Wires | Male-to-Female | 8 per unit |
| Power Supply | 3.3V (min 500mA) | 1 per unit |
- Breadboard for prototyping
- External antenna for extended range
- Level shifter (for 5V Arduino boards)
| ESP8266 GPIO | SX1278 Pin | Description |
|---|---|---|
| GPIO15(D8) | NSS/CS | Chip Select |
| GPIO16(D0) | RST | Reset |
| GPIO5(D1) | DIO0 | Interrupt |
| GPIO14(D5) | SCK | SPI Clock |
| GPIO13(D7) | MOSI | SPI Data Out |
| GPIO12(D6) | MISO | SPI Data In |
| 3.3V | VCC | Power Supply |
| GND | GND | Ground |
ESP32 Configuration
| ESP32 GPIO | SX1278 Pin | Description |
|---|---|---|
| GPIO5 | NSS/CS | Chip Select |
| GPIO14 | RST | Reset |
| GPIO2 | DIO0 | Interrupt |
| GPIO18 | SCK | SPI Clock |
| GPIO23 | MOSI | SPI Data Out |
| GPIO19 | MISO | SPI Data In |
| 3.3V | VCC | Power |
| GND | GND | Ground |
| ESP32 GPIO | SX1278 Pin |
|---|---|
| GPIO15 | NSS/CS |
| GPIO4 | RST |
| GPIO26 | DIO0 |
Arduino Nano/Uno Configuration
| Arduino Pin | SX1278 Pin | Description |
|---|---|---|
| D10 | NSS/CS | Chip Select |
| D9 | RST | Reset |
| D2 | DIO0 | Interrupt (INT0) |
| D13 | SCK | SPI Clock |
| D11 | MOSI | SPI Data Out |
| D12 | MISO | SPI Data In |
| 3.3V | VCC | Power |
| GND | GND | Ground |
# Add ESP8266 Board Package
# File → Preferences → Additional Board Manager URLs:
http://arduino.esp8266.com/stable/package_esp8266com_index.jsonNavigate to Sketch → Include Library → Manage Libraries and install:
- LoRa by Sandeep Mistry
- AESLib by DavyLandman
git clone https://github.com/roboticist-blip/LoRa8266T.git
cd LoRa8266T- Open
LoRa8266T.inoin Arduino IDE - Select your board: Tools → Board → ESP8266 Boards → NodeMCU 1.0
- Select COM port: Tools → Port
- Click Upload ⬆️
- Power up both ESP8266 + LoRa modules
- Open Serial Monitor at 9600 baud
- Type message and press Enter
- Watch magic happen ✨
ESP8266 LoRa Interface with AES Encryption Starting...
LoRa Ready with AES Encryption!
TX: 0:Hello World (Encrypted)
RX: 1:Hello back! (RSSI: -45)
TX: 2:Testing secure comms
RX: 3:Roger that! (RSSI: -52)
- TX: Transmitted message with counter
- RX: Received message with RSSI (signal strength)
- RSSI Values: -30 to -60 (Excellent), -60 to -90 (Good), < -90 (Poor)
#define LORA_FREQUENCY 433E6 // 433 MHz (Europe/Asia)
#define LORA_SYNC_WORD 0x12 // Network ID
#define LORA_SPREADING_FACTOR 7 // 7-12 (higher = longer range)
#define LORA_BANDWIDTH 125E3 // 125 kHz
#define LORA_TX_POWER 17 // dBm (2-20)| Region | Frequency | Legal Status |
|---|---|---|
| Europe/Asia | 433 MHz | ISM Band ✅ |
| North America | 915 MHz | ISM Band ✅ |
| Europe | 868 MHz | ISM Band ✅ |
uint8_t aes_key[AES_KEY_SIZE] = {
0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
};For Maximum Range:
#define LORA_SPREADING_FACTOR 12 // Slower but longer range
#define LORA_TX_POWER 20 // Maximum powerFor Maximum Speed:
#define LORA_SPREADING_FACTOR 7 // Faster transmission
#define LORA_BANDWIDTH 250E3 // Wider bandwidthPlaintext → AES-128 CBC → PKCS7 Padding → LoRa Transmission
- AES-128 CBC: Symmetric encryption with 128-bit key
- Initialization Vector (IV): Randomized per message
- Message Counter: Monotonically increasing sequence
- PKCS7 Padding: Ensures block alignment
✅ Replay Attack: Prevented by message counter
✅ Man-in-the-Middle: Protected by AES encryption
✅ Eavesdropping: Encrypted transmission
| Problem | Solution |
|---|---|
| ❌ LoRa init failed | • Check wiring connections • Verify 3.3V power supply • Test with multimeter |
| 📡 No messages received | • Match frequency on both devices • Verify sync word (0x12) • Check antenna connection |
| 🔓 Decryption failed | • Ensure identical AES keys • Verify both devices running same code |
| 📉 Poor range | • Adjust antenna position • Increase TX power • Use higher spreading factor |
| 💡 ESP8266 won't boot | • Check GPIO15 not floating • Verify GPIO0/GPIO2 states • Test power supply |
Enable detailed logging:
#define DEBUG_MODE 1| Parameter | Value |
|---|---|
| Range | Up to 2km (line-of-sight) |
| Data Rate | ~5.5 kbps @ SF7 |
| Frequency | 433 MHz (configurable) |
| Encryption | AES-128 CBC |
| Power Consumption | ~100mA TX, ~15mA RX |
| Operating Voltage | 3.3V |
| Interface | UART (9600 baud) |
LoRa8266T/
├── LoRa8266T.ino # Main firmware
├── docs/
│ ├── wiring_diagram.png # Connection guide
│ └── LICENSE # MIT License
└── README.md # This file
View Complete Pin Configurations
#define SS_PIN 15 // GPIO15
#define RST_PIN 16 // GPIO16
#define DIO0_PIN 5 // GPIO5#define SS_PIN 4 // GPIO4 (D2)
#define RST_PIN 0 // GPIO0 (D3)
#define DIO0_PIN 2 // GPIO2 (D4)We welcome contributions! Here's how you can help:
- 🍴 Fork the repository
- 🌿 Create your feature branch:
git checkout -b feature/amazing-feature - 💾 Commit your changes:
git commit -m 'Add amazing feature' - 📤 Push to the branch:
git push origin feature/amazing-feature - 🎉 Open a Pull Request
- Follow existing code style
- Test on real hardware before submitting
- Update documentation for new features
- Add comments for complex logic
This project is licensed under the MIT License - see the LICENSE file for details.
✅ Commercial use
✅ Modification
✅ Distribution
✅ Private use
- Sandeep Mistry - LoRa Library
- DavyLandman - AESLib
- ESP8266 Community - Hardware support and documentation
- This project is for educational and experimental purposes
- Ensure compliance with local radio regulations when using LoRa frequencies
- The default AES key is for demonstration only
- Always use your own secure key in production
- Respect ISM band regulations in your region
- Maximum transmission power may be legally restricted
Made with ❤️ for the IoT Community
Built with ESP8266 • Secured with AES-128 • Powered by LoRa