For my project I m using the ENC28J60 ethernet module and the library is Arduino UIPEthernet Library The issue I m facing with this is, the IP pings when ethernet connected to my PC but when I connecting it with Switch it is not pinging properly. Can you help with me to solve this issue as it is an urgent one.
my code
#include <SPI.h>
#include <UIPEthernet.h>
#include <SoftwareWire.h>
SoftwareWire myWire( 10, 11);
EthernetServer server = EthernetServer(1000);
uint8_t MACADDR[15];
void setup()
{
Serial2.begin(9600);
uint8_t mac[6];
myWire.beginTransmission(0x53); // transmit to device #44 (0x2c) // device address is specified in datasheet
myWire.write(byte(0xFA)); // sends instruction byte
myWire.endTransmission(); // stop transmitting
int n = myWire.requestFrom(80, 6);
myWire.readBytes(mac, n);
// Serial2.println("--------------------");
for (int i = 0; i < 6; i++)
{
Serial2.print(mac[i], HEX); //Communication card mac
}
sprintf(MACADDR, "%02X%02X%02X%02X%02X%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
// Serial2.println(MACADDR);
// Ethernet.begin(mac, myIP);
IPAddress myIP(192,168,1,xx);
Ethernet.begin(mac,myIP);
Serial2.print("localIP: ");
Serial2.println(Ethernet.localIP());
Serial2.print("subnetMask: ");
Serial2.println(Ethernet.subnetMask());
Serial2.print("gatewayIP: ");
Serial2.println(Ethernet.gatewayIP());
Serial2.print("dnsServerIP: ");
Serial2.println(Ethernet.dnsServerIP());
server.begin();
}
void loop()
{
size_t size;
if (EthernetClient client = server.available())
{
while((size = client.available()) > 0)
{
uint8_t* msg = (uint8_t*)malloc(size);
size = client.read(msg,size);
Serial2.write(msg,size);
free(msg);
}
client.println("DATA from Server!");
client.stop();
}
}
Thanks in Advance