Connect a LoRaWAN Device to Blynk via LORIOT

Skip the middleware. Connect your LoRaWAN sensors directly to Blynk via LORIOT. Build your payload decoder and launch a live dashboard in 6 easy steps.

Published

Author

Turning a LoRaWAN Sensor Into a Working Product | Blynk + LORIOT Webinar Replay

Step-by-step guide

LoRaWAN devices can reach sensors kilometers away on a coin cell battery. But they don't talk to the cloud directly. They need a gateway and network server in the middle.

This tutorial shows you how to connect any LoRaWAN device to Blynk using LORIOT as the network server. Blynk and LORIOT recently partnered to make this integration path as smooth as possible. You'll set up a complete pipeline: your device sends data over LoRaWAN, LORIOT receives it, and Blynk turns it into a live dashboard you can check from anywhere.

The same pattern works for any LoRaWAN sensor. Temperature probes, soil moisture sensors, door contacts, water level monitors. The steps are identical. The only thing that changes is how you decode the payload, and we'll cover that too.

How the pieces fit together

LoRaWAN Device  →  Gateway  →  LORIOT  →  HTTP Push  →  Blynk Data Converter  →  Dashboard
(your sensor)              (radio)          (network    (webhook)          (decodes payload,             (see your
                                                           server)                                  finds your device)               data live)

Your device transmits a small packet over LoRaWAN radio. A nearby gateway picks it up and forwards it to LORIOT. LORIOT manages the network side (encryption, deduplication, device management) and pushes the raw payload to Blynk via HTTP.

The key piece is Blynk's Data Converter. It's a function that:

  1. Reads the incoming payload from LORIOT
  2. Matches it to the right Blynk device using the device's unique identifier
  3. Decodes the sensor data
  4. Updates your Blynk datastream

No custom server, no middleware, no MQTT broker to manage.

What you'll need

Before you start, make sure you have:

  • A Blynk account (Free plan works)
  • A LORIOT account with your device already registered and a gateway in range
  • Your device's unique identifier (devEUI) (check the label on your device, the packaging, or your LORIOT device list)
  • A LoRaWAN device (any sensor or actuator that's registered with LORIOT)

If you don't have a LORIOT account yet, you can sign up at loriot.io.

Step 1: Create a Blynk Template

Templates define what a type of device can do in Blynk: what data it sends, how the dashboard looks, and what metadata it carries. A template is reusable. You create it once, then create as many devices from it as you need. If you have 50 smart buttons, they all share the same template.

Because of this, name your template for the device type, not the individual device. "LoRaWAN Temperature Sensor" or "Milesight WS101" works well. "Office front door sensor" doesn't, because that's a specific device, not a type.

Create the template:

  1. In Blynk.Console, go to Developer Zone > My Templates
  2. Click + New Template
  3. Name it for your device type (e.g., "LoRaWAN Temperature Sensor" or "Milesight WS101")
  4. Set Connection Type to LoRaWAN and Hardware to whatever matches your device
  5. Click Done

Add a datastream:

Datastreams are the channels your device data flows through. We'll start with a single datastream that shows the raw payload from your device. You can add decoded datastreams later once you understand the payload format.

  1. In your template, go to Datastreams
  2. Click + New Datastream and select Virtual Pin
  3. Set Name to "Raw Payload"
  4. Set Pin to V0 (or any available virtual pin)
  5. Set Data Type to String
  6. Leave Units, Min, Max, and Default Value as-is
  7. Click Close to save

The Data Converter references datastreams by name, not by pin number, so the pin assignment doesn't matter for this integration. Just pick the next available one.

Add a metadata field:

Metadata lets Blynk identify which physical device sent each message. We'll use the devEUI as the unique identifier.

  1. Go to Metadata in your template
  2. Add a field named devEui with Type set to Text

Build a simple dashboard:

  1. Click Web Dashboard in the left menu
  2. From the Widget Box, drag a Label widget onto the canvas
  3. Configure it with a title (e.g., "Last Payload") and connect it to the Raw Payload datastream

This is your starting point. Once data is flowing, you'll see the raw hex payload from your device here. Later you can add more widgets for decoded values.

Step 2: Set up the LORIOT HTTP output

Now tell LORIOT where to send data. We'll configure this before the Data Converter so you have the full picture of what payload Blynk will receive.

  1. In your LORIOT application, go to the Application Outputs section
  2. Click Manage outputs
  3. Click Add a new output and choose HTTP Push
  4. You'll need the Endpoint URL from Blynk's Data Converter (next step). Come back here to paste it once you have it.

When LORIOT sends data to Blynk, the payload looks something like this:

{
  "devEui": "70b3d52a1ff00001",
  "timestamp": "2026-01-27T10:21:00Z",
  "payload": "01020304",
  "fPort": 1,
  "rssi": "-73",
  "snr": "10.5",
  "fCntUp": 15794
}

Two fields matter for our Data Converter:

  • devEui: identifies which physical device sent the message
  • payload: the actual sensor data, hex-encoded

Step 3: Create the Blynk Data Converter

The Data Converter runs inside Blynk every time an HTTP message arrives. No external servers needed.

In your template, go to Data Converter and select HTTP.

Paste this code:

function initialize(context) {
  const { handler } = context;
  handler.useAuthMetaField("devEui");
}

function handleRequest(context) {
  const { request, server } = context;
  const { uri, headers, body, isSecure } = request;

  const data = JSON.parse(new TextDecoder().decode(body));

  // Find the Blynk device that matches this devEUI
  const devEui = data.devEui;
  const device = server.authenticateDevice(devEui);

  // Pass through the raw payload
  device.setDataStreamValue('Raw Payload', data.payload);

  return { status: 200, body: 'Datastreams updated' };
}

How it works:

  • `handler.useAuthMetaField("devEui")` tells Blynk to match incoming messages to devices by comparing the `devEui` in the payload against the devEui metadata field you created in Step 1. This is how Blynk knows which device dashboard to update.
  • `server.authenticateDevice(devEui)` looks up the matching Blynk device. If no device has that devEUI in its metadata, the message is ignored.
  • `device.setDataStreamValue()` pushes the raw hex payload to your datastream, which instantly updates the dashboard.

This is intentionally simple. It works for any LoRaWAN device. You'll see the raw hex string on your dashboard, which confirms the full pipeline is working. We'll decode the payload in Step 6.

Copy the Endpoint URL shown in the Data Converter page. You'll need it for the next step.

Step 4: Connect LORIOT to Blynk

Go back to your LORIOT application output (from Step 2) and paste the Blynk Endpoint URL into the Target URL field.

Save the output. LORIOT will now push every uplink message from your device to Blynk.

Step 5: Test it

Trigger your device. For a button, press it. For a sensor, wait for the next scheduled uplink (most sensors send every few minutes). Within a few seconds, you should see the raw hex payload appear on your Blynk dashboard.

For example, a Milesight WS101 Smart Button might show something like `01754BFF2E02`. That's the raw data from the sensor, hex-encoded. It doesn't mean anything to a human yet, but it means the full pipeline is working: device to gateway to LORIOT to Blynk.

Not seeing data? Check these common issues:

  • devEUI mismatch: Make sure the devEUI in your Blynk device metadata matches the one in LORIOT exactly
  • Gateway out of range: Check LORIOT's device page to confirm uplinks are arriving
  • Endpoint URL: Verify you pasted the complete URL from the Data Converter page into LORIOT
  • Datastream name: The name insetDataStreamValue('Raw Payload', ..)must match your datastream name exactly

Step 6: Decode your payload

The raw hex string on your dashboard confirms the pipeline works. Now you need to decode it into something meaningful.

Every LoRaWAN device encodes its payload differently. There's no universal format. A temperature sensor, a door contact, and a smart button all pack their data into hex bytes in their own way. To decode yours, you need to check your device's datasheet or payload documentation. Most manufacturers provide this, and many include example decoders.

Here's what to look for:

  • Payload format documentation in your device's user manual or datasheet
  • Example decoders on the manufacturer's GitHub or support page
  • Channel/type/value structure if your device uses IPSO or LPP-style encoding

Worked example: Milesight WS101 Smart Button

Let's walk through a real payload to show how decoding works. A Milesight WS101 Smart Button sends a payload like `01754BFF2E02`. That encodes two readings: 75% battery and a long press event. The exact byte structure is in the device's payload documentation.

The part we care about is the button event. The hex signature `FF2E` means "button event," and the byte after it tells you the press type: `01` = short, `02` = long, `03` = double.

To decode this in Blynk, update your Data Converter. This is Anthony's original decoder for the WS101:

function initialize(context) {
  const { handler } = context;
  handler.useAuthMetaField("devEui");
}

function handleRequest(context) {
  const { request, server } = context;
  const { uri, headers, body, isSecure } = request;

  const data = JSON.parse(new TextDecoder().decode(body));

  // Authenticate the device
  const devEui = data.devEui;
  const device = server.authenticateDevice(devEui);

  // Get the message payload
  const hexPayload = data.payload.toUpperCase();
  let result = "Unknown";

  // Look for the Button Event signature: FF (Channel) 2E (Type)
  if (hexPayload.includes("FF2E")) {
    const index = hexPayload.indexOf("FF2E");
    // The value is the two characters (1 byte) following "FF2E"
    const buttonValue = hexPayload.substring(index + 4, index + 6);

    switch (buttonValue) {
        case "01":
            result = "Short Press";
            break;
        case "02":
            result = "Long Press";
            break;
        case "03":
            result = "Double Press";
            break;
    }
  }

  // Set the value for your data stream
  device.setDataStreamValue('Smart Button', result);

  return { status: 200, body: 'Datastreams updated' };
}

Note: this uses a datastream named "Smart Button" (String type). If you followed the generic setup in Steps 1-5, rename it in the code to match your datastream, or add a new one.

Now your dashboard shows "Long Press" instead of raw hex.

Adapting for your device

The structure is always the same:

  1. Authentication stays identical. handler.useAuthMetaField("devEui") and server.authenticateDevice() work for any LoRaWAN device. Don't change these.
  2. Add datastreams in your template that match your sensor's outputs (temperature, humidity, door state, etc.)
  3. Write the decode logic based on your device's payload documentation. Parse the hex string, extract the values, convert to readable units.
  4. Push to datastreams with device.setDataStreamValue().
Tip: Most Milesight sensors use the same channel/type/value encoding shown above. The Milesight IoT [payload decoder repository](https://github.com/Milesight-IoT/SensorDecoders) has decoders for all their devices. Other manufacturers typically provide equivalent resources.

What's next

You've got a working LoRaWAN-to-Blynk pipeline. Here's how to make it more useful:

Set up notifications. Go to Automations in Blynk and create a rule based on your decoded datastreams. For example: "When Battery drops below 20%, send me a push notification." Or "When Temperature exceeds 30C, send an email."

Add more sensors. The pattern is the same for any LoRaWAN device on LORIOT. Create a new template, add datastreams for the sensor's readings, write a payload decoder, and connect it. You can run dozens of sensors through the same LORIOT-to-Blynk pipeline.

Build a mobile dashboard. Download the Blynk app (iOS / Android) and you can monitor your devices from anywhere. The mobile dashboard syncs automatically with what you've built on the web.

Try a Blueprint. If you want to skip the manual setup next time, check the Blynk Blueprint library for ready-made templates you can use with LoRaWAN sensors.

Sign up for a newsletter
Get latest news from Blynk
Over 500,000 people already signed up our newsletter.
We never spam.
Thank you!
Your submission has been received.
Oops! Something went wrong while submitting the form.