Modbus TCP with W5100

Hi, I need help with my modbus program, I use W5100 and a arduino uno for this setup.
I'm unable to get reading in the modbus doctor to read the 0 from my arduino.
The following is my code.

#include <ModbusIP.h>
#include <Modbus.h>
#include <Ethernet.h>
#include <SPI.h>


//IPAddress ip(192, 168, 250, 177);
//EthernetServer ethServer(502);
//ModbusTCPServer modbusTCPServer;
 int SERVO_HREG ;
 const int SERVO_HREG_HR = 0;
 ModbusIP mb;


void setup() {
  Serial.begin(9600);
 byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
 byte ip[] = { 192, 168, 250, 177 }; 
 mb.config(mac, ip);
 mb.addHreg(SERVO_HREG_HR);


  }



void loop() {
  mb.task();
  SERVO_HREG = 123;
  mb.Hreg(SERVO_HREG_HR,SERVO_HREG);
  Serial.println(SERVO_HREG);
  delay(200);
}

@j133n, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project :wink: See About the Installation & Troubleshooting category.

Can you please edit your opening post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code (e.g. [] instead of []).

Also, please spend a bit of time (again?) reading How to get the best out of this forum.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.