Table of Contents

ImodbusRTUInit()

ImodbusRTUInit() sets the communication port, station number and baud rate.

ImodbusRTUInit command operation flow

void ImodbusRTUInit(HardwareSerial& serialPort, uint8_t slaveId, long baudrate)

Commands

Command Arguments Return Value Operation
ImodbusRTUInit(serialPort, slaveId, baudrate) HardwareSerial& serialPort — Serial port connected to RS-485
uint8_t slaveId — Slave address
long baudrate — Baud rate
void Sets the communication port, station number and baud rate.

Example

void setup() {
  ImodbusRTUMem(100, 200);  // Set the M·D memory sizes used by the Slave.
  ImodbusRTUAdr(0, 0);  // Set the start addresses of M·D memory.
  ImodbusRTUInit(Serial1, 1, 115200);  // Set the communication port, station number and baud rate.
}
 
void loop() {
  ImodbusRTU();  // Check incoming requests and process Slave responses.
  D[0] = 100;
  D[3] = 200;
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List