Go Down

Topic: Ethernet Shield problem with standard library (Read 167 times) previous topic - next topic

Hydridity

Hello, i would like to ask if somebody had similar experience with Deek-Robot NANO Ethernet Shield V1.0 this one:


When i'm trying ethernet library examples like web server tutorial: Web Server

in setup function that print server is at ...   via serial monitor it keep telling me that server is at 0.0.0.0 while it could be on 192.168.100.6 as i defined in ip value and also i added definitions for my local network gateway and subnet but it's same    no ping responses or http responses


so i found library arduino_UIP: arduino_UIP

and when i run following code i got results as expected
Code: [Select]
#include <UIPEthernet.h>

EthernetServer server = EthernetServer(1000);

void setup()
{
  Serial.begin(9600);

  uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
  IPAddress myIP(192,168,100,6);

  Ethernet.begin(mac,myIP);

  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);
          Serial.write(msg,size);
          free(msg);
        }
      client.println("DATA from Server!");
      client.println(Ethernet.localIP());
      client.stop();
    }
}


both ping and connection are working, this code above is listening to port 1000 and on connection sending string DATA from Server and actual ip adress so after connection via putty there is expected response
Quote
DATA from Server!
192.168.100.6
i could just stick with this library but i am curious why that arduino standard library wont work, its not just that webserver example but i couldn't make to work any of them
Do somebody have any idea why arduino standard library doesn't work for me, i am doing something wrong? I thought also of possibility if these two library  can't  uses different pin setup so it can't communicate with that shield ?

pert

The standard Arduino library is written for the W5100 Ethernet controller (W5200 and W5500 support are soon to be added). Your shield uses the ENC28j60 Ethernet controller, which is not supported by the Ethernet library. That's why you need to use the UIPEthernet library, which was specifically written for ENC28j60.

This is something you'll need to pay attention to with many libraries. They are written for specific hardware. If you try to use them with hardware they weren't written for then of course they don't work.

Go Up