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.
Other
534 stars 188 forks source link

modbus TCP set slave Id #259

Closed nex2000 closed 1 year ago

nex2000 commented 1 year ago

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

Merdock1 commented 1 year ago

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

emelianov commented 1 year ago

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);