thingsboard-gateway icon indicating copy to clipboard operation
thingsboard-gateway copied to clipboard

[HELP] how to send and test RPC Messages to a specific MODBUS device?

Open jpiwek opened this issue 6 months ago • 1 comments

Describe the issue Thingsboard Server and IoT-Gatewayy runs on my local RPi5 device. I created a RPC request in the MODBUS Connector device to "Write Single Coil" with Type bits. How can I now test this RPC Call?

Configuration (Attach your configuration file) Notate: Remove Access token from file if you want to attach a tb_gateway.yaml Image Image

Connector name (If you need help with some connector/converter): MODBUS Connector (TCP)

Versions (please complete the following information):

  • OS: RaspiOS Bookworm Linux 6.6.62+rpt-rpi-2712
  • Thingsboard IoT Gateway version [3.7.5] with Docker

jpiwek avatar Jun 17 '25 10:06 jpiwek

Hi @jpiwek,

The simplest way to test RPC is to use Swimming pool SCADA system solution template with emulator, you can find it on thingsboard.cloud, it contains instructions on how to configure devices and some pre-configured RPC requests and shared attribute updates.

Image

In general - to test RPC you need to create a dashboard with related control widget, for testing purposes we recommend to use RPC debug terminal, it provides more control over responses. How to create a dashboard and add a widget you can find information here - https://thingsboard.io/docs/iot-gateway/guides/how-to-use-gateway-rpc-methods/#step-1-create-a-dashboard-to-use-rpc-api-in-thingsboard-iot-gateway

You will need to set connected device through the gateway as a target for this widget.

imbeacon avatar Jun 18 '25 07:06 imbeacon

@imbeacon: just tried the example you have shared. I create an example with a switch button which work + added a Modbus RPC Write Request to write to a coil.

Question: I created a RPC debug terminal for my TB IoT-Gateway (see picture below). Can I execute commands via the terminal on a Modbus devices which is connected to the Gateway? I see I can list devices with gateway_devices but I can't see any command to execute a prefined RPC request on the devices itself.

Image

jpiwek avatar Jun 18 '25 15:06 jpiwek

@jpiwek In the widget, you need to select the actual device. The RPC will be sent to the ThingsBoard Gateway, which includes the target device information, allowing the gateway to route it to the correct connector.

From the UI perspective, you should interact with the device created by the gateway just like any other regular device. ThingsBoard will automatically forward the requests to the gateway behind the scenes.

imbeacon avatar Jun 19 '25 04:06 imbeacon

thanks @imbeacon. Where can I find the standard documentation about supported commands which can be executed in the RPC Debug Console? I found something here, is there a consolidated overview available: https://thingsboard.io/docs/iot-gateway/guides/how-to-use-gateway-rpc-methods/ https://thingsboard.io/docs/iot-gateway/guides/how-to-use-get-set-rpc-methods/?getSetConnectorRPC=modbus

Additionally I found this RPC option in the Modbus Connector. However I was not able to send any Modbus Command to my Modbus Server Device: I always get KeyError Message. How to use that

Image

jpiwek avatar Jun 19 '25 06:06 jpiwek

You can execute any RPC in RPC debug terminal, for example if you have configured RPC in connector configuration - you can choose related device as device for RPC debug terminal widget and send data to them.

You provided links to all service RPC methods that gateway has.

On provided screenshot - requests to connector, not to devices, to send GET/SET RPC to device - you need to create a new dashboard, with RPC debug terminal widget, set target device as entity for this widget and then you will be able to send RPC, like described in https://thingsboard.io/docs/iot-gateway/guides/how-to-use-get-set-rpc-methods/?getSetConnectorRPC=modbus

We will add more information to documentation, about dashboards creation, adding this widget in the future.

imbeacon avatar Jun 19 '25 08:06 imbeacon

We will add more information to documentation, about dashboards creation, adding this widget in the future. that would be great!

but how to the "service RPC" form for Modbus Connector RPC parameters or what is it good for? As I always get an KeyError when I fill out and press "send"

jpiwek avatar Jun 19 '25 09:06 jpiwek

We are working on this issue, it will be fixed in the nearest release.

imbeacon avatar Jun 19 '25 09:06 imbeacon

We are working on this issue, it will be fixed in the nearest release.

good to know! I tought it was my mistake!

jpiwek avatar Jun 19 '25 09:06 jpiwek