last day (18 days later) » 

10:26 PM
0
A: Two ports on Uno with ethernet shield

Juraj move the modbus refresh out of the if (client) condition mb.begin() calls Ethernet.begin(). Do not repeat it in setup() move client.println("</html>"); break; inside the if block before it copy the rest of the detection of empty line from the WebServer example stop() the client after response ch...

 
I've added to code I am using, I have port 80 assigned and the modbus library sets a port 502 for the modbus. When I use this I can ping the device but Modbus and web communication is not there.
When i check the serial monitor, I planned to remove it once this was working, it reports the IP address as 0.0.0.0
 
but it is not the IP address of the EthernetServer, it is the IP of the shield. the ip is reported wrong or the shield did not connect. try to connect with DHCP.
 
when I comment out all the webpage parts it works fine, and I can even ping the device with the code in using the set ip.
 
mb.begin() calls Ethernet.begin(). Do not call it again in setup()
 
I removed Ethernet.begin() and tried it out and it still didn't work, I can still ping the device but getting Modbus data or the webpage still doesn't work.
 
10:26 PM
I rewrote the answer
 
i made the changes with no change in the results
#include <SPI.h>
#include <VL53L0X.h>
#include <Ethernet.h>
#include <Modbus.h>
#include <ModbusIP.h>
#include <VL53L0X.h>
#include <Wire.h>

VL53L0X sensor;
EthernetServer server(80);

//Modbus Registers Offsets (0-9999)
const int SENSOR_Hreg0 = 100;

//ModbusIP object
ModbusIP mb;

unsigned long ts;

void setup() {
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 177 };

Wire.begin();
mb.config(mac, ip);

// Add SENSOR_Hreg register - Use addHreg() for Sensor Input
here is what I have now
the out put on serial is that the sever address is 0.0.0.0 and then the measurements as expected but the modbus doesn't work and neither does the webserver
I can ping the board though
 

  last day (18 days later) »