emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

modbus TCP set slave Id

nex2000 opened this issue · comments

I followed another post where it said to edit this line on the ModbusSettings file line 76.

uint8_t unit=1 // 255

I made this modification but nothing changes. I noticed that the ID can only be changed on push and pull functions. But unfortunately nothing to do even with these commands.

How can I change the slave address number.

Can I get an example ?

Thanks NEX

As far as I know the TCP slave ID is its IP address, unlike the RTU protocol.
Here is more information about it.
Does Slave ID field have significance in MODBUS TCP
https://www.modbustools.com/mbslave-user-manual.html#_connection

The library responds on any united when acting as ModbusTCP server.
For the client note last parameter for read\write calls:

uint16_t readCoil(IPAddress ip, uint16_t offset, bool* value, uint16_t numregs = 1, cbTransaction cb = nullptr, uint8_t uint = MODBUSIP_UNIT);