Русская версия
How-to · updated 5 December 2026

Modbus RTU to MQTT gateway on Tibbo

The gateway polls devices on an RS-485 line over Modbus RTU and publishes their values to an MQTT broker. Energy meters, thermostats, drives and other Modbus devices show up in SCADA, Home Assistant, Node-RED or a cloud service without a PC on site. Setpoints can be written back over MQTT.

Everything here comes from recipe 01: a TIDE project and an AppBlocks variant under the MIT license, tested on Scancode's hardware.

In short

  • Hardware: Tibbo TPP2(G2) board in a TPB2 enclosure, four Tibbit modules (RS-485 port, terminal block, power supply, power connector), a 12 V adapter.
  • Interfaces: RS-485 as Modbus RTU master, Ethernet with MQTT 3.1.1.
  • Firmware: Tibbo BASIC in TIDE; site settings live in two files. Or the AppBlocks variant with settings in a web console.
  • No PCB design: modules plug into sockets, the enclosure is built around them.

Bill of materials and layout

TPP2(G2) layout: RS-485 Tibbit #05 in socket S1, terminal block #21 in S2, power supply #09 in S11, connector #18 in S12
Socket layout checked by the tps_check script

The layout and power budget were checked by the tps_check script from the Tibbo skills for AI agents: about 205 mA on the 5 V line against 700 mA available from the power supply module, 29% load. Four M sockets stay free for inputs, relays or more RS-485 ports.

In the Scancode catalog (Russia) the Tibbo items cost $308.45 including VAT as of 5 December 2026; the 12 V adapter and the DMK1000 DIN-rail kit are extra. Outside Russia and the CIS, check prices with Tibbo or a local distributor.

  • 1 × TPP2(G2) board
  • 1 × TPB2 enclosure
  • 1 × Tibbit #05, RS-485 port, socket S1
  • 1 × Tibbit #21, 4-terminal block for the RS-485 line, socket S2
  • 1 × Tibbit #09, 5 V supply from 9-18 V, socket S11
  • 1 × Tibbit #18, power jack and 2 terminals, socket S12
  • 1 × 12 V DC adapter, 0.5 A or more
Example. The cabinet only has 24 V: replace #09 with Tibbit #33 (8-60 V input) and keep #18 in S12. #33 costs more but needs no separate 12 V supply. Never connect #09 to 24 V.

Why TPP2(G2)

It is the cheapest board that does the job. CPU and memory are the same as on TPP3(G2); it just has fewer sockets. TPP3(G2) with the TPB3 enclosure costs more and only makes sense if the gateway needs more modules than TPP2 can hold.

Setting up the poll list

Everything site-specific sits in two files. config.tbh holds the network (DHCP or static), broker address and login, topic root, RS-485 speed and parity, and poll period. config.tbs holds the list of points, one line per value: device address, Modbus function, register, data type, divider, point name, and whether MQTT may write to it.

Function 3 reads holding registers, function 4 input registers. Registers are numbered from zero, so 40001 in a device manual becomes 0. Types: U16 and S16 take one register, U32, S32 and F32 take two, high word first. A divider of 10 turns 235 into 23.5. Writing from MQTT works for U16 and S16 with function 3.

MQTT topics

The controller ID in topics is its MAC address in hex, for example 002477517F17.

  • tibbo/<id>/<point name>: controller to broker, the value, for example 23.5
  • tibbo/<id>/<point name>/set: broker to controller, a new value to write (function 6)
  • tibbo/<id>/status: controller to broker, for example online ok=6 err=0 after every poll cycle

Loading the firmware

Install TIDE from tibbo.com, open the project, edit config.tbh and config.tbs and build it. Pick the controller in Device Explorer and run: the firmware loads and starts in debug mode, and the Output window shows the IP address, the broker connection and poll errors. For production, switch the build to Release and load it again.

Troubleshooting

  • Every point fails with error 255: A and B swapped, wrong baud rate or parity, or a wrong device address. Device makers label A and B differently.
  • Error 254: noise on the line. Use shielded twisted pair and terminate both ends. Tibbit #05 revision B already has a 120 Ω terminator.
  • Error 2 or 3: the device does not know that register or function. Check its register map.
  • The green LED keeps blinking: no broker. Check the address, port 1883, login and password.
  • Odd F32 values: the device sends the low word first. Try the neighbouring register or add a type with reversed word order.

The AppBlocks variant

The recipe also ships the official Tibbo ModbusMQTTGateway example moved to TiOS and the same TPP2(G2) kit. Devices and registers are set in the device web console. It reads one 16-bit register per point, publishes only (no writes from MQTT), polls every 5 s and publishes every 30 s by default. For float values, 32-bit counters and setpoint writes, use the TIDE variant.

Questions

Can I do the same without programming?
If you only need Modbus RTU to Modbus TCP, Tibbo DS1101 or DS1102 with the free Modbus Gateway app does it without code. For MQTT, use the AppBlocks variant of this recipe or the TIDE project with two settings files.
How many devices can it poll?
The poll list is a table in config.tbs; each line is one value from one device on the line. The practical limit is the RS-485 line itself and the poll period you need.
Can it use TLS to the broker?
Not on TPP2(G2): the recipe connects without TLS. TLS needs the TPP2(G3) board; with the Tibbo skills an AI agent can move the project to it and add a TLS connection to the broker.
What is the license?
MIT. Use and change the code in commercial projects.

Where to buy Tibbo

In Russia and the CIS - Scancode, the official Tibbo distributor (iot@scancode.ru, prices on tibbo.ru). In other countries - Tibbo Technology and its local distributors.

See also