IoT System with ATAK Integration

A step-by-step guide for building and configuring your IoT system with ESP32, LoRa, 5G, and PACE communication.

Introduction

This guide provides detailed instructions for setting up an IoT system with integrated ATAK functionality, leveraging ESP32, 5G for video transmission, and PACE communication strategies for robust connectivity.

System Architecture

The system includes:

Hardware Setup

Required Components

Wiring Diagrams

Below are wiring diagrams for connecting the ESP32-CAM, LoRa module, GPS, and other components.

ESP32-CAM with LoRa and GPS

                ESP32 Pin Connections:
                - LoRa Module:
                  VCC -> 3.3V
                  GND -> GND
                  MISO -> GPIO19
                  MOSI -> GPIO23
                  SCK -> GPIO18
                  NSS -> GPIO5
                  RST -> GPIO14
                  DIO0 -> GPIO26
                - GPS Module:
                  VCC -> 3.3V
                  GND -> GND
                  RX -> GPIO16
                  TX -> GPIO17
            

Raspberry Pi Zero 2 W as a Local Node

Raspberry Pi Zero 2 W Pin Connections:
- LoRa Module:
  VCC -> 3.3V
  GND -> GND
  MISO -> GPIO9
  MOSI -> GPIO10
  SCK -> GPIO11
  NSS -> GPIO8
  RST -> GPIO25
  DIO0 -> GPIO24
- Optional GPS Module:
  VCC -> 3.3V
  GND -> GND
  RX -> GPIO14
  TX -> GPIO15

The Raspberry Pi Zero 2 W collects LoRa data from ESP32 nodes and forwards it to the central hub (Raspberry Pi 4) via Wi-Fi or 5G, depending on network availability.

Raspberry Pi Hub with 5G Modem

                Raspberry Pi Pin Connections:
                - 5G Modem:
                  USB Modem -> Raspberry Pi USB Port
                - LoRa Gateway:
                  VCC -> 5V
                  GND -> GND
                  MISO -> GPIO9
                  MOSI -> GPIO10
                  SCK -> GPIO11
                  NSS -> GPIO8
                  RST -> GPIO25
                  DIO0 -> GPIO24
            

Assembly Notes

Use weatherproof enclosures for outdoor nodes. Ensure stable power supply to each device using LiPo batteries or solar panels as necessary.

Software Configuration

Setting Up ESP32 Nodes

Flash the ESP32 with the following firmware for LoRa and GPS communication:

#include 
#include 

TinyGPSPlus gps;
HardwareSerial gpsSerial(1);

void setup() {
    gpsSerial.begin(9600, SERIAL_8N1, 16, 17);
    LoRa.begin(868E6);
}

void loop() {
    while (gpsSerial.available() > 0) {
        if (gps.encode(gpsSerial.read())) {
            String message = "{";
            message += "\"lat\":" + String(gps.location.lat(), 6) + ",";
            message += "\"lon\":" + String(gps.location.lng(), 6) + "}";
            LoRa.beginPacket();
            LoRa.print(message);
            LoRa.endPacket();
        }
    }
}
            

Configuring Node-RED for PACE

Set up Node-RED on both the Raspberry Pi Zero 2 W and Raspberry Pi 4 to handle PACE communication:

Node-RED Workflow for Fallback Channels

[{
    "id": "primary",
    "type": "http request",
    "url": "http://central_hub:8087",
    "method": "POST",
    "headers": {"Content-Type": "application/xml"},
    "wires": [["response_handler"]]
}, {
    "id": "fallback_wifi",
    "type": "mqtt out",
    "topic": "fallback/wifi",
    "broker": "mqtt_broker",
    "wires": [["response_handler"]]
}, {
    "id": "fallback_lora",
    "type": "function",
    "name": "LoRa Packet Handler",
    "func": "msg.payload = {data: msg.payload}; return msg;",
    "wires": [["send_lora"]]
}]

The flow attempts to send data using 5G first (HTTP), then Wi-Fi (MQTT), and finally LoRa as a contingency.

Configuring the Raspberry Pi Hub

Install the following software on the Raspberry Pi:

sudo apt update
sudo apt install mosquitto mosquitto-clients
sudo apt install nodered influxdb grafana
            

Node-RED Flow Example

Set up a flow to handle incoming data from ESP32 nodes:

[{
    "id": "sensor1",
    "type": "mqtt in",
    "topic": "sensors/#",
    "broker": "mqtt_broker",
    "payload": "json",
    "wires": [["process_data"]]
}, {
    "id": "process_data",
    "type": "function",
    "name": "Parse GPS",
    "func": "msg.payload = {lat: msg.payload.lat, lon: msg.payload.lon}; return msg;",
    "wires": [["influxdb"]]
}]
            

ATAK Integration

CoT Protocol

Use the CoT protocol to send sensor and video data to ATAK:


    
        Sensor detected motion
    

            

Sending Data to ATAK

Use Python to send CoT data via HTTP:

import requests

cot_message = """

    
        Motion detected
    

"""
response = requests.post("http://atak_ip:8087", data=cot_message, headers={"Content-Type": "application/xml"})
print(response.status_code)
            

PACE Communication Plan

Channel Switching

Node-RED dynamically switches channels based on availability. For example:

if (5G_unavailable) {
    switch_to("Wi-Fi Mesh");
} else if (Wi-Fi_unavailable) {
    switch_to("LoRa");
} else if (LoRa_unavailable) {
    switch_to("Satellite");
}

Troubleshooting

Common issues and their solutions:

Troubleshooting PACE Setup