How to Remotely Control RS485 Devices Using LoRaWAN Downlink Commands (Class C Explained)
Short Answer
A LoRaWAN downlink is a message from your server to a device. Sent to an RS485 to LoRaWAN converter, it becomes a Modbus write: a new set-point in a holding register, a relay closed through a coil, a mode changed on a controller. Whether the command arrives in seconds or in minutes depends on the device class: a Class A battery device only listens briefly after each of its own transmissions, so a command waits for the next uplink; a Class C mains-powered device listens continuously and acts within a second or two.
To control an RS485 device over LoRaWAN you need four things:
- A converter that supports Modbus writes by downlink (function codes 06 and 16 for registers, 05 and 15 for coils), such as the MacSync LX1.
- DC power at the converter if you want Class C latency; battery units stay Class A.
- A network server that can queue downlinks (ChirpStack, The Things Stack) and a gateway with downlink capacity.
- A way to confirm the write took effect, which is a read-back, not an acknowledgement.
The rest of this guide covers the classes, the encoding, the platform steps, a worked VFD example, and the line between what LoRaWAN control is good for and what it must never be used for.
Device Classes, and Why They Decide Latency
LoRaWAN defines three classes by when a device listens. All devices transmit the same way; they differ in how they receive.
| Class | Listens | Command arrives | Power | Fits |
|---|---|---|---|---|
| A | Two short windows after each uplink | After the next uplink | Lowest; years on battery | Sensors, battery converters |
| B | Scheduled slots synced to gateway beacons | At the next slot, seconds to minutes | Medium | Rare in practice |
| C | Continuously, except while transmitting | Within ~1–3 s | Highest; mains or DC | Controllers, DC converters |
A Class A converter reporting every 15 minutes applies a downlink up to 15 minutes after you send it, 7½ minutes on average. You can shorten that by shortening the heartbeat, at a battery cost, or by sending an uplink on demand, but you can’t make it instant. A Class C converter applies it as soon as the gateway can transmit it.
The power difference is why class follows power source. A Class C receiver draws a few milliamps continuously, which would drain a 19 Ah cell in months rather than years; Macnman’s LoRaWAN controllers are Class C only and mains-powered, and the DC variant of the LX1 can be set to Class C in the Maya app while the battery variant stays Class A. The class must also be set on the network server (a Class C flag in the ChirpStack device profile; the device’s class in The Things Stack), or the server will keep queuing downlinks for the next uplink.
What a Downlink Costs the Network
Downlinks are more expensive than uplinks, and that shapes how you use them.
- The gateway goes deaf while it transmits. It’s half-duplex: for the airtime of each downlink it hears no uplinks from any device. A site that sends hundreds of downlinks an hour loses sensor data.
- The gateway has its own duty-cycle limit: 10% transmit time in India under G.S.R. 853(E), shared by every device it serves. See LoRaWAN in India: IN865 and WPC Rules.
- Public networks cap them. The Things Network’s community fair use policy allows 10 downlinks per device per day. A private ChirpStack network has no such cap, only the duty cycle; see Do I Need a Gateway for LoRa?
- One downlink per receive opportunity. The server sends one queued message per window; a queue of five takes five opportunities on Class A.
The practical rule: use downlinks for set-points, schedules, mode changes and occasional relay commands, not for polling or for a control loop. For continuous data, let the converter poll; see Transparent Mode vs Polling Mode.
How the Converter Turns a Downlink into a Modbus Write
The downlink carries a small binary command on a specific FPort; the converter decodes it and performs the Modbus transaction on the RS485 bus. The LX1 maps its downlink operations to FPorts:
| FPort | Operation | Modbus function |
|---|---|---|
| 6 | Change reporting interval | — |
| 8 | Write holding register(s) | FC06 / FC16 |
| 9 | Write coil(s) | FC05 / FC15 |
| 10 | Add or update a polled field | — |
| 12 | Set baud rate and parity | — |
| 13 | Read a register group once | FC03 / FC04 |
| 15 | Return a configured field | — |
The command payload for a write carries the slave ID, the register address, and the value (one register for FC06; several, in the instrument’s word order, for FC16). Rather than hand-assemble bytes, use the downlink encoder published with the decoder: it exposes an encodeDownlink function that takes { slaveId, register, value, type, order } and returns the bytes and FPort. The LX1’s encoder is in the MacnMan LoRaWAN decoders repository alongside the uplink decoders described in How to Decode LoRaWAN Payloads from Modbus Devices.
Two encoding rules carry over from decoding. A 32-bit value written with FC16 must be split into two registers in the word order the instrument expects (ABCD or CDAB), and a scaled value must be multiplied before sending: a set-point of 45.00 Hz in a register scaled 0.01 Hz is written as 4500.
Worked Example: Changing a VFD Speed Set-Point
A pump’s VFD accepts its frequency reference in holding register 2001 (protocol address 2000, 0x07D0) in units of 0.01 Hz, slave ID 1. Operations wants it moved from 50.00 Hz to 45.00 Hz from the dashboard.
- Convert the value: 45.00 Hz × 100 = 4500 = 0x1194.
- Encode:
encodeDownlink({ slaveId: 1, fc: 6, register: 0x07D0, value: 0x1194 })returns the bytes for FPort 8. Assembled by hand for an FC06 write the core fields are01 06 07 D0 11 94: slave 1, function 6, address 0x07D0, value 0x1194. [VERIFY the LX1 encoder’s exact framing before publishing.] - Enqueue on FPort 8 (steps below). On the Class C DC converter the write happens within seconds; on a Class A unit, after its next uplink.
- Read back: enqueue a read-once on FPort 13 for register 0x07D0. The next uplink carries 0x1194; the dashboard shows 45.00 Hz. If the VFD rejected the write (out of range, or in local mode), the read-back shows the old value or the uplink carries a Modbus exception, and you know within one cycle.
- Log it: who sent the command, when, the value, and the read-back result.
The same pattern changes a chiller set-point, a DG controller’s mode, an irrigation valve’s open time, or a streetlight dimming level, as long as the instrument exposes it as a writable register.
Enqueueing the Downlink
ChirpStack v4. Open the device, go to the Queue tab, enter the FPort (8 for a register write), paste the payload as hex or base64, tick Confirmed if you want a MAC-level acknowledgement, and enqueue. From software, publish to the MQTT topic application/{applicationId}/device/{devEUI}/command/down with a JSON body containing fPort, data (base64) and confirmed, or use the gRPC/REST API. The generic device steps are in How to Connect a LoRaWAN Sensor to ChirpStack.
The Things Stack. Open the end device, go to Messaging and then Downlink, set the FPort and payload, choose Push (append) or Replace for the queue, and schedule. From software, use the MQTT integration’s down/push topic or the HTTP webhook’s downlink endpoint, with the device’s downlink API key.
ThingsBoard, Node-RED and others. ThingsBoard sends an RPC to the device through the integration’s downlink converter, which builds the same payload; Node-RED on a Macnman gateway publishes to the ChirpStack topic directly, which is how a local rule (tank full → close valve) runs without the cloud. Protocol considerations are in MQTT vs HTTP for IoT Sensors.
Confirming the Command Took Effect
A confirmed downlink proves the converter received the bytes; it does not prove the instrument accepted the write. Three layers of confirmation, use at least two:
- LoRaWAN acknowledgement (confirmed downlink): the converter’s next uplink carries an ACK bit. Cheap; tells you the radio link worked.
- Modbus response: the converter received the instrument’s reply to the write (or an exception). Some converters report this in an uplink; check the LX1’s uplink for a write-status field. [VERIFY.]
- Read-back: a read-once of the same register, compared with the value sent. This is the only one that proves the set-point is in the instrument.
Design commands to be idempotent (sending “set to 45.00 Hz” twice is harmless; sending “increase by 5 Hz” twice is not), and never assume a single downlink was delivered: the gateway may have been transmitting, or the receive window may have been missed. Automations should send, read back, and retry once before raising an alarm.
What LoRaWAN Control Is For, and What It Isn’t
| Use case | Command | Class | Feedback |
|---|---|---|---|
| VFD or pump speed set-point | FC06 write | C | Read-back |
| Chiller or HVAC set-point | FC06 write | C | Read-back |
| Irrigation valve open/close | Coil or relay | C | Status uplink |
| Streetlight dimming schedule | FC06 or FC16 | C | Read-back |
| DG set mode, non-safety | FC06 write | C | Status uplink |
| Energy meter tariff or reset | FC06 / FC16 | A | Read-back |
| Inverter curtailment limit | FC16 write | C | Read-back |
| Reporting interval change | FPort 6 | A | Next uplink |
LoRaWAN control is right for commands that are infrequent, tolerant of seconds of delay, and safe to retry. It is wrong for anything that needs a closed loop faster than a few seconds, for emergency stops, for safety interlocks, and for commands whose failure must be known instantly. Those stay in the PLC and the instrument’s own protections, with LoRaWAN carrying the set-points and the status. A relay that drives a pump should still have local overload and dry-run protection; the downlink only asks for the pump to run.
Security of Remote Control
Downlinks are encrypted and integrity-checked by LoRaWAN, so the risk is not interception; it’s authorisation. Anyone who can enqueue a downlink on the application can write to the bus. Keep control devices in their own application with restricted roles; log every command with the user; limit which registers the platform can write (a server-side allowlist, and, where the converter supports it, a device-side one); and keep the converter’s keys regenerated when a unit changes hands. Configuration of keys and access is covered in How to Configure a LoRaWAN Sensor.
Step-by-Step: From Zero to the First Write
- Choose the hardware. A DC-powered converter set to Class C for anything interactive; a battery Class A converter where a delay of one reporting interval is acceptable. For relay outputs rather than Modbus writes, a Class C LoRaWAN controller.
- Register the device on the network server with the right class, and load the decoder and encoder.
- Identify the writable registers in the instrument’s manual: address, type, word order, scaling, and any mode the instrument must be in (many VFDs ignore remote writes unless set to remote or “comms” control).
- Bench-test the write with a USB-RS485 adapter and a polling tool before involving the radio, exactly as in How to Connect a Modbus RS485 Sensor to LoRaWAN.
- Encode and enqueue one command; read back; confirm on the instrument’s display.
- Automate with send-read-back-retry logic in Node-RED or ThingsBoard, and alarms on failure.
- Document the register list, the encoder version and who may send commands.
Mistakes We See
Expecting Class C latency from a battery device. Class A waits for the uplink. Power it, or accept the delay.
Forgetting to set Class C on the server. The device listens; the server still queues for the next uplink.
Trusting the confirmed-downlink ACK as proof of the write. Read it back.
Non-idempotent commands. “Increase by 5” doubles on a retry.
Using the community network for control. 10 downlinks a day won’t run a plant; use a private gateway with its own server.
Putting a safety function on the radio. Interlocks stay local.
Control From the Dashboard, Protect at the Panel
Macnman designs and manufactures LoRaWAN devices in India on the IN865 band. The MacSync LX1 RS485 Modbus to LoRaWAN converter writes holding registers and coils by downlink, reads a register on demand, and runs Class C on its 9–36 V DC variant; the LoRaWAN controller range adds Class C relay outputs for valves, pumps and lighting. Both work with the Setu LX indoor and MacLink Gen-2 outdoor gateways, which run ChirpStack and Node-RED on board so local control rules keep working when the internet doesn’t. Encoders and decoders are published in the MacnMan LoRaWAN decoders repository; the full LoRaWAN product range is on the main site.
Want to control something specific? Tell us the instrument, the registers or relays involved, and how quickly a command must take effect, and a product engineer will recommend the converter or controller, the class, and the encoding within one working day: contact Macnman. To try a write-and-read-back on your own panel, order a pilot kit.
Frequently Asked Questions
How do I control an RS485 device over LoRaWAN?
Use an RS485 to LoRaWAN converter that supports Modbus writes by downlink. Encode the write (slave ID, register, value) with the converter’s downlink encoder, enqueue it on the network server on the converter’s write FPort, and confirm with a read-back of the register. Use a Class C, DC-powered converter for commands that must apply within seconds.
What is LoRaWAN Class C?
A device class that keeps its receiver open continuously except while transmitting, so downlinks arrive within a second or two instead of waiting for the device’s next uplink. It needs mains or DC power because the receiver draws current all the time.
What is the difference between Class A and Class C?
Class A listens only in two short windows after each uplink, so a command waits for the next transmission, minutes on a typical battery device. Class C listens continuously, so a command arrives almost immediately, at the cost of continuous receiver power.
How long does a LoRaWAN downlink take to arrive?
On Class C, about one to three seconds including server scheduling. On Class A, up to one reporting interval: with a 15-minute heartbeat, up to 15 minutes and 7½ on average.
Can I control a device in real time over LoRaWAN?
Not in the control-loop sense. LoRaWAN suits set-points, schedules, mode changes and occasional relay commands with seconds of latency and retries. Fast loops, emergency stops and safety interlocks stay local in the PLC or instrument.
How many downlinks can I send?
On a private network, as many as the gateway’s duty cycle and half-duplex capacity allow, bearing in mind that every downlink blinds the gateway for its airtime. On The Things Network’s community network, the fair use policy allows 10 per device per day.
How do I know the write worked?
Read the register back. A confirmed downlink only proves the converter received the bytes; the read-back proves the instrument holds the new value.
Can a battery-powered converter use Class C?
It can be configured to, but the continuous receiver would exhaust the battery in months. Use the DC variant for Class C and keep battery units on Class A.
Can I write 32-bit values or several registers at once?
Yes, with FC16 (write multiple registers), splitting the value into two registers in the instrument’s word order and multiplying by the instrument’s scaling factor before sending.
Is remote control over LoRaWAN secure?
The link is AES-encrypted and integrity-checked. The risk is who can enqueue commands: restrict platform roles, keep control devices in a separate application, log every command, and allowlist writable registers.
