LoRaWAN Fundamentals · Manufacturing & Process Plants

How to Connect a LoRaWAN Sensor to ChirpStack (v4 Guide, IN865)

LoRaWAN
How to Connect a LoRaWAN Sensor to ChirpStack (v4 Guide, IN865)

How to Connect a LoRaWAN Sensor to ChirpStack: Step-by-Step Guide (v4, IN865)

Short Answer

To connect a LoRaWAN sensor to ChirpStack v4, you need five things in place: a gateway online in ChirpStack, a device profile set to the sensor’s LoRaWAN version and region (IN865 in India), a payload codec on that profile, an application, and the sensor registered under it with its DevEUI, JoinEUI and AppKey. Power the sensor, watch it join in the device’s Events tab, and read the decoded data over MQTT or an HTTP integration.

The order that works:

  1. Confirm the gateway is online.
  2. Create a device profile (one per sensor model).
  3. Paste the sensor’s codec into the profile.
  4. Create an application.
  5. Add the device with its OTAA keys.
  6. Power on, confirm the join and the first decoded uplink.
  7. Connect your dashboard over MQTT or HTTP.

This guide uses ChirpStack v4 on the IN865 band. Differences from v3 are covered near the end.

Before You Start

What you need:

  • ChirpStack v4 installed and reachable, in the cloud or on a local server. Installation itself is covered in the ChirpStack documentation.
  • A LoRaWAN gateway configured for the IN865 band and pointed at your ChirpStack server. One Macnman indoor or outdoor gateway covers most sites.
  • The sensor’s identifiers: DevEUI, JoinEUI (also called AppEUI) and AppKey. On Macnman sensors these are pre-provisioned and printed on the device.
  • The sensor’s payload decoder from the manufacturer. Macnman publishes decoders in the LoRa Module SDK on GitHub.
  • The sensor’s LoRaWAN version and class from its datasheet. The MacSync LTS X1, for example, runs LoRaWAN 1.0.4, Class A, OTAA.

A note on ChirpStack’s structure: v4 is organised as tenants → applications → devices, with device profiles and gateways belonging to the tenant. If you run one private network, you’ll use a single tenant.

Step 1: Confirm the Gateway Is Online

No sensor can join if the gateway isn’t forwarding to ChirpStack.

  1. In ChirpStack, open Gateways. Your gateway should show a recent “last seen” time.
  2. If it isn’t listed, click Add gateway, enter the Gateway EUI from its label or web interface, and save.
  3. Make sure the gateway’s packet forwarder is configured for the IN865 channel plan and points to your ChirpStack server. Gateways connect either over the Semtech UDP protocol or Basics Station; both go through the ChirpStack Gateway Bridge.

For IN865, the gateway should listen on at least the three default channels: 865.0625, 865.4025 and 865.985 MHz. If you’ve added extra channels on the gateway, the same channels must be set in the ChirpStack region configuration.

Step 2: Create a Device Profile

A device profile tells ChirpStack how a sensor model behaves. Create one per sensor model, not per device.

Go to Device profiles → Add device profile and fill in:

FieldWhat to setNotes
Namee.g. MacSync LTS X1 – IN865Include the model and region
RegionIN865Must match the gateway and the sensor’s firmware
MAC versionFrom the datasheet, e.g. LoRaWAN 1.0.4A mismatch breaks the join
Regional parameters revisionUsually the latest for your MAC versionKeep the default unless the datasheet says otherwise
ADR algorithmDefault LoRa ADRKeep ADR on for fixed sensors
Expected uplink intervalYour reporting interval in seconds, e.g. 900Used for device status
Device supports OTAAOnMacnman sensors use OTAA
Device supports Class B / Class COff for battery Class A sensorsTurn on Class C only for mains-powered Class C devices

Leave the Join tab defaults unless you run a separate join server.

Why one profile per model: the codec, class and MAC version are properties of the model, so a single profile serves every unit you install. Fifty temperature sensors share one profile.

Step 3: Add the Payload Codec

Without a codec, ChirpStack delivers the sensor’s data as raw bytes. The codec turns those bytes into named fields such as temperature and humidity.

  1. Open the device profile you just created and go to the Codec tab.
  2. Set Payload codec to JavaScript functions.
  3. Paste the manufacturer’s decoder in full and click Submit.

In ChirpStack v4 the codec lives on the device profile, so it automatically applies to every device using that profile. The function ChirpStack calls is decodeUplink(input), where input.bytes is the payload and input.fPort is the port the sensor sent on.

Here’s a trimmed example built on the MacSync-L temperature and humidity sensor’s heartbeat uplink, which arrives on port 2 as 10 bytes: an error flag, temperature ×100 (signed, two bytes), humidity ×100 (signed, two bytes), battery percentage, and a 4-byte UTC timestamp:

function decodeUplink(input) {
  var b = input.bytes;
  var data = {};

  // Signed 16-bit, big-endian
  function s16(hi, lo) {
    var v = (hi << 8) | lo;
    return (v & 0x8000) ? v - 0x10000 : v;
  }
  // Unsigned 32-bit, big-endian
  function u32(a, c, d, e) {
    return ((a << 24) | (c << 16) | (d << 8) | e) >>> 0;
  }

  // Port 2: periodic heartbeat, 10 bytes
  if (input.fPort === 2 && b.length === 10) {
    data.type        = "heartbeat";
    data.temperature = s16(b[1], b[2]) / 100;   // °C
    data.humidity    = s16(b[3], b[4]) / 100;   // %RH
    data.battery     = b[5];                    // %
    data.timestamp   = u32(b[6], b[7], b[8], b[9]); // UTC seconds
    return { data: data };
  }

  return { data: data, warnings: ["Unhandled port or length"] };
}

Three details matter in every decoder:

  • Signed values. Temperatures below zero arrive in two’s complement. Decode them as signed, or every freezer will read as +600 °C.
  • Scaling. Values are sent as integers (here ×100) to avoid floating point. Divide to recover the real reading.
  • Ports. Many sensors use different ports for different message types (boot, heartbeat, alarms). Decode by port, and handle lengths you don’t expect gracefully.

Paste the full manufacturer codec rather than a trimmed one in production. The complete MacSync-L codec also handles the boot message on port 5, alarm and clear events on port 4, multi-sample batches on port 3, and downlink encoding for configuration.

Step 4: Create an Application

An application groups devices and holds the integrations that send their data onward.

  1. Go to Applications → Add application.
  2. Give it a name, e.g. Cold Store – Building A, and save.

Group devices by site or by the system that consumes the data, since integrations are set per application.

Step 5: Add the Device

This is where the sensor’s identity and keys go.

  1. Open the application and click Add device.
  2. Enter the Device EUI from the sensor’s label, a name, and select the device profile from Step 2.
  3. Save, then open the OTAA keys tab.
  4. Enter the Application key (AppKey). In v4 the JoinEUI is entered on the device as well; use the value from the device label.
  5. Save.

Copy keys from the physical label or QR code. Most “won’t join” problems are a single mistyped character.

Step 6: Power On and Verify the Join

Watch the join happen, then confirm the first decoded uplink.

  1. Open the device and go to the LoRaWAN frames or Events tab.
  2. Power on the sensor, or trigger a join from its configuration app. Macnman sensors can be joined and configured from the Maya app over Bluetooth.
  3. You should see a join request, then a join accept, within a minute or two.
  4. The next uplink should appear under Events with an object field containing your decoded data, for example temperature: 24.3, humidity: 58.1, battery: 97.

If the join succeeds but the object field is empty, the codec is missing or on the wrong profile. If there’s no join request at all, see the troubleshooting table below.

Step 7: Get the Data Out of ChirpStack

ChirpStack publishes every decoded uplink to MQTT, and can push it to HTTP endpoints and cloud platforms through application integrations.

MQTT (always on). ChirpStack publishes events to its MQTT broker on topics like:

application/<application-id>/device/<dev-eui>/event/up

Subscribe with any MQTT client to see JSON containing the device info, radio metadata (RSSI, SNR, spreading factor) and your decoded object. From here the data can go into Node-RED, a time-series database, or a SCADA bridge.

Integrations (per application). In the application’s Integrations tab you can add:

  • HTTP: posts each event to a URL on your server
  • InfluxDB: writes decoded fields straight into a time-series database
  • AWS SNS, Azure Service Bus, GCP Pub/Sub: for cloud pipelines
  • ThingsBoard: connects directly to a ThingsBoard dashboard

Which one to pick depends on where the dashboard lives. If you’re building on ThingsBoard, use its integration. If you have your own backend, HTTP or MQTT is simplest.

ChirpStack v3 vs v4: What Changed for Sensor Onboarding

If you’re following older vendor guides, three differences cause most of the confusion.

-ChirpStack v3ChirpStack v4
StructureSeparate Network Server and Application Server; organisations and service profilesSingle ChirpStack service; tenants, with device profiles and gateways under the tenant
Codec functionDecode(fPort, bytes)decodeUplink(input) returning { data: ... }
Where the codec livesDevice profile (Application Server)Device profile (tenant)
RegionsOne region per Network Server instanceMultiple regions in one instance; pick the region in the device profile

If a manufacturer’s decoder file contains both a Decode(fPort, bytes) function and a decodeUplink(input) function, v4 uses only decodeUplink. Many vendors, Macnman included, ship both so one file works on either version.

Troubleshooting: Sensor Won’t Join or Won’t Show Data

What you seeMost likely causeFix
No join request in the gateway’s framesGateway offline, wrong region on the gateway, or the sensor isn’t an IN865 LoRaWAN deviceCheck the gateway’s last-seen time and channel plan; confirm the sensor is on IN865 and runs LoRaWAN firmware
Join request appears, no join acceptWrong DevEUI, JoinEUI or AppKey; MAC version mismatch in the profileRe-enter keys from the label; set MAC version from the datasheet
“MIC invalid” errorsWrong AppKey, or the device was registered twiceCorrect the key; delete duplicate registrations
Joins, but uplinks stop after the first fewChannel mismatch, or weak downlink so ADR/channel commands aren’t receivedMatch extra channels between gateway and region config; improve signal
Uplinks arrive, object is emptyNo codec, or codec on a different profileAdd the codec to the profile the device uses
Decoded values look wrong (e.g. 655 °C)Signed/unsigned or scaling error in the decoderUse the manufacturer’s current decoder for your firmware version
Nothing arrives at the dashboardIntegration not configured, or MQTT topic wrongCheck the application’s Integrations tab and topic names

Signal problems are easiest to catch at installation. Macnman sensors show RSSI, SNR and a link check result in the Maya app, so you can confirm coverage before mounting; see Built-In LoRaWAN RF Testing. If a sensor labelled “LoRa” refuses to join at all, read Will a LoRa Sensor Work With Your LoRaWAN Gateway?

Scaling Up: From One Sensor to a Site

Once one sensor works, the rest is repetition. For larger deployments:

  • Bulk import. ChirpStack supports adding devices in bulk via its API or CSV-style imports, which saves time for 50+ sensors.
  • Device-profile templates. ChirpStack can import device profiles, including codecs, from the LoRaWAN device repository, so popular sensors arrive pre-configured.
  • Multicast and FUOTA. For fleets that need firmware updates over the air, plan multicast groups early.
  • Monitoring. Enable periodic device-status requests so battery and signal trends appear in ChirpStack; see LoRaWAN Link Check.
  • Regulatory settings. Keep transmissions within India’s 865–868 MHz rules; see LoRaWAN in India: IN865 and WPC Rules.

ChirpStack-Ready Sensors from Macnman

Macnman designs and manufactures LoRaWAN sensors in India, built for the IN865 band and tested with ChirpStack:

  • Pre-provisioned keys. Every sensor ships with its own DevEUI, JoinEUI and AppKey, ready to enter.
  • Published decoders. Full decodeUplink and downlink codecs for each product are in our GitHub SDK.
  • Configured from one app. Join, reporting interval, thresholds and RF checks are all done from the Maya app over Bluetooth.

Browse the LoRaWAN sensor range, including the MacSync LTS X1 temperature and humidity sensor, the RS485 to LoRaWAN converter for Modbus instruments, and our LoRaWAN gateways.

Setting up your first ChirpStack network? Order a pilot kit with sensors and a gateway, or request a quote. A product engineer will help you onboard your first devices and reply within one working day.

Frequently Asked Questions

Do I need a separate device profile for each sensor?
No. Create one device profile per sensor model and region. The profile holds the LoRaWAN version, class, region and codec, so every unit of that model shares it. A site with 50 identical temperature sensors needs one profile.

Where do I put the payload decoder in ChirpStack v4?
On the device profile, under the Codec tab. Set “Payload codec” to “JavaScript functions” and paste the full decoder. It then applies to every device using that profile.

Why does my sensor join ChirpStack but show no decoded data?
Either no codec is set on the device profile, or the device is using a different profile from the one with the codec. Open the device, check its profile, and confirm the codec is present there.

Why won’t my sensor join ChirpStack?
The most common causes are mistyped keys, a MAC version in the device profile that doesn’t match the sensor, a region mismatch (for example an EU868 sensor on an IN865 network), or the gateway not forwarding. Check the gateway’s last-seen time first, then the keys, then the profile.

Which region should I select in ChirpStack for India?
IN865. The gateway, the device profile and the sensor firmware must all use it.

How do I get sensor data from ChirpStack to my dashboard?
ChirpStack publishes every decoded uplink to MQTT on application/<id>/device/<deveui>/event/up. You can also add an HTTP, InfluxDB, ThingsBoard or cloud integration under the application’s Integrations tab.

What is the difference between Decode and decodeUplink?
Decode(fPort, bytes) is the ChirpStack v3 codec function. decodeUplink(input) is the v4 function, which receives input.bytes and input.fPort and returns { data: ... }. Many vendor decoder files include both.

Can I use sensors from different manufacturers on one ChirpStack server?
Yes. Create a device profile with the right codec for each model. Any LoRaWAN-compliant sensor on the same region works with the same gateways and server.

Can ChirpStack run without internet?
Yes. ChirpStack can run on a local server or even inside a gateway, with sensors and gateways on the same local network. Internet is only needed if your dashboard or cloud integration is remote.

Does ChirpStack support IN865 duty-cycle limits?
ChirpStack enforces regional parameters and can be configured with your channel plan. Keep reporting intervals and downlinks within India’s limits for your device category; our India regulations guide covers the figures.

On this page

WhatsAppLinkedInEmail
products image macnman
Got an IoT idea?

Let’s bring it to life!

Let‘s Make it Easy

Reach Out Now

Icon

Contact to Sales

Talk to our friendly team

chat@macnman.com
Icon

Call Us

24 X 7 Always On

+91 7972856163
Icon

Contact to Support

We are here to help

support@macnman.com
Icon

Visit Us

Visit our office HQ

View on Google Map

Socials

LoRaWAN

4G IoT

WiFi Ble IoT

Nb IoT

Customize

Maya

Documentation

Case Studies

Blogs