Marcio Cunha

Orchestrating IoT Actuators and Sensors in Private LoRaWAN Networks with ChirpStack Server

Learn how to build a fully private long-range wireless network using ChirpStack to connect and control industrial devices without relying on telecom operators.

Marcio Cunha•5 min
Also available in:PortuguêsEspañol
Summary
  • Private LoRaWAN networks ensure operational autonomy and complete data control in isolated industrial environments.
  • The ChirpStack server centralizes gateway and device management in a modular, open-source architecture.
  • Payload format conversion via JavaScript codecs translates raw bytes into readable metrics for applications.
  • Secure provisioning requires proper cryptographic key registration on both devices and the network server.
  • Actuator integration demands rigorous latency handling and packet delivery confirmation in crowded radio channels.

The Landscape of Long-Range Wireless Networks in Industry

Imagine needing to monitor the temperature of dozens of grain silos scattered across miles of land, or controlling irrigation valves on a farm where cellular internet simply does not reach. Running physical cables is out of the question due to absurd trenching costs, and traditional Wi-Fi barely covers a backyard. This exact connectivity gap is what long-range, low-power radio networks aim to bridge in modern operations.

In practice, this means utilizing unlicensed radio frequencies that travel for kilometers while consuming minimal power, allowing sensors to run for years on a single battery. However, when relying on commercial telecom operators to manage this data, we lose direct control of the infrastructure and become dependent on monthly fees and unstable coverage. The robust alternative is building your own private infrastructure, creating an autonomous ecosystem where every radio message is received, decoded, and delivered locally.

The Architecture Behind a Private Installation

To set up an independent wireless network, we need three fundamental pillars working in harmony. The first pillar consists of end nodes, which are sensors collecting environmental data and actuators executing physical commands, such as turning on a motor. The second pillar is the LoRaWAN gateway, an intelligent antenna that captures radio signals from scattered sensors and translates them into standard internet packets via Ethernet or Wi-Fi.

The third pillar, and the brain of the operation, is the local network server. While the gateway merely forms the physical bridge, the server authenticates each device, decrypts messages, prevents duplicate packets from flooding the system, and routes commands back to the correct actuators. Simply put, the server acts as the telephone switchboard for your farm or factory, ensuring that sensor messages reach their exact destinations without getting lost along the way.

Installing and Configuring ChirpStack on a Local Server

ChirpStack is one of the most powerful and popular tools worldwide for managing these networks in a fully independent manner. Because it is open-source software, we can install it on a local computer at our company, a small Raspberry Pi server, or in the cloud. It brings together multiple modules that communicate with one another, handling security, temporary data storage, and the visual interface where we monitor everything happening.

To get this machinery running smoothly, the cleanest approach is using Docker containers, which pack the software and all its dependencies into an isolated environment. Below is a typical configuration file to spin up the complete environment with a database and MQTT message broker:

version: '3.8'
services:
  chirpstack:
    image: chirpstack/chirpstack:v4
    restart: unless-stopped
    ports:
      - '8080:8080'
    volumes:
      - ./configuration:/etc/chirpstack
    depends_on:
      - postgresql
      - mosquitto
  postgresql:
    image: postgres:14-alpine
    restart: unless-stopped
    volumes:
      - pgdata:/var/lib/postgresql/data
  mosquitto:
    image: eclipse-mosquitto:2
    restart: unless-stopped

Once the services are running and accessible on the main browser port, the next step involves registering the receiving gateway by entering its unique identifier. With the gateway connected and online, the path is clear to start registering the sensors and actuators that will populate our private network.

Provisioning Sensors and Actuators with Cryptographic Security

Registering a physical device on a LoRaWAN network requires extreme attention to security details. Each apparatus features unique identifiers and secret cryptographic keys ensuring that unauthorized outsiders cannot intercept actuator commands or inject false sensor readings. Inside the ChirpStack control panel, we create device profiles determining the radio behavior and expected communication model for each batch of hardware.

During registration, we manually input or import the security keys provided by the hardware manufacturer. The most secure and common activation process is OTAA, where the sensor requests network entry by exchanging encrypted air messages with the server. Once the server validates the credentials, a secure session is established, allowing compact data exchange to preserve battery life and radio bandwidth.

Translating Raw Data with JavaScript Codecs

LoRaWAN devices transmit data in an extremely lean format consisting of hexadecimal number sequences to avoid wasting energy on long text strings. To the server, data such as temperature and humidity arrives simply as a confusing string of characters like '010a021b'. To turn this jumble of letters and numbers into readable insights, we utilize conversion functions called codecs.

In ChirpStack, we can write small snippets of JavaScript code inside the device profile to decode the raw signal arriving from the sensor. When a message arrives, the server executes this code automatically, converting bytes into a structured format that any monitoring system can easily understand. Below is a simple example of a decoding function:

function decodeUplink(input) {
  var bytes = input.bytes;
  var temperature = ((bytes[0] << 8) | bytes[1]) / 100;
  var umidade = bytes[2];
  return {
    data: {
      temperature: temperature,
      humidity: umidade
    }
  };
}

With this automatic translation running on the server, external applications receive clean JSON instead of raw bytes, drastically simplifying integration with graphic dashboards and building or industrial automation systems.

Orchestrating Actuators and Real-Time Control Logic

So far we have seen how to collect data from sensors, but the true power of automation emerges when we close the loop by sending commands to actuators. Unlike sensors that only transmit readings periodically, actuators require delivery confirmation to ensure the command to open a gate or turn off a pump was actually executed by the physical hardware in the field.

Since the radio spectrum is shared and subject to interference, ChirpStack manages downlink message queues, waiting for the next communication window opened by the sensor or actuator to deliver the command. External systems can connect to the server's MQTT broker to trigger these actions automatically based on sensor readings, creating intelligent control rules without relying on external internet connectivity. To complement this implementation in production environments, see our related technical analyses on Modbus TCP in Redundant Industrial Networks: Orchestrating Actuators and Readings and Datacenter Climate Control Automation with IoT Sensors and LoRaWAN Networks.

Final Considerations

Building and orchestrating a private LoRaWAN network with ChirpStack places total control of IoT infrastructure directly into your team's hands, eliminating recurring costs and third-party dependencies. From proper server container configuration to payload translation and sending commands to actuators, each layer demands careful planning and rigorous signal testing. Mastering this architecture opens doors for scalable, resilient solutions perfectly tailored to the most complex remote monitoring and automation challenges.