This allows you to read forced pin state changes Read the current state of the pins before calling Run() Uint8_t mac = Įthernet.begin(mac, ip, gateway, subnet) If you're using an UNO or any other Arduino with less pins then just remove the lines that map to pins you don't have. All of the other holding registers are just raw ADC values from analogRead(). For diagnostics I made a holding register for the Slave's free ram as well as two holding registers that hold the 32bit millis() value split into two 16 bit words. Some of the pins have thermistors connected, I multiply by 10 so I can divide by 10 on the master and carry a decimal place. I have this sketch working with an industrial HMI for a home automation type system, it works quite well. I have an Arduino Mega 2560 with all of it's pins mapped out with the exception of those required by the Ethernet shield.
If you want a Modbus/TCP slave then I have included the Mudbus library. Are you looking for Modbus over Serial or over Ethernet, I didn't see this mentioned anywhere.