Commanding Modbus Devices
We'll explain how to command Modbus devices in a few steps
Last updated
We'll explain how to command Modbus devices in a few steps
Last updated
The BACE IoT Platform allows you to command modbus devices through writable modbus registers. This capability allows control over several device functions such as starting a motor pump, adjusting its speed, or updating a solar inverter's schedule. Refer to the Modbus device manual for understanding the appropriate registers to write to and the correct values to achieve the desired action.
Before writing to modbus registers via the BACE IoT Platform, please ensure:
The Modbus device is onboarded onto the BACE Gateway and actively sending measurements.
You have the requisite datatype
for writing to the corresponding modbus device and registers.
If you have not onboarded your Modbus device yet, please visit How To Onboard Modbus Devices on how to do so.
Once your device is properly set up, you must obtain the corresponding datatype
for your device. As also explained in Accessing Data, there are multiple ways to retrieve all measurements and their groups. Below is an example API request to fetch all datatypes and their latest values using id_physical_device
endpoint
GET
https://dashboard.bace-iot.com/api/v2/physical-device/{id}?expand=group.latestData
Returns all the latest measurements collected by the gateway
Name | Type | Description |
---|---|---|
To write to a Modbus device, use the ModbusWrite endpoint. This process requires you to provide the datatype
number and the desired value in the payload.
The modbus-write endpoint is your interaction point to command a device. The payload must include the datatype
number and the desired value for execution.
PUT
https://dashboard.bace-iot.com/api/v2/physical-device/{id}/modbus-write
modbus-write endpoint is used for writing to modbus register(s)
Here is an example payload for writing to a single modbus register.
The endpoint can execute a write action for multiple registers simultaneously. This process requires providing all datatype
s and their corresponding values within the same payload as an array. Below is an example payload to set schedule for a solar inverter:
parameter | description |
---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
id*
String
id_physical_device
datatype
Each modbus register has an index called datatype
assigned by the gateway. The datatype is used for reading to and writing from modbus registers.
value
this is the value you want to write to the modbus register
id*
string
Gateway's id_physical_device
datatype*
int
datatype of the modbus register
value*
int/float
provide the value