Learn how to build a Modbus client using RAK WisBlock and Blues Notecard with LoRaWAN and cellular connectivity for industrial IoT applications.
Modbus is one of the most widely used communication protocols in industrial automation due to its simplicity, reliability, and long-standing adoption. Built on the RS-485 physical layer, it enables stable data exchange over long distances, making it suitable for connecting sensors, meters, and industrial controllers in demanding environments.
As industrial systems increasingly require remote monitoring and analytics, securely transmitting Modbus data to cloud platforms becomes essential. IoT technologies such as LoRaWAN and cellular networks provide scalable and cost-effective connectivity, enabling industrial data to be collected, visualized, and analyzed in real time from remote locations.
This tutorial replicates a project originally developed by Blues Wireless and extends it using RAK WisBlock modular hardware. A button and LED are included for interface functionality. By the end of this guide, you will be able to transmit it wirelessly using LoRaWAN or NB-IoT.
- Modular hardware simplifies the transition from prototype testing to enclosure-ready industrial deployment.
- Power stability directly affects cellular reliability; insufficient current can cause transmission
- Payload decoding determines whether cloud dashboards display meaningful Modbus register values.
- Local Modbus emulation accelerates development before integrating real industrial equipment.
- Connectivity choice depends on available infrastructure and account configuration.
- Firmware flexibility enables adaptation to different Modbus register maps and devices.
- Cloud visualization provides operational insight beyond simple device-level communication.
System Design Overview
The goal of this project is to present a ready-to-use product for implementation in an industrial setting. This tutorial replicates the project developed in the Blues Wireless accelerator, which features a useful prototype for building a cellular Modbus client.
The reference project uses Adafruit components and retrieves Modbus signals from a locally emulated server using Pymodbus. The implementation is extended to create a final product capable of receiving data from any device connected via the Modbus protocol. Testing can be performed using another circuit or a Raspberry Pi to emulate the Modbus server.
Integration with WisBlock modular hardware addresses the limitations of the prototype by enabling a cleaner configuration and enclosure-ready deployment. The original version did not utilize an IoT platform for visualization; this implementation incorporates Ubidots to provide real-time monitoring and an improved user experience. Finally, LoRaWAN communication is included as an optional connectivity method, offering users more connectivity options.
Hardware Requirements
Necessary Hardware
- WisBlock Baseboard RAK19001
- WisBlock Core RAK4631
- WisBlock RS485 Module
- Unify Enclosure IP67 150x100x45mm
- WisBlock Blues Carrier Module RAK13102
- LiPo Battery
- Blues Notecard (Select one according to your location)
- Blues Notecarrier A, B or F (Optional)
Figure 2: Required Hardware Components
Gateway
- RAK7268V2 WisGate Edge (used in this guide)
Back-End Services
Hardware Assembly and RS-485 Wiring
The hardware adopts a modular approach provided by WisBlock. The complete firmware is developed and available in the RAKWireless Tutorial GitHub for Modbus Client, and the IoT data visualization platforms are cloud-ready. The implementation replicates the project developed by Blues Wireless using JSON data to access the information.
Connecting the WisBlock elements is straightforward:
Insert the WisBlock Core (RAK4631) into the core slot of the RAK19001 baseboard. Other compatible cores are available from the RAKwireless WisBlock baseboards.
Install the RAK5802 module into an available IO slot on the RAK19001 baseboard.
Connect the Blues Notecard via the WisBlock Blues Carrier Module, and insert it into an IO slot on the baseboard.
Mount the assembled hardware inside the Unify Enclosure IP67 150x100x45mm for deployment.
Now that the devices are connected, you can begin programming.
The Blues Notecard requires a peak current of 2 A to send data. The VDD pin of the WisBlock cannot provide this current, so it is recommended to use a battery or connect an additional USB cable to the Notecard during your project testing.
RS-485 Deployment Notes
For reliable Modbus RTU communication, use twisted-pair shielded cable and maintain a common ground reference between connected devices. Route communication lines away from high-voltage or high-current wiring to reduce electrical noise.
Improper termination, grounding, or shielding can lead to CRC errors, intermittent timeouts, or unstable Modbus communication even when firmware settings are correctly configured.
Blues Hardware Assembly
After completing the instructions outlined in the hardware configuration and uploading the code provided by Blues on GitHub to the notecard, the final assembly is shown in the image below:
Firmware Development and Configuration
The code can be downloaded from the RAKWireless Modbus Client Code Repository. It was developed using Visual Studio Code and PlatformIO, which are two widely used tools for programming firmware.
In case the libraries are not available on Platform IO, you can find them from the following sources:
If you need more information about how to configure and code your WisBlock setup with Platform IO, check the following guide for Setting up WisBlock on PlatformIO.
Cloud Integration and Data Flow
This section explains how Modbus data from the RAK4631 is transmitted to the cloud using either LoRaWAN or cellular connectivity. Each path requires proper network configuration and decoding to ensure that register values are accurately displayed in Ubidots.
End-to-End Data Flow Architecture
This project supports two cloud paths:
LoRaWAN
Cellular
For LoRaWAN, TTN applies the payload decoder and forwards the structured JSON to Ubidots via a webhook. For cellular connection, the Blues Notecard sends structured data to Notehub, which then routes it to Ubidots
Authentication operates independently at each layer:
LoRaWAN devices authenticate to TTN using Over-The-Air Activation (OTAA).
TTN employs a Ubidots API token for webhook delivery.
The Notecard authenticates to Notehub using its device UID.
The firmware reads Modbus registers and formats the payload. TTN or Notehub manage routing and delivery, while Ubidots stores and visualizes the resulting data.
LoRaWAN Configuration (TTN)
The process of communicating with end devices via LoRaWAN networks can be accomplished through a public network like Helium or by setting up your network using a gateway for LoRaWAN. In this instance, configure the second option. For this process, you will need:
This process is straightforward and can be completed in just a few minutes. For a step-by-step configuration guide, refer to the RAK7268V2 gateway documentation.
After the successful configuration and connection of the gateway to the TTN LNS, use the given payload decoder.
TTN Payload Decoder
async function formatPayload(args){
var ubidots_payload = {};
// Log received data for debugging purposes:
// console.log(JSON.stringify(args));
// Get RSSI and SNR variables using gateways data:
var gateways = args['uplink_message']['rx_metadata'];
for (const i in gateways) {
// Get gateway EUI and name
var gw = gateways[i];
var gw_eui = gw['gateway_ids']['eui'];
var gw_id = gw['gateway_ids']['gateway_id'];
// Build RSSI and SNR variables
ubidots_payload['rssi-' + gw_id] = {
"value": gw['rssi'],
"context": {
"channel_index": gw['channel_index'],
"channel_rssi": gw['channel_rssi'],
"gw_eui": gw_eui,
"gw_id": gw_id,
"uplink_token": gw['uplink_token']
}
}
ubidots_payload['snr-' + gw_id] = gw['snr'];
}
// Get Fcnt and Port variables:
ubidots_payload['f_cnt'] = args['uplink_message']['f_cnt'];
ubidots_payload['f_port'] = args['uplink_message']['f_port'];
// Get uplink's timestamp
ubidots_payload['timestamp'] = new Date(args['uplink_message']['received_at']).getTime();
// If you're already decoding in TTS using payload formatters,
// then uncomment the following line to use "uplink_message.decoded_payload".
// PROTIP: Make sure the incoming decoded payload is an Ubidots-compatible JSON (See https://ubidots.com/docs/hw/#sending-data)
// var decoded_payload = args['uplink_message']['decoded_payload'];
// By default, this plugin uses "uplink_message.frm_payload" and sends it to the decoding function "decodeUplink".
// For more vendor-specific decoders, check out https://github.com/TheThingsNetwork/lorawan-devices/tree/master/vendor
let bytes = Buffer.from(args['uplink_message']['frm_payload'], 'base64');
var decoded_payload = decodeUplink(bytes)['data'];
// Merge decoded payload into Ubidots payload
Object.assign(ubidots_payload, decoded_payload);
return ubidots_payload
}
function decodeUplink(bytes) {
// Decoder for the RAK1906 WisBlock Environmental Sensor (https://store.rakwireless.com/products/rak1906-bme680-environment-sensor)
var decoded = {};
if (bytes[0] == 1) {
// If received data is of Environment Monitoring type
decoded.holding_register = (bytes[0] << 8 | (bytes[1]));
decoded.input_register = (bytes[2] << 8 | (bytes[3]));
decoded.coil_value = (bytes[4]);
}
return {"data": decoded};
}
module.exports = { formatPayload };Cellular Configuration (Blues Notecard & Notehub)
Create an account on the Notehub page and then create a new project. For a detailed guide, you can review the Blues documentation to see the process step by step.
Blues Payload Decoder
This payload decoder is used when the transmitted data is sent via the Blues Wireless hardware.
{
"coil": {"value": body.coil},
"holdingRegister": {"value": body.holdingRegister},
"inputRegister": {"value": body.inputRegister}
}Ubidots Connection
The Blues Accelerator executes business logic through Notehub and the Notecard. While effective, this design makes it harder to scale to other networks and can be limiting for users who need a more visual, user-friendly way to access data.
To address this, Ubidots is used to visualize data collected by the WisBlock client from a Modbus server. Ubidots provides dashboards that allow users to easily monitor and interpret the collected values.
Using the PyModbus library, a server is emulated with:
100 coils
100 discrete inputs
100 holding registers
100 input registers.
The firmware provides functions to access all registers and inputs. For demonstration, a coil, a holding register, and an input register are read. These values are initialized to 0, 66, and 33. After the data is read, the final result appears in Ubidots, as shown in the figure below.
The final solution deployed and working is presented in the following image:
Deployment Considerations
A Raspberry Pi running Pymodbus emulates a Modbus server that provides register data for testing and cloud transmission.
The implementation can be used with real Modbus-compatible devices by adjusting the firmware to match the target device’s register map.
Strengths of Working with WisBlock
Production-Ready: Not just a prototype, this is a finished product ready for real-world use.
Modular Design: Easy and fast to set up thanks to WisBlock’s plug-and-play modular architecture.
Clean & Professional: Results in a polished and compact final product with minimal assembly.
Developer-Friendly Firmware: Compatible with Arduino and PlatformIO; no need for complex IDEs.
Multi-Network Communication: Supports LoRaWAN and cellular (NB-IoT, LTE-M, CAT-1) connectivity.
Quick Integration with Dashboards: Easily connected to IoT platforms; no advanced front-end/backend coding required.
Space-Efficient: Small form factor ideal for installations with limited space.
Stock Notice: Some components used in Blues' reference solution may no longer be available.
Summary
RAK WisBlock offers a flexible modular hardware solution for industrial IoT projects, enabling integration of Modbus devices with cloud platforms. Using the RAK4631 WisBlock Core, RS-485 communication, and the Blues Notecard, the system reliably collects Modbus data and transmits it wirelessly via LoRaWAN or cellular networks.
This architecture allows industrial devices to connect to cloud services such as TTN, Notehub, and Ubidots, supporting real-time monitoring, visualization, and data analysis without custom PCB development. Its modular design and prebuilt firmware accelerate deployment, while Arduino and PlatformIO compatibility ensures a developer-friendly workflow.
FAQs
Why is my RAK4631 not receiving any Modbus data over RS-485?
The RAK4631 WisBlock Core operates as a Modbus RTU client over RS-485. Communication requires matching serial parameters, including baud rate, parity, and stop bits. Incorrect settings can cause repeated timeouts or no response.
The firmware must also use the correct slave address and function code (0x01 for coils, 0x03 for holding registers, 0x04 for input registers). Always verify wiring, serial configuration, slave ID, and register type before assuming firmware failure.
Why do I get timeouts or intermittent Modbus communication?
Timeouts usually indicate that the Modbus server did not respond within the configured polling window. Causes include incorrect slave address, serial mismatch, or electrical noise on the RS-485 bus.
Each Modbus RTU frame contains a CRC-16 checksum. If validation fails, the frame is discarded. Intermittent communication often results from wiring issues, missing termination, or unstable grounding.
Why are my Modbus register values always zero or incorrect?
Incorrect values often result from polling the wrong register address or using the wrong function code. For example, reading a holding register with a coil function will return unexpected data.
In development, a Raspberry Pi running Pymodbus may initialize registers to default values such as 0, which appear valid but misleading. Multi-byte values must be interpreted consistently. Confirm the register map, polling interval, and register type configuration.
Why does the Blues Notecard reset or fail during cellular transmission?
The Blues Notecard can draw up to 2 A peak current when transmitting over cellular networks. The WisBlock VDD pin cannot supply this current, which may cause resets or failed transmissions.
Use a LiPo battery or a dedicated USB source during testing and deployment. This is an electrical limitation, not a firmware issue, and ensures reliable NB-IoT or LTE-M communication.
My device joins TTN but no data appears in Ubidots. What should I check?
If the RAK7268V2 WisGate Edge forwards data to TTN but Ubidots shows no updates, the issue is usually decoder-related. The TTN payload decoder must correctly parse the raw frm_payload and output properly structured JSON fields.
If register values are not decoded correctly, Ubidots will not display meaningful variables. Verify that the correct decoder is active, confirm the expected FPort is used, and ensure that decoded fields match Ubidots variable naming. Always validate the raw uplink payload in TTN before adjusting cloud configuration.
When should I use LoRaWAN versus cellular in this architecture?
|
|
Harold Duarte Harold is an electronics engineer and senior technical content writer at RAKwireless. He is passionate about learning and developing new solutions for IoT, making it #IoTMadeEasy. |
Changelog
-
Version 1 - Cellular and LoRaWAN Modbus Client with RAK WisBlock
and Blues Notecard
- Author: Harold Duarte
- Reviewer: Karla Jimenez
- Date Published: 30/03/2026
Updated