Writing Modbus Drivers for Monica M&C: Making Devices Speak Our Language
If you are an electrical technician or engineer working in the field of communication networks, and you’ve ever had to write a driver for an industrial protocol, you know it’s a mix of detective work, trial and error, and the occasional moment of pure magic when things just work. With Modbus, it’s no different - except that despite its long history, it still presents challenges one might expect to be resolved by now.
Our Monica M&C system - a comprehensive monitoring and control solution used to manage devices and systems across a range of industries - including industrial automation and SCADA system management, already comes with a built-in Modbus client. So our goal wasn’t about reinventing the wheel - it was about getting that wheel rolling smoothly across a diverse set of devices. To achieve this, we developed a collection of Modbus drivers tailored to support communication with different devices, each with its quirks, data formats, and not always precise documentation.
In this article, we share practical tips and insights together with our experiences gained from developing these drivers within the Monica M&C system.
Why Modbus?
Modbus is like the grandfather of industrial protocols. It’s been around forever, it’s simple, and it just works. You’ll find it everywhere - from power meters to PLCs and even in some legacy devices that refuse to die.
Monica supports two Modbus versions:
- Modbus TCP – For devices communicating over Ethernet
- Modbus RTU – For those still rocking serial connections (yes, RS-485 is still alive and kicking)
Building Modbus Drivers: A Structured Five-Step Approach
Each Modbus device speaks the same protocol but not necessarily the same language. Some expect registers in a specific order, some require offsets, and some just don’t follow the specifications (because, why not?).
Our driver development process followed a structured approach including the following steps:
- Read the device manual (and pray it’s accurate)
Ever had to go through 7-8 separate documentation files, jumping back and forth just to understand what the author really meant? Yeah, do we know this! - Map out the required registers
Holding registers, input registers, coils, and discrete inputs - our drivers define them with simple literals, like in the table below.

- Define transformations
This step includes scaling, bit manipulation, endian swapping, and other fun surprises. Built-in support for offset and scale are helpful but for everything else; Groovy and Python scripting come in handy for handling these cases on the fly.

- Implement polling and request handling
Some devices need constant monitoring, while others wake up only when poked. Monica allows fine-tuning of each parameter to ensure data arrives on time, every time.
- Test, debug, repeat
Because it never works the first time.
The Fun Parts (and Not-So-Fun Parts)
Data Formatting Shenanigans
Ever read a 16-bit register that actually holds two separate 8-bit values? Or a floating-point number split across two registers - but in reverse order? We did.
Thankfully, the Visual Driver Editor in Monica makes it easy to edit register mappings on the fly - or even to add a custom script handling these for you.
Some devices store multiple Boolean values inside a single register, while others store 32-bit values across two 16-bit registers in Little Endian format (because, of course they do). The following image previews how we handle Registers with Groovy scrips.

This kind of scripting saves hours of debugging when dealing with Modbus devices that store data in creative (and sometimes infuriating) ways.
Timeout Tolerance
Some Modbus devices respond like they’re stuck in molasses, while others time out faster than a teenager losing WiFi. Enabling fine-tuning the timeout settings in Monica was key.

Register Auto-Mapping (coming soon)
Right now, we map registers manually, based on documentation (or trial and error). Future versions of our Monica drivers might include auto-detection, making setup even easier.
Conclusion
The End Result? Smooth Communication.
With each new driver, Monica M&C gets better at talking to different Modbus devices, making it more flexible and user-friendly.
The goal is simple: users should focus on their data, not on protocol headaches. This is at least what we deliver with the Modbus adapter implementation in Monica.
How can we collaborate?
Got a Modbus device that needs taming? Or a horror story about registers that made no sense? Our monitoring and control solution could be adapted to your specific needs. It allows you to write your own driver scripts, choose from the existing set of drivers - or we can simply configure it for you in the scope of our engineering support services. For more information contact our customer support.
Conact us
We’d love to her your feedback. Send us a message via Contact us form. Let’s talk! 🚀