Page 1 of 1

Web-Enable your Arduino with an Arduino ENC28J60 Ethernet shield …

Web-Enable your Arduino with an Arduino ENC28J60 Ethernet shield …
   221

One day I ran into this particular Arduino ENC28J60 Ethernet module on eBay for $18. It included an Arduino ENC28J60 Ethernet shield/module and an Arduino USB Nano V3.0. Well, that’s pretty much for free isn’t it? So I could not resist and bought it, fully well knowing that it might not work. It took a little bit of figuring out, but I finally got it to work.

Playing with the Arduino is definitely fun, specially when you start looking into these kind of fun gadgets (snoop around on eBay and Amazon to see what’s out there!). If you look at eBay, or for example Amazon, for an Arduino ENC28J60 Ethernet shield, then you’ll notice that there are plenty models variations. 

In this article we will focus on selecting a good ethernet library for the ENC28J60 and run a “Hello World” example.
The code discussed in this article will probably work for all of them. 




Arduino and ENC28J60 Ethernet Controller

The number “ENC28J60” actually only refers to a chip developed by Microchip.  This chip has 28 pins and contains a complete stand alone Ethernet controller for a 10BASE-T network connection with an SPI interface so microcontrollers like the Arduino can “talk” to it.

10BASE-T is the same connector you’ll find on your computer (if it has one) to connect with a wire to a network, where “10” indicates a maximum speed of 10 Mbit/sec. That might sound slow, but if you consider that it’s being used by devices like the Arduino, then you can’t really expect massive data loads anyway. I’ve found it to be very responsive.

ENC28J60 – No longer recommended …
 

After several years of experience with the ENC28J60, I have to say that I can no longer recommend this Ethernet Shield for any Arduino project.
Unfortunately, the card comes with it’s issues, especially when it comes to stability.

If you’re looking for a good Ethernet Controller for your Arduino projects – please consider using a W5100 or W5500 ethernet shield (you can find some here – EU, US).
Or if you want a cheap, small, yet much faster Arduino compatible microcontroller and WiFi is an option, then please consider getting an ESP8266 (EU, US) or ESP32 (EU, US).

Selecting the right Ethernet Controller … 

The standard Arduino Ethernet Shield uses a all-in-one Ethernet Controller as well, and the proper libraries are included with your Arduino IDE. The used controller however is a Wiznet W5100!

In this article we focus on modules based on the MicroChip ENC28J60!
Which is NOT the same as the W5100 and is NOT compatible with it either, so other libraries will be needed.

  For those in need of making cables for this, please read our “How to make your own network cables” article.

10BASE-T uses RJ45 Connectors

10BASE-T uses RJ45 Connectors

Choosing your ENC28J60 board

When looking for one, you’ll find that there are numerous variations available, and they pretty much all work the same, just the board and pins look different for specific purposes. The only thing that can be tricky is finding the right pins for the right library. Illustration below: Just two of many variations of the ENC28J60 modules.

I found mine at eBay for $18 which came with an Arduino Nano (left in the picture – Nano not displayed), which works just fine with, for example, an Arduino Uno as well. The connectors however are geared towards mounting an Arduino Nano of course.

My main reasons to pick this one (besides being totally unaware, at the time, that this is not the same as the Arduino Ethernet shield) were: Price, came with a Nano and size. The module and Nano combined make this thing VERY compact. Including the Arduino Nano (clone) the setup would be app 6.7 cm (~2.6″) long, 1.7 cm (~0.7″) wide, and 1.7 cm (~0.7″) tall – depending on how you use the pins at the bottom and how you mount your Nano of course. You can choose the top connectors or bottom pins (breadboard) while experimenting, but you could consider cutting off the bottom pins for your final product.

ENC28J60 - Two examples of variations

ENC28J60 – Two examples of variations

Getting the Right Library

Since I randomly picked this particular model, I had to find out the hard way that things do not seem all that easy, since it’s not compatible with the Arduino “Ethernet” library that comes with your Arduino IDE. And then I’m not even mentioning the lack of good info to determine what pins are to be used, so I had to figure that out by myself.

In the next paragraphs you’ll find my experiences with three Arduino libraries. They all work great!

UIPEthernet is great for projects that require “print” to be fully implemented and need to be a drop-in replacement for the standard “Ethernet” library.
ETHER_28j60 is great for it’s simplicity and small size, but comes with limitations.
Ethercard seems best for very advanced users, but I’m sure UIPEthernet can match it’s capabilities.

I’ve included a “Hello World!” example for all three, which could use some optimizing, where the “Hello World!” message can be viewed in your webbrowser.

Before we begin: Libraries and Pins

  We will aways need power so we will always need GND and +3.3V or  +5V pin.
  For my eBay module I had to use the +5V (it has a voltage regulator onboard to handle that), as the 3.3V pin didn’t seem to work.

Below a table, based on a Arduino Uno, Arduino Nano and my eBay Ethernet module, with the needed pins for the three libraries I tested.
As you can see, all of them use the standard SPI pins 10, 11, 12 and 13. Except Ethercard, that seems to use pin 8 for SS, instead of the “standard” pin 10.

ENC28J60 Pins and Libraries
Pin name ETHER_28J60 Ethercard UIPEthernet My eBay Module
 SS  10  8 (!)  10  10
 MOSI (SI)  11  11  11  11
 MISO (SO)  12  12  12  12
 SCK  13  13  13  13

The Ethernet Controller (ENC28J60) is a so called SPI device and uses the SPI pins (10, 11, 12, 13) of your Arduino.

SS stands for Slave Select, used to enable or disable the slave device (the Ethernet module in this case).
MOSI stands for Master Output Slave Input, or in other words: Arduino OUTPUT (data from Arduino to Ethernet Controller).
MISO stands for the opposite, Master Input Slave Output, or: Arduino INPUT (data from Ethernet Controller to Arduino).
SCK is the clock used for SPI timing.

The pins described here will have the “Pin name” usually printed on your Ethernet Module. My eBay module however is fully geared towards the Arduino Nano that came with it and has NO SUCH PIN NAMES for the Ethernet controller, just the pin names of the Arduino pins. Hence the extra column for those who buy the same Ethernet Module, showing the pin number.

To illustrate this, below an illustration of the “Nano Ethernet Shield” by “Deek-Robot” that I purchased from eBay.

My eBay Ethernet module (Deek Robot Nano Ethershield)

My eBay Ethernet module (Deek Robot Nano Ethershield)

My Arduino with ENC28J60 - A wiring example

My Arduino with ENC28J60 – A wiring example

Other Examples

In this article, I’ll only show you a “Hello World!” example for these libraries. In the end “UIPEthernet” became my favorite and for that library I have written other example(s) – I’ll add more to this list as they are being published:

  Data retrieval over network with Data Pull
  Data retrieval over network with Data Push

 

Arduino Library: ETHER_28J60 and EtherShield

Caution – No longer maintained! 

Just a heads-up that you may run into issues with this library. The developer stopped maintaining it.

This is the first library I found, which works great for basic purposes, but I quickly ran into the limitations of the build-in print function. Another problem is that after some digging I found that the development either has stopped development or has been very slow in the past year, which is too bad, because of the (initial) simplicity of this library.

  Note that you will need both libraries to make this work!

Pros:

Below the simplicity of ETHER_28J60 … seriously: could it be any easier?

The library is also very compact, so it will save memory on your Arduino, compared to the other two libraries.

Cons:

Downside however is that this library is not compatible with the Ethernet Library code that comes with your Arduino IDE, so it’s not a drop-in replacement.

The other downside I ran into was the severely limited “print” function, when it comes to passing for example a String.
My knowledge and experience with normal C-strings is somewhat limited when functions like  sprintf and  printf are not there or only partially implemented (limitation of the standard Arduino library).

As development seems to have stopped, I doubt we will see a properly implemented “print” function (unless someone forks it at Github).

Download:

ETHER_28J60 and Ether shield can be downloaded from Github or you can download it from Tweaking4All.
As always: I recommend getting the latest version from Github, although I have little hope that there will be a newer version in the near future.

Download - ETHER_28J60 and Ethershield 

Filename:  ETHER-28J60-and-Ethershield.zip
Platform:  Undefined
Version: 
File size:  24.1 kB
Date:  2014-03-23
 Download Now  Send me a cup of Coffee    


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// A simple web server that always just says "Hello World"

#include "etherShield.h"
#include "ETHER_28J60.h"

// Define MAC address and IP address - both should be unique in your network
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24};  
static uint8_t ip[4] = {192, 168, 1, 15};
static uint16_t port = 80; // Use port 80 - the standard for HTTP                                    

ETHER_28J60 ethernet;

void setup()
{
  ethernet.setup(mac, ip, port);
}

void loop()
{
  if (ethernet.serviceRequest())
  {
    ethernet.print("<H1>Hello World</H1>");
    ethernet.respond();
  }
  delay(100);
}

 

 

Arduino Library: EtherCard

This library seems a very well respected in the Arduino community and with good reason. It seems one of the most complete implementations out there.

The code below might look a little bit more complicated, but that’s mainly because of the added HTML.

  CAUTION: Ethercard seems to use pin 8 instead of pin 10!

Pros:

Definitely a big plus for this library is that complex tasks like DHCP and such are easy to use, and offers easy accessible advanced features. Definitely excellent for the pro Arduino users.

Cons:

A big downside (again) is the lack of a simple to use “print” function to sent data, and I’m fully aware that me bitching about it is based on my own limited experience with working with strings and char arrays etc., but I can imagine that I’m not the only one.

Ethercard is, like UIPEthernet, not the smallest library.

Download:

EtherCard can be found at GitHub and on their project page or you can download it from Tweaking4All.
Again: I recommend getting the latest and greatest version from Github.

Download - Ethercard 

Filename:  ethercard.zip
Platform:  Undefined
Version: 
File size:  116.3 kB
Date:  2017-02-25
 Download Now  Send me a cup of Coffee    

Note: Source has been updated to accommodate the newer Arduine IDE version (line 10, added “const”).


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <EtherCard.h>

// Ethernet IP, default gateway and MAC addresses
static byte myip[] = { 192,168,1,200 };
static byte gwip[] = { 192,168,1,1 };
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Hello World!"
  "</title></head>"
  "<body>"
    "<h3>Hello World! This is your Arduino speaking!</h3>"
  "</body>"
"</html>";

void setup(){
  Serial.begin(57600);
  Serial.println("\n[Hello World]");

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip, gwip);

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  
}

void loop(){
  // wait for an incoming TCP packet, but ignore its contents
  if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
  }
}

 

 

Arduino Library: UIPEthernet

After testing the previous two libraries, I ran into UIPEthernet, at this moment my absolute favorite.

You might see the example code below as more complicated, but that is mainly me to blame. I modified and existing example to make a quick “Hello World” for you.

Pros:

This library is a fully compatible drop-in replacement for the standard Ethernet Library found in your Arduino IDE, which makes it easy to adapt existing examples for use with either the Arduino Ethernet shield for use with the ENC28J60 Ethernet shield. One simply changes the two include lines (“#include <Ethernet.h> ” and “#include <SPI.h> “) in standard Ethernet examples to just one include line “#include <UIPEthernet.h>“.

This library also has a complete implementation of the “print” function that works the same as the “print” function for “Serial”, keeping code simple and very easy to use.

Advanced features are available if needed, so “pro” Arduino users might enjoy this library as well.

Cons:

It will be a little bigger than ETHER_28J60.

Download:

UIPEthernet can be found on GitHub, is mentioned on the Arduino website, and optionally you can be downloaded from Tweaking4All.
I recommend getting the latest version from Github.

Download - UIPEthernet 

Filename:  arduino-uip.zip
Platform:  Undefined
Version:  1.01
File size:  102 kB
Date:  2014-03-23
 Download Now  Send me a cup of Coffee    


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <UIPEthernet.h> // Used for Ethernet

// **** ETHERNET SETTING ****
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };                                      
IPAddress ip(192, 168, 1, 179);                        
EthernetServer server(80);

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

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();

  Serial.print("IP Address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();

  if (client)
  {  
    Serial.println("-> New Connection");

    // an http request ends with a blank line
    boolean currentLineIsBlank = true;

    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();

        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank)
        {
          client.println("<html><title>Hello World!</title><body><h3>Hello World!</h3></body>");
          break;
        }

        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r')
        {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }

    // give the web browser time to receive the data
    delay(10);

    // close the connection:
    client.stop();
    Serial.println("   Disconnected\n");
  }
}

Support Us ...


Your support is very much appreciated, and can be as easy as sharing a link to my website with others, or on social media.

Support can also be done by sponsoring me, and even that can be free (e.g. shop at Amazon).
Any funds received from your support will be used for web-hosting expenses, project hardware and software, coffee, etc.

Thank you very much for those that have shown support already!
It's truly amazing to see that folks like my articles and small applications.

Please note that clicking affiliate links, like the ones from Amazon, may result in a small commission for us - which we highly appreciate as well.

Comments


There are 221 comments. You can read them below.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.

  • Apr 22, 2014 - 3:42 AM - Erick Alves Teixeria Comment Link

    hello … 

    ‘m newbie would like to know if it is possible to send some data from the serial port to the client

    Reply

    Erick Alves Teixeria

    • Apr 22, 2014 - 7:42 AM - hans Comment Link

      Hi Erick,

      I would assume that this would be possible, I haven’t really tried reading any data from the serial port though.
      If you know how to do that, then I’d assume relaying that data to Ethernet would work just fine as well.
      (and I doubt that reading data from the serial would be hard – I just never tried it, or looked into it)

      Reply

      hans

  • Apr 22, 2014 - 7:24 AM - Bob Comment Link

    This article describes the use of the Deek Robot design for an ethernet card. This design uses a 74HCT08 to ensure that the levels on MISO and Interrupt fully meet the spec of the 5V Arduino, but there are considerations:
    1) The unused input pins of the HCT08 (pins 13,12,10 and 9) are left unconnected. THIS IS BAD – CMOS inputs must not float.
    2) The buffered signal on MISO cannot also be connected to another shield (such as a CF shield) because it is permanently actively driven by the HCT08.
    3) The “\INTPT” output of the ENC28J60 is buffered to Arduino Digital Pin 2 for use with INT0. This digital pin cannot be used by anything else and MUST be set as an input.

    There are ways of dealing with 1) & 2) above, but No 2) is far less easy:
    1) With solder, carefully link together pins 13, 12, 11, 10 and 9 of the 74HCT08 to avoid floating inputs.
    2) If another MISO must be interfaced, connect it to pin 5 or 4 of the 74HCT08, not to the pin on Arduino. The ’08 will then buffer both signals. THIS IS VERY DELICATE!

    Reply

    Bob

    • Apr 22, 2014 - 7:38 AM - hans Comment Link

      Hi Bob,

      thanks for the info, but I’m not sure what you’re talking about?
      Are you suggesting a 7408 should be used? Or are you trying to point out a design flaw in the ENC28J60 board I’ve used?

      Reply

      hans

  • May 1, 2014 - 11:32 PM - Eduardo Comment Link

    Hi, 2 things:

    First: there is a new version of the UIPEthernet library, check at: https://github.com/ntruchsess/arduino_uip

    Second: I am using it and after a few hours the device stops sending data to another server I have. kind of a buffer overflow at the ethernet card, just a feeling. I restarted it and it does fine for a few hours more, then the same.

    Thanks for sharing with other, great work.

    Reply

    Eduardo

    • May 2, 2014 - 8:20 AM - hans Comment Link

      Thanks for the heads-up Eduardo. 

      I’ll update the downloadable library as soon as I can, and I’ll do some long term testing to see if I run into the same issues and if I can find a fix.

      Reply

      hans

    • May 2, 2014 - 8:29 AM - hans Comment Link

      Hi Eduardo,

      I just downloaded the latest version – I can’t find any differences with the one we have available at Tweaking4All …
      Do you know what changed?

      Reply

      hans

      • May 2, 2014 - 9:01 AM - Eduardo Comment Link

        I haven’t ran any diff in between versions to be honest. But I read a few forums, while trying to troubleshoot my issue, that the new version fixed few issues.

        One thing I am trying to do is to enable UIPETHERNET_DEBUG_CLIENT and UIPETHERNET_DEBUG, do you know anything about this?

        thanks,

        Reply

        Eduardo

      • May 2, 2014 - 11:22 AM - hans Comment Link

        OK, then I’ll just upload the latest Github master,… they files all looked the same, same dates, etc.
        But I might be overlooking one or the other tiny difference 

        Sorry … I have not (yet) tested UIPETHERNET_DEBUG_CLIENT and UIPETHERNET_DEBUG_CLIENT.
        Did you try finding/asking it at https://github.com/ntruchsess/arduino_uip/issues?
        Norbert, the writer of the library, is a very nice and helpful guy, he might be able to give you a pointer or two.

        Reply

        hans

  • Jun 7, 2014 - 12:52 PM - Adrian Miron Comment Link

    Hello,

    I’m
    contacting you regarding a project that I have. I’m using Arduino Uno
    and enc28j60 module and some XBees. The main problem is regarding the
    connection to the LAN/Internet. I’m using some sensors and I’m trying to
    view the sensors reading on the web. I used a lot of libraries but I
    can’t see nothing. I connected the enc28j60 module with a cable directly
    to the computer and in the browser I am typing the IP but nothing to
    see. Should I try with a router, but if I do so, why do I still put an IP? What am I doing wrong? Please help.

    This are some examples I’ve tried:

    #include <EtherCard.h>
    #include <DHT.h>
    #include <stdlib.h>
    #define DHTPIN 2
    #define
    DHTTYPE DHT11
    DHT dht(DHTPIN, DHTTYPE);
    static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
    static byte myip[] = {192,168,1,10};
    byte Ethernet::buffer[700];
     
    void setup () {
     
      Serial.begin(57600);
      Serial.println(“Temperatura demo”);
      dht.begin();
     
      if (ether.begin(sizeof Ethernet::buffer, mymac, 8) == 0)
        Serial.println( “Failed to access Ethernet controller”);
     
      if (!ether.staticSetup(myip))
        Serial.println(“Failed to set IP address”);
    }
     
    void loop() {
     
      int h = dht.readHumidity();
      int t = dht.readTemperature();
     
     
     word len = ether.packetReceive();
      word pos = ether.packetLoop(len);
      if(pos) {
       
        Serial.println(“—————————————- NEW PACKET —————————————-“);
        Serial.println((char *)Ethernet::buffer + pos);
        Serial.println(“——————————————————————————————–“);
        Serial.println();
        if (isnan(t) || isnan(h)) {
       
    Serial.println(“Failed to read from DHT”);
      } else {
        Serial.print(“Humidity: “);
        Serial.print(h);
        Serial.print(” %\t”);
        Serial.print(“Temperature: “);
        Serial.print(t);
        Serial.println(” *C”);
      }
        BufferFiller bfill = ether.tcpOffset();
         bfill.emit_p(PSTR(
      “HTTP/1.0 200 OK\r\n”
        “Content-Type: text/html\r\n”
        “Pragma: no-cache\r\n”
        “\r\n”
        “<meta http-equiv=’refresh’ content=’10’/>”
        “<title>Temp server</title>”
        “<h1>Temp: $D.00 *C <br>Humidity: $D.00 %</h1>”),
      t, h);
     
        ether.httpServerReply(bfill.position());
      } 
    }

    #include <EtherCard.h>

    // ethernet interface mac address, must be unique on the LAN
    static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
    static byte myip[] = { 192,168,1,203 };

    byte Ethernet::buffer[500];
    BufferFiller bfill;

    void setup () {
      if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
        Serial.println( “Failed to access Ethernet controller”);
      ether.staticSetup(myip);
    }

    static word homePage() {
      long t = millis() / 1000;
      word h = t / 3600;
      byte m = (t / 60) % 60;
      byte s = t % 60;
      bfill = ether.tcpOffset();
      bfill.emit_p(PSTR(
        “HTTP/1.0 200 OK\r\n”
        “Content-Type: text/html\r\n”
        “Pragma: no-cache\r\n”
        “\r\n”
        “<meta http-equiv=’refresh’ content=’1’/>”
        “<title>RBBB server</title>”
        “<h1>$D$D:$D$D:$D$D</h1>”),
          h/10, h%10, m/10, m%10, s/10, s%10);
      return bfill.position();
    }

    void loop () {
      word len = ether.packetReceive();
      word pos = ether.packetLoop(len);
      
      if (pos)  // check if valid tcp data is received
        ether.httpServerReply(homePage()); // send web page data
    }

    Reply

    Adrian Miron

    • Jul 31, 2014 - 12:21 PM - hans - Author: Comment Link

      I apologize for the very late response … totally overlooked this post.

      First of all, yes I’d go through a router, unless you have a crossed network cable and know what you’re doing …
      Router is easier to work with and most give visual feedback when data gets transmitted as well.

      First thing to check of course if both Arduino and PC have the right IP address (fixed?). An IP address is required since we’re working over a network, even if it’s just a cable from the ENC28J60 to your computer.

      Reply

      hans

  • Aug 7, 2014 - 12:46 PM Comment Link
    PingBack: microcontrollerelectronics.com

    […] Need more information on or sample code?  I found the best information about using this module is here:  tweaking4all.com […]

  • Sep 8, 2014 - 7:53 PM - Fred Comment Link

    Hello,

    Some precision:

    *If the green and orange led of RJ45 connector are not lighted, you must connect VCC to arduino 5V pin.

    *you can use PIN 10 for CS (SS) with ethcard library -> just add “10” as parameter: ether.begin(sizeof Ethernet::buffer, mymac,10) 

    Reply

    Fred

    • Sep 9, 2014 - 5:38 AM - hans - Author: Comment Link

      Thanks Fred for the additional info! Much appreciated! 

      Reply

      hans

      • Oct 12, 2014 - 5:25 PM - Edson Sobreira Comment Link

        Another good option is just change the library.

        Look for “CS”, and you will get the Pin = 8, so change and save.

        Reply

        Edson Sobreira

    • Feb 14, 2015 - 1:56 AM - Helge Comment Link

      Thanks, this with 5V helped me! As well as pin 10. Thanks!

      Reply

      Helge

  • Sep 27, 2014 - 4:06 PM - ben Comment Link

    I have a very basic question…  how do you install the libraries?

    For example, I’ve downloaded the ethercard zip, opened Arduino 1.5.6-r2 and imported the unzipped folder library.   After restarting the IDE, I select any Ethercard example, but it doesn’t compile**

    I’m assuming the examples compile without changes, so I must not be installing it correctly.    What am I doing wrong?   (sorry for the basic question, I’m a beginner to this!)

    **

    backSoon.ino:19: error: ‘byte’ does not name a type

    backSoon.ino:23: error: expected initializer before ‘PROGMEM’

    backSoon.ino: In function ‘void setup()’:

    backSoon.ino:43: error: ‘Serial’ was not declared in this scope

    backSoon.ino:46: error: ‘ether’ was not declared in this scope

    backSoon.ino:46: error: ‘Ethernet’ has not been declared

    backSoon.ino:46: error: ‘mymac’ was not declared in this scope

    Reply

    ben

    • Sep 28, 2014 - 1:48 AM - hans - Author: Comment Link

      Hi Ben,

      seems that your Arduino IDE is missing quite a bit or your code is not correct.

      To install libraries, read this Arduino article

      If your code looks like the last code example in this article, then I’d think reinstalling the Arduino IDE might be needed.

      Reply

      hans

    • Nov 12, 2014 - 12:34 AM - Stephan Comment Link

      Hi there,

      I have found that all the libraries have to be put in separate zip files and imported one by one. The one zip with multiple libraries sometimes gives issues.

      Reply

      Stephan

    • Nov 12, 2014 - 9:25 AM - hans - Author: Comment Link

      Thanks for the tip Stephan! 

      Reply

      hans

  • Oct 18, 2014 - 9:10 AM - Lars Comment Link

    Hi Hans

    I have been using the EtherCard library a while and wanted to switch to the UIPethernet library but could not make it work. I suspected the reason to be in different pinning connection but till I found this article have not had any luck finding the pin-connection used by UIPethernet.

    I switched pin 8 to 10 on my UNO and Voila it worked.

    Thanks a lot for sharing this with us!

    All the best

    Lars

    Reply

    Lars

  • Oct 22, 2014 - 12:33 PM - Brian Wayne Comment Link

    Hello:

    I have used ethernet and arduino for maybe 4 years now.  It’s quite simple to pull a web link lIke google.com into the arduino, but more complex links seem to be too difficult to get around.  I’ve already forgotten the steps that need to be taken to obtain the ip address for “google.com”, but once I’ve sort of re-learned that process, I’d like to be able to pull in other Web pages, like:  http://www.marinetraffic.com/en/ais/details/ships/538005277/vessel:BOW_CONDOR

    Is doing that fairly straightforward???

    The marine traffic site has a “complex” address, while the google.com one could be defined as “simple”.  Anyone fought something like this yet??

    Reply

    Brian Wayne

    • Oct 23, 2014 - 2:54 AM - hans - Author: Comment Link

      You could try the method I’ve used in the Data Push Example (way of entering the URL), Optionally replacing http://www.marinetraffic.com with it’s IP address (this does not always work and depends on the webserver having a unique IP address for given website, websites that share an IP Address will not work):

      void loop() {
        // if you get a connection, report back via serial:
        if (client.connect(server, 80)) {
          Serial.println("-> Connected");
          // Make a HTTP request:
          client.print( "GET /testserver/arduino_temperatures/add_data.php?");

      So this could become – give it a try … I have not tested this myself since I’m not having any hardware at hand right now (not home):

      void loop() {
        // if you get a connection, report back via serial:
        if (client.connect("www.marinetraffic.com", 80)) {
          Serial.println("-> Connected");
          // Make a HTTP request:
          client.print( "GET/en/ais/details/ships/538005277/vessel:BOW_CONDOR");
      Reply

      hans

  • Oct 23, 2014 - 10:05 AM - Brian Wayne Comment Link

    I don’t currently have hardware either.  I wonder if the second section of code may have additional syntax between the GET statement, and the remainder of that address? ??

    Reply

    Brian Wayne

  • Oct 23, 2014 - 9:56 PM - Brian Wayne Comment Link

    Hello:

    I picked up an ethernet board today.  I’ll try to tweak the “web page reading” files a bit.  The second group of code above has a line: client.print …..  sometimes  syntax has, sort of, a beginning quotation mark after the GET  in that client.print statement (or so I thought).  But it’s been so long since I’ve tried to dig into this stuff.  I probably should know this syntax, but I don’t really.  I have to travel for work, so if I don’t reply for like 3 weeks, or whatever, I’ll try to be back here at a later date once I get more time off from work.  I may check back here for like the next 2 or 3 days, but then I have to go back to work for like 16 days.  I’ll be back here sometime.

    Reply

    Brian Wayne

    • Oct 24, 2014 - 2:01 AM - hans - Author: Comment Link

      In the URL, you could use percent-characters, ie. instead of a space use %20 etc. 

      Reply

      hans

  • Oct 24, 2014 - 2:03 AM - Lars Comment Link

    Hi Hans

    I have recently bought a MEGA 2560 to replace my UNO – primarily due to the UNOs limited memory. The EN28J60 board works fine with UIPethernet but when I hook it up to the MEGA using the same pins as on the UNO it does not work. I have a TFT touchscreen with SD cardreader attached to the MEGA but I don’t believe there could be bus-/dataconflicts.

    Any idea what could be the reason for the board not to work with a MEGA?

    Best

    Lars

    Reply

    Lars

    • Oct 24, 2014 - 2:19 AM - hans - Author: Comment Link

      I assume you have a dedicated pin for the Ethernet board?

      Reply

      hans

    • May 14, 2015 - 4:30 PM - Dan Comment Link

      I believe the mega has different SPI pins, so instead of 11,12,13,10 you’re using the 50,51,52,53 on the mega. Check on that.

      Reply

      Dan

  • Oct 24, 2014 - 2:23 AM - Lars Comment Link

    all pins used by the Ethernet board are only used by that board: 

    I just read an article about Ethernet with the MEGA and they used pins 50-53??

    Reply

    Lars

    • Oct 24, 2014 - 2:28 AM - hans - Author: Comment Link

      I yet have to try that – by lack of a Mega board. But it would not surprise me …

      Reply

      hans

      • Oct 24, 2014 - 8:47 AM - Lars Comment Link

        It works now – the MEGA has its SPI bus on th epins 
        SO

        Reply

        Lars

        • Oct 24, 2014 - 8:51 AM - Lars Comment Link

          oops – a bit fast sending the reply ;-)

          SO is on 50

          SI is on 51

          SCLK is on 52

          SS for most libraries is on 53

          Thus I added pin 10 as SS for the SD card reader, set it as output and HIGH, waited 5 ms before communicating on the SPI bus with the Ethernet board and it worked.

          Reply

          Lars

      • Oct 24, 2014 - 10:59 AM - hans - Author: Comment Link

        Awesome Lars! Thank you for sharing this info – I’m sure others (including myself) will benefit from it! 

        Reply

        hans

  • Nov 3, 2014 - 4:12 AM - Robert C Comment Link

    Here is for anybody looking to use the EtherCard Library Example with the Nano and the ENC28J60 Shield.

    Change Line 28 of the Example above from:

    if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)

    to:

    if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)

    as outlined in the Readme.md included in the library, but in this shield we replace 53 with 10:

    # The default CS pin defaults to 8, so you have to set it on a mega:
        ether.begin(sizeof Ethernet::buffer, mymac, 53)

    That will successfully change your CS Pin from 8 to 10!

    Thanks to the OP who helped my 3 hours of scratching my head come to an end!

    Now can someone point me on how to read incoming form data from a radio button to control low or high on a Pin? I can read the Pin state, and print it, but I’m not sure on how to read the GET or POST?

    Thanks, Robert.

    Reply

    Robert C

    • Nov 3, 2014 - 4:39 AM - hans - Author: Comment Link

      Thanks Robert for the additional info … others will benefit from this for sure! 

      As for your question, I’ll assume you’re familiar with this article on the Arduino website (there are plenty other articles).

      For others, the basic reading of a switch:

      const int buttonPin = 2;     // the number of the pushbutton pin
      const int ledPin = 13; // the number of the LED pin
      // variables will change:
      int buttonState = 0; // variable for reading the pushbutton status
      void setup() {
        // initialize the LED pin as an output:
        pinMode(ledPin, OUTPUT);      
        // initialize the pushbutton pin as an input:
        pinMode(buttonPin, INPUT);     
      }
      void loop(){
        // read the state of the pushbutton value:
        buttonState = digitalRead(buttonPin);
        // check if the pushbutton is pressed.
        // if it is, the buttonState is HIGH:
        if (buttonState == HIGH) {     
          // turn LED on:    
          digitalWrite(ledPin, HIGH);  
        } 
        else {
          // turn LED off:
          digitalWrite(ledPin, LOW); 
        }
      }

      For the HTML output you could do something like:

      client.println("<html><title>Hello World!</title><body><h3>Hello World!</h3>");
      if (buttonState == HIGH) 
              {
                client.println("<p>Switch is <strong>ON</strong></p>");
              }
      else
              {
                client.println("<p>Switch is <strong>OFF</strong></p>");
              }
      client.println("</body>");

      (around line 41 in the last example in the article)

      Since you’re mentioning POST and GET, I’m assuming you’re cross referencing to the Arduino Data Push/Pull articles?
      If that’s the case, then you can add to the URL something like (Push example) “&mySwitch=1” (on) or “&mySwitch=0” (off). The PHP code can add this to the table (add a suitable boolean or tinyint field to the table) and change the SQL statement in PHP to something like:

      $SQL = "INSERT INTO test.temperature (sensor ,celsius, myswitch) VALUES ('".$_GET["serial"]."', '".$_GET["temperature"]."', '".$_GET["mySwitch"]."')";
      Reply

      hans

      • Nov 4, 2014 - 5:13 AM - Robert C Comment Link

        Maybe I wasn’t very clear. Everything you wrote, I knew, but what I can’t figure out is how to read the incoming url to the Arduino Shield like:

        http://192.168.1.200/something.html?digitalPin1=high&digitalPin2=low

        Or is it like:

        http://192.168.1.200/?digitalPin1=high&digitalPin2=low

        What is this “something” dot “something”, and how do I read the variables in the URL? So I can end up with something like:

        if (digitalPin1 == "high") { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }
        client.println("<html><title>Led FORM</title><body><h3>Hello World!</h3><br><form method=post>LedPin1 <input name=digitalPin1 type=radio value=high><input name=digitalPin1 type=radio value=low><br><input name=Submit type=Submit value=Update></form></body></html>");
        Reply

        Robert C

      • Nov 4, 2014 - 5:35 AM - hans - Author: Comment Link

        I apologize for maybe not quite understanding your question …

        You want to access your Arduino over Ethernet to read the position of a switch?
        Or do you want to send the state of the switch to your webserver so it can store it in a database? 
        Or do you want to control the Arduino with a form so you can use your computer to switch something ON/OFF?

        Reply

        hans

        • Nov 4, 2014 - 5:38 AM - Robert C Comment Link

          I want to control the Arduino with a form so I can use my computer to switch something ON/OFF? 

          Reply

          Robert C

        • Nov 4, 2014 - 5:49 AM - hans - Author: Comment Link

          Ah, OK, now I get what you want … that might require a little thinking indeed.

          Unfortunately, I do not have my equipment with me (I’m traveling), but I did find some articles that might help (I did a Google search on “arduino parse html form”):

          Sorry I can’t help you at the moment, I do like where you’re going with this and once I return home (mid December), I’ll most certainly start playing with this! Hope this info get’s you started 

          Reply

          hans

          • Nov 7, 2014 - 5:58 AM - Robert C Comment Link

            Here is some good information for people looking for the answer to my question.

            https://github.com/gysmovoile/arduwebrelays/blob/master/arduWebRelays.ino

            It breaks down how to read a single value inline. My next step is to take the entire string in the data and  break it up by using the ? as the start, then break it at the &’s, then finally break those down by the =’s … I’ll post it up once I get my parse script finished.

            Robert C

          • Jan 12, 2015 - 5:46 AM - narcomenos Comment Link

            Hey RobertC, Hans,

            Iam also using an rfid reader and arduino mega adk with ethernet shield connected to a raspberrypi (lamp server). I had build a local access control system for 1 door but now ive added 2 more doors and the verification of rfid tags needs to be more centralized. 

            Did u had any luck with the parsing of http form ? Iam thinking from the arduino mega a http get request via php and then in the page returned a string compare of the scanned id tag with the ones returned from mysql (allowed ones). 

            I think if u had any luck with ur project it will give me a boost. Iam also looking of MySQL Connector/Arduino http://drcharlesbell.blogspot.gr/2013/10/introducing-mysql-connectorarduino-100.html  

            narcomenos

          • Jan 12, 2015 - 7:25 AM - hans - Author: Comment Link

            Hi Narcomenos,

            That sure sounds like an interesting project, which should not be too difficult to implement. Add a unique key to the URL to identify the lock you’re trying to unlock. Possibly with a return value that opens the lock?

            I unfortunately do not have any of my equipment nearby, but it sure sounds like a fun project. Did you have a particular source for good RFID readers and/or electric locks?

            As for the MySQL connector: for a Uno this library might be too big, not leaving much space for other code. A Mega should be able to work with it though.

            hans

          • Jan 12, 2015 - 11:04 AM - narcomenos Comment Link

            Hans,

            Its very interesting project and i enjoy working on it. I have ID20LA RFID Reader and also u need a breakout board. The reader is working without any problem for many months. I also bought a typical electric strike (12V DC) connected with a 5V excitation DC relay from digital pins of arduino (important: not directly cause the excitation of the coil can return current back to arduino and destroy the board).

            I recommend using the same hardware.

            http://www.hobbytronics.co.uk/rfid-reader-id20la

            http://www.sainsmart.com/arduino-pro-mini.html

            You’re also correct i started the project with a uno rev3/poe ethernet shield and the code without using mysql connector was about 29k of 32k that uno has. The mysql connector needs at least 15k.. so last week i bought arduino mega adk and port my existing code there.

            I have register some users and id tags (125KHz) so the code goes smt like

            char* allowedTags[] = {
                "0006733125",   // Tag 1
                "S122349A34",   // Tag 2
                "D3004ADDBA",   // Tag 3
            };

            // List of names to associate with the matching tag IDs
            char* tagName[] = {
                "USER1",    // Tag 1
                "USER2",    // Tag 2
                "USER3",    // Tag 3
            };

            // Check the number of tags defined
            int numberOfTags = sizeof(allowedTags)/sizeof(allowedTags[0]);

            and in my void loop() after i have the 10 character id from reader i call findTag()

                        // Search the tag database for this particular tag
                        int tagId = findTag( tagValue );

            In findTag then i make the compare with the above approved list.

            int findTag( char tagValue[10] ) 
            {
                for (int thisCard = 0; thisCard < numberOfTags; thisCard++)
                {
                    // Check if the tag value matches this row in the tag database
                    if(strcmp(tagValue, allowedTags[thisCard]) == 0)
                    {
                    // The row in the database starts at 0, so add 1 to the result so
                    // that the card ID starts from 1 instead (0 represents "no match")
                    return(thisCard + 1);
                    }
                }
                // If we don't find the tag return a tag ID of 0 to show there was no match
                return(0);
            }

            So in findtag() i have to make the string compare (if return 0 i have no match or else with >0 we have a match).

            Iam right now trying to make the id verification through ethernet both ways, so any examples would be very appreciated.
            I want to make it work using http <form> get and parse the results for my UNO, but also using QUERY_POP from arduino mysql connector for mega. I have a local xampp setup for easy testing (a mysql database called door1 with a table tag and columns id, name, event_date) so iam in the phase of trials and errors :D

            This nice way this instructions are written really helped me understand how http <form> requests work with arduino!! Nice work.

            narcomenos

          • Jan 12, 2015 - 11:54 AM - hans - Author: Comment Link

            Thanks Narcomenos for the info. Nice, really nice project! 
            And thanks for the component suggestions!

            Did you read the articles on Arduino data push and Arduino data pull that I wrote?
            It’s not 100% – but you might be able to get some useful info there … 

            The Arduino Data Push article get’s you started with passing info to the server (MySQL), you’ll just need to combine it with receiving an answer from the server 

            hans

  • Nov 6, 2014 - 10:31 AM - freddy Comment Link

    Hi.

    Thanks for the post, and for the feedbackyou give.

    I am using Arduino v 1.06 and a Mega board.

    Even though the green and yellow lights goes on, I seem to not get the board to work.

    I am using Wireshark to sniff the computer ethernet interface, and when I try to connect to the arduino, loaded with any of the examples, like TcpServer, all I see is the ARP request for the ip I gave to the arduino board, but no answer. I guess is due to my board, everybody else seems to be enjoying the code. Is there anything to change anywhere to make it work with arduino mega boards? Thanks!

    Reply

    freddy

    • Nov 7, 2014 - 2:32 AM - hans - Author: Comment Link

      Hi Freddy,

      It could be that you need to use different pins, see this comment just above yours.

      Hope this helps 

      Reply

      hans

    • Nov 7, 2014 - 6:03 AM - Robert C Comment Link

      If you have this all hooked up right on the Mega, you should have:
      SO = Pin 50SI  = Pin 51SCK = Pin 52CS = Pin 53
      And if you look at my post above, you’ll need to use the line:

      if (ether.begin(sizeof Ethernet::buffer, mymac, 53) == 0)

      53, being your CS Pin.Try that. :)

      Reply

      Robert C

    • Nov 7, 2014 - 6:07 AM - hans - Author: Comment Link

      Thanks Robert for jumping in! Love it when visitors help each other! 

      Reply

      hans

    • Nov 7, 2014 - 9:33 AM - freddy Comment Link

      Hi everybody!

      Did the homework, read you, Robert & Hans.

      Also read the pinout of the Arduino UNO and Arduino Mega.

      I have this board http://www.dx.com/p/ethernet-shield-v1-1-for-arduino-66908 which stacks on top of the Mega board. The problem was as said by Robert the different pins used for SPI, but also because on Mega pin 13 goes to control an onboard LED. So, I cut the DI/O pin 13, correctly connected pins (10, 11, 12, 13) to (53, 51, 50, 52) without changing anything else, it worked smothly.

      Thanks, guys!

      :-)

      Reply

      freddy

  • Nov 19, 2014 - 2:14 PM Comment Link
    PingBack: bigdanzblog.wordpress.com

    […] TCP Communications between a PC and an Arduino Nano Using Lazarus / Free Pascal  […]

  • Dec 14, 2014 - 11:39 AM - Brice Comment Link

    Hello,

    I have a question about the ENC28J60 component vs. ENC28J60  shield.
    Does the shield still allow you to use pins 11, 12, 13, 14, or are they also used by the shield and no more available ?

    Thanks !
    Regards.

    Reply

    Brice

    • Dec 14, 2014 - 2:50 PM - hans - Author: Comment Link

      If you mean the passing though Arduino pins, then 10-13 are in use – yet passed through anyway.
      I’m not sure if they can be used though.

      Maybe a more experienced Arduino user will know how to answer this … 

      Reply

      hans

      • Dec 15, 2014 - 2:22 AM - Dan Likins Comment Link

        Pin 13 is dedicated as a Chip Select for your Ethernet Interface and cannot be used for anything else.

        However pins 10, 11 & 12 are the SPI Buss and may be connected to other SPI chips, each with their own dedicated Chip Select pin.

        (The LED on pin 13 should not pose a problem.)

        Most of the Libraries allow you to specify an alternate pin to be used as the Chip Select – somewhere in the initialization call.

        Reply

        Dan Likins

        • Dec 15, 2014 - 2:30 AM - Dan Likins Comment Link

          Oops

          Got the pin numbers wrong…

          11 – SPI in

          12 – SPI out

          13 – SPI clock

          xx – Chip Select (can be specified) [must be unique to each chip]

          Reply

          Dan Likins

      • Dec 15, 2014 - 6:02 AM - hans - Author: Comment Link

        Thanks Dan! 

        Reply

        hans

  • Dec 17, 2014 - 5:07 AM - nikt Comment Link

    Hi,

    I have a question about UIPEthernet library.

    I’m using netbeans to develop. It show that it could not find ‘println’. I look in to the headers and source files of this library and I could not find any definition or declaration of this function.

    However function ‘println’ appears in examples attached to this library. It is inherit from somewhere ?

    Your example code is not compiling for me. 

    It is fine when I use client.write(…) instead client.println(…) – this function exists in headers and source files.

    Should I include something more then <UIPEthernet.h> ?

    Reply

    nikt

    • Dec 17, 2014 - 6:35 AM - hans - Author: Comment Link

      Hi Nikt,

      I’m not sure if it’s from the <ETHER_28J60.h> library, some how doubt it, but I haven’t checked.
      This is the only other library I’ve included.

      I haven’t used NetBeans to develop (yet), how well does that work compared to the Arduino IDE?

      Reply

      hans

      • Dec 17, 2014 - 7:06 AM - nikt Comment Link

        Hi Hans,

        Thank You for Your answer. I check it and <ETHER_28J60.h> contains print() function (not println()). However this is other library and is not connected to UIPEthernet.

        I try to run code from this article on stock Arduino UNO connected to ECN28J60 from Arudino IDE.

        Netbeans is much more complex to setup to work. However I use it to build program and then load it by AVR-ISP to boards made by me (and using same MCU as Arduino). This is not possible by Arduino IDE (as I think).

        Reply

        nikt

      • Dec 17, 2014 - 9:02 AM - hans - Author: Comment Link

        By the best of my knowledge, I’m not including any other libraries … let me know how things go with the stock Arduino IDE! 

        Reply

        hans

    • Dec 17, 2014 - 6:36 AM - hans - Author: Comment Link

      For those interested, I’ve found a plugin for NetBeans to do Arduino development. Is this the one you use Nikt?

      Reply

      hans

  • Jan 21, 2015 - 5:28 PM - Kevin Comment Link

    Hi,

    I hope you can help me. 

    I have problems with the UIPEthernet lib. It just won’t connect with the internet. 

    It won’t get a IP from the DHCP server. Even an static IP won’t work.

    I also tried the EtherCard lib and that works instantly. 

    I will get an IP from the DHCP server and an static IP works fine to.

    So is this a common problem? Am i doing something wrong?

    Thx

    Reply

    Kevin

    • Jan 22, 2015 - 4:24 AM - hans - Author: Comment Link

      Hi Kevin,

      I have only encountered this problem because I made mistakes in the setup (forgot to use DHCP, wrong cable, etc). But in your case, since Etherlib works just fine, I doubt it’s any of these issues.

      I assume you’ve tried different cables, reflash the sketch, etc.

      You could look at the GitHub pages of UIPEthernet, there is an question and answer section there – maybe they can assist.

      Reply

      hans

      • Jan 22, 2015 - 4:47 AM - Kevin Comment Link

        Thanks for the quick response.

        I already found the problem.

        The CS cable needed to be in arduino port 10.

        Reply

        Kevin

      • Jan 22, 2015 - 4:57 AM - hans - Author: Comment Link

        Awesome! 

        Glad to hear you’ve got it to work.

        Reply

        hans

  • Feb 3, 2015 - 6:43 AM - Daniel Comment Link

    HI!

    I hope you can help me. 

    I have problems with the UIPEthernet lib. and LEONARDO It just won’t connect with the internet. 

    I Try SC port 8 an 10 with no succes. Any ideas?

    Thanks in advance!

    Reply

    Daniel

    • Feb 3, 2015 - 8:54 AM - hans - Author: Comment Link

      Hi Daniel!

      When you say “doesn’t connect to the Internet” do you mean you’re not getting an IP Address? 

      (Initial tips: make sure you use the right network cable, that your router has DHCP enabled, make sure your power-supply is suffient)

      Reply

      hans

      • Feb 3, 2015 - 9:40 AM - Daniel Comment Link

        HI! thanks for fast answer!  Sorry my English please.

        I use arduino 1.0.5. (downloading 1.0.6!)

        My project works well with EtherCard Library. But now I ‘m trying to use UIPEthernet library by your recommendation with no success. Where can I change the CS pin? I can’t find it!

        I’m planning the automation of my home:solar power, alarm, watering garden, lights and so on. A problem is length of wires. SO my idea its to have distributed  arduinos with Ethernet shields, so its necessary that these mini-modules works as client-server. They can be able to receive instructions as”turn kitchen ligth ON” or say to the server “window opened -> fire alarm”

        May be there is better solution. Bee and other posibilities are not cheap for me.

        Thanks!!

        Reply

        Daniel

      • Feb 4, 2015 - 4:15 AM - hans - Author: Comment Link

        Hi Daniel,

        I have not tested or needed this [yet], but this is what I’ve found at GitHub – but I cannot very this at the moment.
        I also found the following (also untested):

        ether.begin(sizeof Ethernet::buffer, mymac, 53)

        Where “53” is the CS pin you’d like to use.

        For Ethercard see Robert’s comments.

        Reply

        hans

        • Feb 5, 2015 - 5:32 PM - Daniel Comment Link

          HI!

          Thanks for answer. I return to Ethercard library and it works.

          I read Robert’s comments, with not lucky. Still planning to use arduino as client-server.

          Thanks a LOT!!!

          Reply

          Daniel

        • Feb 6, 2015 - 3:18 AM - hans - Author: Comment Link

          You’re welcome … Glad to hear you’ve got something working … 

          Reply

          hans

          • Jan 28, 2016 - 11:57 AM - Daniel Comment Link

            HI Again!

            Finally I have time to  take my project again.

            I have a problem. I call a PHP server from ARDUIno with succes first time , with call back!:

            <<<<  Callback  >>>>
            HTTP/1.1 200 OK
            Date: Thu, 28 Jan 2016 17:18:50 GMT
            Server: Apache/2.4.17 (Unix) OpenSSL/1.0.1q PHP/5.5.30 mod_perl/2.0.8-dev Perl/v5.16.3
            X-Powered-By: PHP/5.5.30
            Content-Length: 49
            Connection: close
            Content-Type: text/html
            <<<<  Callback  >>>>

            so a minute later I call again with new params. with NO SUCCES.

            I think I must reset (in some way) the conection to make a new one. I use browsrURL proc:

                ether.browseUrl(PSTR(“/SaveEvents.php?”) , params1 , website, myCallback);

            and in the loop:

                ether.packetLoop(ether.packetReceive()) ;

            Any ideas??

            Thanks a lot!!!

            Daniel

          • Jan 29, 2016 - 4:10 AM - hans - Author: Comment Link

            Hi Daniel!

            You could try “resetting” the ENC28J60 with:

            if (!client.connect(server, 80)) {
                  // Serial.println("-> Connection failure detected: Resetting ENC!"); 
                  Enc28J60.init(mac);
                } else {
                  client.stop();
                } 

            I’ve used it in the past when many connections occur in a relatively short time. It did seem to do the trick, even though this might not be the 100% correct way of doing it. Worth a try I would say 

            hans

          • Jul 24, 2016 - 9:12 AM - amoarg69 Comment Link

            HI again! system lost my id I dont know why

            Finally foud WHY Leonardo doesn’t works on ENC28J60 with UIPEthernet. SS pin on Leonardo is 14 no 10. So I made the chnages an it works!

            But ENC28J60 is higly unstable. it can take some mins to hours but finally crashes

            Further reading showme that it is very sensitive to the power source.only with .2v diferences crashes. And send packet primitive has a bug that crashes code.

            SOmebody has solves both problems? is W5100 stable?

            Thanks a lot in advance. Daniel

            amoarg69

          • Jul 25, 2016 - 3:09 AM - hans - Author: Comment Link

            Awesome! Well, I think the ENC28J60 is OK for very simple stuff, but as soon as you’d like to do more, then things can indeed become unstable over time. I’d have to guess that the W5100 is more stable, since even AdaFruit is using it ….

            hans

  • Feb 11, 2015 - 7:40 AM - Akarsh Comment Link

    hi,

    I’m using Arduino Nano to interface ENC28J60 ethernet
    shield. My code compiled and uploaded to nano sucessfully. After wiring,
    the leds on the RJ 45 connector are not blinking.

    With the same code and wiring setup, its works correctly with Arduino Mega 2560 board.

    Here i changed the cs pin from 53 to 10 for the arduino nano board. but its not working.

    Is it a power problem?

    Can u suggest me a remedy?

     Thanks

    Reply

    Akarsh

    • Feb 11, 2015 - 7:47 AM - hans - Author: Comment Link

      Hi Akarsh,

      LEDs not blinking on the RJ45 can mean issues with the network cable, but since you had it working with an Arduino Uno, I think we can rule that one out.

      I haven’t tried the Arduino Nano yet, but as far as I recall from the comments, is that pin 53 is intended for the Arduino Mega. I assume you made a typo.

      Power could be an issue, but if the same power supply was used as with the Arduino Uno, then I would think it’s adequate for the Arduino Nano as well.

      I’d check the CS pin … at least that would be my first guess … 

      Reply

      hans

      • Feb 11, 2015 - 10:26 PM - AKARSH Comment Link

        Thanks for the reply Hans!

        I’m using the same network cable with both Mega2560 and Nano.

        Its working fine with Mega 2560.

        CS pin for nano is 10 and for Mega2560 is 53.

        With the same environment, Mega2560 is working but not on Nano. Is this ethernet shield ENC28J60 is compatible with Nano?

        Reply

        AKARSH

      • Feb 12, 2015 - 3:04 AM - hans - Author: Comment Link

        Oh OK, sorry for misunderstanding the pin part 

        I would think the ENC28J60 should be nano compatible. I’ve used it with an Arduino Uno R3 and Nano and Uno seem the same (expect the Nano has 2 more analog ports it seems) – see Arduino board comparison chart. According to the info on the Arduino website, the Uno and Nano use exactly the same pins for SPI. Same power requirements/levels, same microprocessor, same memory, same clock …

        Reply

        hans

        • Mar 3, 2015 - 2:26 AM - Akarsh Comment Link

          Sorry for late reply Hans.

          I think my ethernet shield is not compatible with nano which i’m using…

          Reply

          Akarsh

        • Mar 3, 2015 - 2:46 AM - hans - Author: Comment Link

          Hmm, that sucks … are you sure?
          I have not tested it with the Nano yet, but if this is the case, then I wouldn’t have much use for my Nano’s either … 

          Reply

          hans

      • Feb 12, 2015 - 3:08 AM - hans - Author: Comment Link

        I did some more searching, and one forum topic mentions a defective pin.

        Otherwise I was unable to find reasons why the Nano wouldn’t be able to do what the Uno can.

        Reply

        hans

  • Feb 17, 2015 - 3:46 PM - NEODODO Comment Link

    Thanks for this article, I was trying to run your Nano v1 Ethernet module with an Arduino Nano v3 and did not work … everything was so simple with the explanation of “Not the same driver WIZnet 5100 with ENC28J60” and download the libraries everything worked. thanks for the info.

    Reply

    NEODODO

    • Feb 18, 2015 - 3:01 AM - hans - Author: Comment Link

      Hi NeoDodo!

      Thank you for taking the effort to leave a nice feedback! Thanks, it’s much appreciated! 

      Reply

      hans

  • Apr 24, 2015 - 3:28 PM - minu Comment Link

    hi

    I tried the code with the EtherCard library and im getting Backsoon on my serial monitor.But when i tried to type the ip address nothing came.it says webpage error..please can u help me with this..please.

    Reply

    minu

    • Apr 29, 2015 - 3:01 AM - hans - Author: Comment Link

      Hi Minu,

      sorry for the late reply …

      What is your serial output showing? Did it output a valid IP address, gateway, and such?

      Reply

      hans

  • Apr 28, 2015 - 11:52 PM - Akarsh Comment Link

    hi,

    is there any way to change the SS pin to some other pins?

    i need it because i have to communicate both ethernet shield and tft touch display simultaneously. if both slaves uses same ss pin , it clashes.

    is there any idea to get a remedy?

    Reply

    Akarsh

    • Apr 29, 2015 - 3:02 AM - hans - Author: Comment Link

      Hi Akarsh,

      That’s a very good question … ehm, to which I cannot give you a good answer …
      I’m traveling and do not have any of my gear near me … 

      Reply

      hans

  • May 18, 2015 - 11:15 AM - MaxiD - Author: Comment Link

    I can change by code, the SS pin? I have a connecting plate otherwise the A0 pin.

    Reply

    MaxiD

    • May 19, 2015 - 7:11 AM - hans - Author: Comment Link

      You will have to start digging in the library you’re using. As you can see in the first table, the SS pin is assigned in the library to a particular pin.

      The all use pin 10, except Ethercard (uses pin 8) – so I’d assume this is a definition/setting in the individual libraries.

      Reply

      hans

      • May 19, 2015 - 9:07 AM - MaxiD - Author: Comment Link

        Sorry i’m use UIPEthernet

        Reply

        MaxiD

      • May 19, 2015 - 5:08 PM - hans - Author: Comment Link

        No problem MaxiD!

        I have been looking around and have to admit that it seems surprisingly difficult to find info to do exactly that.

        One maybe helpful post I found at Github (Can arduino_uip work with ATmega644 – I know it “sounds” irrelevant, read through the conversation there and you’ll see they are talking about changing particular pins in the library code).

        Reply

        hans

  • May 26, 2015 - 5:00 AM - TheFex Comment Link

    After reading this article I decided to do some tests with the various libraries listed here. My personal take is that Ethercard by far wins on performance and flexibility. UIPEthernet suffers from multiple problems, including hangs. 

    Reply

    TheFex

    • May 26, 2015 - 8:16 AM - MaxiD - Author: Comment Link

      Yes, yes im test UIPEthernetand freez or erratical function

      Reply

      MaxiD

      • May 26, 2015 - 8:32 AM - TheFex Comment Link

        I hope you have better luck with the Ethercard library. It doesn’t take much to set up. Be sure to add the SS pin to the Ethercard.begin() call in your setup. 

        Reply

        TheFex

        • May 26, 2015 - 9:32 AM - MaxiD - Author: Comment Link

          I’ve only tested the UIPEthernet and with poor results.
          Where the SS pin is changed?

          in the lastest lib say


          #define SPI_SS                  10

          Reply

          MaxiD

          • May 26, 2015 - 1:48 PM - TheFex Comment Link

            The SPI pinout varies per AVR. 

            See here for more details:

            http://www.arduino.cc/en/Reference/SPI

            Here’s a snippet from one of my sketches:

            const byte SPI_SS_pin = 10; // This parameter defines the slave pin for SPI
            
            void setup () {
              if (ether.begin(sizeof Ethernet::buffer, mymac, SPI_SS_pin) == 0) 
                Serial.println(F("Failed to access Ethernet controller"));
            }

            It appears that the SPI pinout isn’t defined as a part of the SPI.h, which is why I declared it.

            TheFex

  • May 26, 2015 - 12:02 PM - ben Comment Link

    Hi, thanks for the great site!   Lots of great information!    Just curious:

    1) To be safe, is it best to supply +3.3v AND +5v to the ENC28J60 module (since mine has power pins for both)?   The SPI will always be 3.3v levels?

    2) Does the first Arduino library mentioned (ETHER_28J60.cpp) implement a TCP/IP stack?    I know the EtherCard uses the tuxgraphics tcp/ip stack, and that uipEthernet uses Adam Dunkels famous uip stack.     (Incidentally ibex has lots of great open source projects, including a tcp/ip stack for the enc28j60 : http://www.embedded-code.com/source-code/communications/ethernet-tcp-ip/ethernet-tcpip-driver )

    3) There’s some nice arduino/ethernet tutorials here : http://www.lucadentella.it/en/category/enc28j60-arduino/

    4) What SPI clock speeds have you used?   SPI Mode?

    5) Do you have any thoughts on the Lantronix Xport (ethernet <-> uart) modules?   Do they work the same as the enc28j60 but use rs232 instead of spi?   I’ve seen some videos for it and it seems to work without any extra code on the embedded side!  Not sure though.

    6) Finally, I’m using this snippet I found for basic ping test and webserver, perhaps it can help others:

    #include <EtherCard.h> 

    static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01}; 

    static byte myip[] = {192,168,1,10}; 

    byte Ethernet::buffer[700]; 

      

    void setup () { 

      ether.begin(sizeof Ethernet::buffer, mymac,10); 

      ether.staticSetup(myip); 

      

    void loop() { 

      

      word len = ether.packetReceive(); 

      word pos = ether.packetLoop(len); 

      

      if(pos) {    

         

        BufferFiller bfill = ether.tcpOffset(); 

        bfill.emit_p(PSTR(“<h1>hello</h1>”)); 

        ether.httpServerReply(bfill.position()); 

      } 

    Reply

    ben

    • May 27, 2015 - 6:09 AM - maxid Comment Link

      1. Enc28j60 are 3v3 only. But pins cs,miso,mosi, sck, reset are 5v tolerant

      Reply

      maxid

  • Jun 29, 2015 - 1:13 AM - Danie - Author: Comment Link

    HI Guys.
    Not a Newbe to Arduino but also not a Expert. I seriosly need some urgent advice.
    I want to connect a ENC28J60 ethernet to my GBoard Pro (Itead) with GSM. I need it to be able to plug a IP Camera to the Ethernet, and that it uses GSM to send n Picture Taken to the FTP server.

    Any advice highly appreciated

    Thanks

    Danie

    Reply

    Danie

    • Jun 29, 2015 - 2:14 AM - hans - Author: Comment Link

      Hi Danie,

      I’m not familiar with the GBoard Pro, but as far as I can see, this might not be the right approach to send pictures.
      The memory of the Arduino is (I think) too limited to retrieve a picture and pass it through to your GSM module.
      Not to mention, but I’m not 100% sure, that the pins of the ENCC28J60 might conflict with the pins used by the GBoard.

      For this kind of application you’re probably better off using a Raspberry Pi.

      But, keep in mind that I have no experience with the GBoard or with handling (larger) pictures on an Arduino.
      I do know though that the Ethernet library alone already takes quite a bit of memory of the Arduino. Only a few Kilobytes remain.

      Sorry … 

      Reply

      hans

      • Aug 7, 2015 - 3:05 AM - Danie - Author: Comment Link

        HI
        Ok got everything going

        Using a LS-y201 Serial Camera, take the picture (Activated by a Passive IR – when to take snapshot), save to SD card, and then Send a SMS/MMS to the customer with the Picture. Everything done from the Gboard Pro.

        Regards

        Danie

        Reply

        Danie

  • Aug 6, 2015 - 1:25 PM - Martin Comment Link

    Hello everyone, 

    I’m newby and i’m trying the 1st sample and I’m getting this errors.. and I have no idea what should I do about them – I did install the lib 

    Can you have a look and give some advice? thank you in advance! 

    Build options changed, rebuilding all

    In file included from C:\Program Files (x86)\Arduino\libraries\etherShield/etherShield.h:25:0,

                     from final.ino:3:

    C:\Program Files (x86)\Arduino\libraries\etherShield/ip_arp_udp_tcp.h:32:66: error: ‘prog_char’ does not name a type

     extern uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

                                                                      ^

    C:\Program Files (x86)\Arduino\libraries\etherShield/ip_arp_udp_tcp.h:32:77: error: ISO C++ forbids declaration of ‘progmem_s’ with no type [-fpermissive]

     extern uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

                                                                                 ^

    In file included from final.ino:3:0:

    C:\Program Files (x86)\Arduino\libraries\etherShield/etherShield.h:34:65: error: ‘prog_char’ does not name a type

        uint16_t ES_fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

                                                                     ^

    C:\Program Files (x86)\Arduino\libraries\etherShield/etherShield.h:34:76: error: ISO C++ forbids declaration of ‘progmem_s’ with no type [-fpermissive]

        uint16_t ES_fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

                                                                                ^

    Error compiling.

    Reply

    Martin

  • Aug 7, 2015 - 2:51 AM - hans - Author: Comment Link

    Hi Martin,

    seems there are problems with “etherShield” – did you get the latest version from Github?
    There you can also open an issue if you’d want to.

    Which version of the Arduino IDE are you using?
    If it’s a very recent version, you could try reverting to an older version (not sure if that will help though).

    Reply

    hans

    • Sep 2, 2015 - 9:54 AM - Martin Comment Link

      I tried with the Arduio IDE older version, but that didn’t work for me.

      Reply

      Martin

  • Sep 2, 2015 - 1:18 AM - Guillermo Comment Link

    Thansk bro, you are the man!!!

    Regards,

    Guillermo

    Reply

    Guillermo

    • Sep 2, 2015 - 3:27 AM - hans - Author: Comment Link

      Thanks Guillermo for taking the time to leave a nice comment! Its’ much appreciated 

      Reply

      hans

  • Oct 13, 2015 - 4:50 PM - Giannis Comment Link

    Great post! Thank you for taking the time to do all this research and write about it.

    Reply

    Giannis

  • Nov 18, 2015 - 10:25 AM - Heini Comment Link

    thanks for your great overview!!

    Do you know if it is possible to check an external web adress with UIPEthernet? If yes, how??

    Lets say the result of http://www.domain.com/test.php is 1 than turn the led on. If the result is 0, turn it off.

    Thanks!!

    Reply

    Heini

    • Nov 18, 2015 - 5:25 PM - hans - Author: Comment Link

      Hi Heini,

      I think I see where you’re going with that … and I like it!
      Would be great to see a LED indicate if my own website is up and running! 

      Well, so far I have seen rather disappointing results when trying to get name resolve to work properly. My experiments so far have all been based on an IP address because of this. But … it’s worth looking into!

      Reply

      hans

  • Dec 1, 2015 - 5:17 PM Comment Link
    PingBack: emalliab.wordpress.com

    […] //www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/ […]

  • Jan 13, 2016 - 10:32 AM - Torres Comment Link

    Dear friend

    Thanks a lot for your time. I use ENC28j60 for Arduino Nano328  with uip_library and  tcp socketClient  ethernet and work PERFECTLY!!!

    Thanks for shrare.

    Reply

    Torres

    • Jan 14, 2016 - 3:51 AM - hans - Author: Comment Link

      Hi Torres!

      Thank you very much for posting a nice “Thank you” note – it’s very much appreciated! 

      Reply

      hans

  • Feb 8, 2016 - 9:17 PM - senderj Comment Link

    I followed this article but not able to compile the example code using IDE 1.6.7 and ethercard library. IDE exit with status 1 and message “variable ‘page’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’ “

    I add const before the page[] declaration but IDE exit with even more errors around “prog_hcar* has not been declared” at EtherCard.h:283:28.

    Appreciate if anyone can help me.

    Reply

    senderj

    • Feb 9, 2016 - 3:30 AM - hans - Author: Comment Link

      Hi SenderJ,

      This appears to be an error caused by changes in 1.6.7 (see this GitHub link).

      Now I suspect this is a library error, so the first step would be to update your libraries.
      The 1.6.7 I use notifies me at startup if there are library updates: execute those updates.
      If such a message does not appear, then you could try “Sketch” -> “Include Library” -> “Manage Libraries” (can’t guarantee that will work, as I have not been able to test this).

      Copied from that page:

      Q: I get an error message that says: variable ‘message’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’: char message[] PROGMEM = “Hello!”;. What can I do?

      A: The latest avr-gcc compiler (used by Arduino 1.6.x) requires that variables in PROGMEM to be declared as const.

      First of all check if an updated version of the libraries used in the sketch has been released. Upgrading libraries is far the best way to solve the problem. If there are no alternatives you can go to the hard path and change the declaration in your sketch or in your library from

      char message[] PROGMEM = "Hello!";

      to

      const char message[] PROGMEM = "Hello!";
      Reply

      hans

  • Mar 2, 2016 - 9:25 AM - Ricardo R - Author: Comment Link

    I need to connect an RFID MFRC522 device with the network card, the ss MFRC522 is assigned to pin 8, the network card have the SS pin 10, even so I can not operate the MFRC522.

    Would I could give some help?

    ADMIN:

    Since the code was very long, I moved it to the forum. See this forum post.

    Please consider posting code and config files in the forum otherwise the comment section becomes too long.
    Feel free to post a question here with a link to the related forum though …

    Reply

    Ricardo R

    • Mar 2, 2016 - 9:42 AM - hans - Author: Comment Link

      Hi Ricardo,

      Sorry, had to move the code to the forum – it’s too long for comment.
      Others can read the code there if they would like to.
      I apologize for the inconvenience.

      Unfortunately, my RFID experience is minimal at best. Some one in the comments has been toying with RFIDs as well, and in the forum another user had RFID issues as well. Maybe these comments/posts are helpful.

      Reply

      hans

  • Mar 7, 2016 - 2:24 AM Comment Link
    PingBack: idehack.com

    […] Connecter le module Ethernet ENC28J60 à l’Arduino […]

  • May 5, 2016 - 6:58 AM Comment Link
    PingBack: digitalparts.net

    […] Arduino用ライブラリ(github)より利用可能 Web-Enable your Arduino with an Arduino ENC28J60 Ethernet shield …(Tweaking4All) […]

  • May 11, 2016 - 10:10 AM - Haitham Comment Link

    I have a problem when including the “ETHER_28J60 and Ethershield” library
    it can’t be used for libraries must not have any other carcters beside numbers and letters. and that’s waht’s been said 

    Reply

    Haitham

  • May 12, 2016 - 11:05 AM - Haitham Comment Link

    Hi 
    When defining the Mac adress here “byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 }; ”   

     did choose those numbers randomly”{ 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 }” or based on somthing else ? 
    Thank you 

    Reply

    Haitham

    • Jun 16, 2016 - 12:32 AM - Doctor Comment Link

      You can choose your own numbers.

      Reply

      Doctor

    • Jun 16, 2016 - 1:59 AM - hans - Author: Comment Link

      Thanks Doctor for chiming in.

      Indeed you can pick your own numbers, as long as it’s unique in your network.

      Reply

      hans

  • Jun 16, 2016 - 12:41 AM - Doctor Comment Link

    I need to use enc28j60 and NRF24l01+ via SPI, but there are some problems in libraries. I found many comments on Arduino forums about this but it was two years ago. First solution is to use Mirf library, but it’s less convenient than standard RF24 library. If anyone could help or can point me to important things about this please tell me about. Thanks!

    Reply

    Doctor

    • Jun 16, 2016 - 1:58 AM - hans - Author: Comment Link

      Hi Doctor,

      Since I have no experience with NRF23I01, I hope one of the other readers here will be able to assist or give you a hint in the right direction. Did you check GitHub and such as well?

      Reply

      hans

      • Jun 16, 2016 - 8:55 AM - Doctor Comment Link

        It’s looks like no new conversations about it since 2015, maybe I lose something important. I use actual libraries version. Singular workaround that I found is to use soft SPI. Anyway, thank you for response.

        Reply

        Doctor

        • Jun 17, 2016 - 5:31 AM - hans - Author: Comment Link

          You’re welcome Doctor – wish I could provide you with a helpful answer.
          I guess that’s the downside of open source … libraries like these can be abandoned. Then again; quite a few might seem abandoned but simply do not need any maintenance as they simply work …  

          Reply

          hans

    • Jun 16, 2016 - 2:07 AM - Doctor Comment Link

      In addition:

      Actually I used soft SPI for RF24 library as mentioned here, but it needs 3 additional pins.

      Reply

      Doctor

  • Jul 4, 2016 - 5:20 PM Comment Link
    PingBack: aprendiendoarduino.wordpress.com

    […] Y aun más… //www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/ […]

  • Aug 8, 2016 - 3:05 AM - Dennis Comment Link

    Thank you for this review, it is very informative!

    I am trying to make this work with Arduino Mega 2560 and ENC28j60 using the UIPEthernet library (latest release and/or forks) to run one of the Arduino Shield examples (“Web_Params”), replacing relevant includes with “#include <UIPEthernet.h>”. The problem I am facing happens during compilation, here is a bit of a stack trace I get:

    In file included from C:\Users\[USER]\Documents\Arduino\libraries\UIPEthernet\src/UIPEthernet.h:28:0,
    C:\Users\[USER]\Documents\Arduino\libraries\UIPEthernet\src/ethernet_comp.h:5:24: error: redefinition of 'class UIPClient'
     #define EthernetClient UIPClient
    C:\Program Files (x86)\Arduino\libraries\Ethernet\src/EthernetClient.h:8:7: note: in expansion of macro 'EthernetClient'
     class EthernetClient : public Client {

    Can you point me in the right direction of how to compile this?

    Thank you!

    Reply

    Dennis

    • Aug 8, 2016 - 3:54 AM - Dennis Comment Link

      Correction: the stack trace I get is from Webduino + UIPEthernet…

      Reply

      Dennis

    • Aug 8, 2016 - 5:24 AM - hans - Author: Comment Link

      Hi Dennis,

      I’m not familiar with Webduino, could it be that both libraries cannot work together?
      Or did you define “#define EthernetClient UIPClient” in your own code?
      Reply

      hans

      • Aug 8, 2016 - 11:00 AM - Dennis Comment Link

        Hi Hans, 

        Thank you for the quick reply!

        Webduino is considered to be a great high-level library (e.g. for creating RESTful APIs) and is listed on the official Arduino page. You might find it useful. Although it does not support the ENC28J60 chips, that’s why you need a wrapper such as UIPEthernet to make it work. I read this article where author mentions using them both (I am going to post this question there too):

        How to choose the right library to add ethernet (Enc28j60) to your Arduino

        And no, I don’t redefine class instances myself, just out-of-the-box example code…

        Reply

        Dennis

      • Aug 9, 2016 - 4:52 AM - hans - Author: Comment Link

        Thanks for the great info Dennis! 

        I’ll have to take a look, one of these days, as it might indeed make life a little easier…
        For now you could try removing the line 28 (?) from UIPEthernet.h that does the

        #define EthernetClient UIPClient

        See what happens? I know this sounds like a “stupid” way to work around it, but it might be worth a try.
        A quick glance on the articles you’re referring to, gave me the impression that the code was written to try several ethernet/wifi modules. Maybe the author overlooked this, or … an older/newer version of UIPEthernet changed.

        Reply

        hans

  • Sep 7, 2016 - 1:40 AM - Gareth Comment Link

    At last, an ENC28J60 post that is thorough. Some insist that 5v will damage the module.

    Reply

    Gareth

    • Sep 7, 2016 - 7:53 AM - hans - Author: Comment Link

      Thank Gareth!

      Yeah, I had to figure out most of it myself as well – lack of information is definitely a problem for this card.
      Thanks for the heads up! I was not aware of the possible 5V issue, maybe this applies to newer models? Mine works just fine with 5V.

      Reply

      hans

  • Oct 19, 2016 - 4:29 AM Comment Link
    PingBack: learn.linksprite.com

    […] This is a good tutorial as well: //www.tweaking4all.com/hardware/arduino/ardui… […]

  • Dec 9, 2016 - 8:27 AM - cassyarduino Comment Link

    Hi All!

    New (modified) UIPEthernet library available:https://github.com/UIPEthernet/UIPEthernet

    Support more MCU-s: AVR(atmel atmega-s),STM32F,ESP8266.

    I modified the following:
    – Set the version to 1.1.0
    (This version tested on ESP8266 too. Working properly. Without watchdog resets.)
    – Correct ESP8266 exception(28).
    – Add watchdog reset calls in functions for stable running on ESP8266.
    – Add geterevid function to get ENC28j60 chip erevid (revision information).
    – Change linkStatus to static for outside call.
    – Add functions bypass, if can’t communicate with ethernet device.
    – Add SPI bus instabil communication detection.
    – Change debuging/logging. Remove individual debuging. Add global and scalable debuging feature.
    You can setup debuging/logging level in utility/logging.h
    You can use this header file in Your scetch too.
    Add “LogObject” define for serial logging/debuging with board specific default setting.

    You can find wiring too in hardware directory.

    Best Regards

    Reply

    cassyarduino

  • Dec 15, 2016 - 9:55 AM - cassyarduino Comment Link

    Hi All!

    I added support to MBED/SMeshStudio IDE.
    Compiled to STM32F103RB (Nucleo).
    You can download from:https://github.com/UIPEthernet/UIPEthernet

    Best Regards

    Reply

    cassyarduino

    • Dec 15, 2016 - 11:19 AM - hans - Author: Comment Link

      Thanks Cassyarduino for all your work, and for keeping us up to date – excellent! 

      Reply

      hans

  • Dec 29, 2016 - 7:29 AM - cassyarduino Comment Link

    Hi All!

    New version (1.2.1) available: https://github.com/UIPEthernet/UIPEthernet/archive/master.zip

    – Added Abstract Print class to MBED for full compatibility (Can use print, println with uip objects.)

    – All examples working properly with MBED compiler too.

    Best regards

    Reply

    cassyarduino

  • Feb 14, 2017 - 7:11 AM - cassyarduino Comment Link

    Hi All!

    New UIPEthernet release is available (2.0.3).

    Added support for Intel ARC32, Nordic nRF51, and Teensy boards.
    The Errata#12 corrected.

    The Issues corrected.

    You can download from: https://github.com/UIPEthernet/UIPEthernet/archive/v2.0.3.zip

    and from: https://github.com/UIPEthernet/UIPEthernet/archive/master.zip

    Best Regards

    Reply

    cassyarduino

  • Mar 5, 2017 - 8:00 AM - AuLeeFor Comment Link

    Dude, thank you very much. Nice job ! It’ll save me lot of headache. Cheers ! 

    Reply

    AuLeeFor

  • Mar 12, 2017 - 4:01 PM - john Comment Link

    Hello, 

    Please help me with my issue.

    I use latest release Arduino 1.8.1; a Nano v3.0 board (atmel 328); and a HR911105A 16/38 Nano Ethernet Shield v1.0

    I used the UIPEthernet library from this website and also the code example https://www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/#uipethernet

    I got the below error. I opened Enc28J60Network.h file and tried to add my ethernet chip but I am so noob. Please advise me what to do.

    In file included from /Users/john/Documents/Arduino/libraries/UIPEthernet/UIPEthernet.h:35:0,

                     from /var/folders/bd/pzwcmknd3bd_c10t4kwkq_hc0000gn/T/arduino_modified_sketch_470931/EchoServer.ino:1:

    /Users/john/Documents/Arduino/libraries/UIPEthernet/utility/Enc28J60Network.h:99:8: warning: #warning “Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in ‘utility/Enc28J60Network.h’.” [-Wcpp]

           #warning “Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in ‘utility/Enc28J60Network.h’.”

            ^

    In file included from /Users/john/Documents/Arduino/libraries/UIPEthernet/UIPClient.h:37:0,

                     from /Users/john/Documents/Arduino/libraries/UIPEthernet/UIPEthernet.h:41,

                     from /var/folders/bd/pzwcmknd3bd_c10t4kwkq_hc0000gn/T/arduino_modified_sketch_470931/EchoServer.ino:1:

    /Users/john/Documents/Arduino/libraries/UIPEthernet/utility/logging.h:24:2: warning: #warning “You can configure LogObject and ACTLOGLEVEL in ‘utility/logging.h’. More verbosity more memory usage.” [-Wcpp]

     #warning “You can configure LogObject and ACTLOGLEVEL in ‘utility/logging.h’. More verbosity more memory usage.”

      ^

    Sketch uses 17874 bytes (58%) of program storage space. Maximum is 30720 bytes.

    Global variables use 1353 bytes (66%) of dynamic memory, leaving 695 bytes for local variables. Maximum is 2048 bytes.

    Reply

    john

    • Mar 12, 2017 - 5:13 PM - hans - Author: Comment Link

      Hi John,

      well, we all have been (and sometimes still are, me included) noobs … 

      First of all, I’m not familiar with the Nano Ethernet shield you are using, so I’d first verify that it’s really using the ENC28J60.

      Second point, you wrote “I opened Enc28J60Network.h file and tried to add my ethernet chip“, it is not custom to edit library files – unless you really know what you’re doing. So please do not edit library files – you’ll have to do everything in your sketch, and should never have to edit any of the library files. To undo your changes, unless you know exactly what line you modified, please reinstall UIPEthernet. While you’re at it, consider downloading the latest version from Github.

      When I look at your “error” messages; they seem to be only warnings. Did the Arduino IDE upload the code?

      Reply

      hans

      • Mar 12, 2017 - 7:55 PM - John Comment Link

        Hello Hans, 

        Thank you very much for helping me. 

        1. My ethernet shield is exactly like this one http://m.ebay.co.uk/itm/Mini-ENC28J60-Webserver-module-Ethernet-Shield-board-for-Arduino-Nano-/272093489973?hash=item3f5a092b35%3Ag%3APJoAAOSw5ZBWQ5gn&_trkparms=pageci%253A53659db3-0786-11e7-ba0a-74dbd18078e8%257Cparentrq%253Ac5205ae915a0a6a8e7d5006bfff773bd%257Ciid%253A1

        2. These errors I get before editing the libray(with a clean one and updated 2.0.3)

        3. My arduino ide is uploading the code but nothing happens on the serial monitor (baud is set accordingly) or in browser ( i looked in my router software to see if any new ip connected to my local lan) 

        Reply

        John

      • Mar 13, 2017 - 1:11 AM - john Comment Link

        Also I forgot to mention that when I upload the code I got this message:

        Sketch uses 17444 bytes (56%) of program storage space. Maximum is 30720 bytes.

        Global variables use 1082 bytes (52%) of dynamic memory, leaving 966 bytes for local variables. Maximum is 2048 bytes.

        Invalid library found in /Users/john/Documents/Arduino/libraries/arduino_uip: /Users/john/Documents/Arduino/libraries/arduino_uip

        Invalid library found in /Users/john/Documents/Arduino/libraries/arduino_uip: /Users/john/Documents/Arduino/libraries/arduino_uip

        Reply

        john

        • Mar 13, 2017 - 10:05 AM - hans - Author: Comment Link

          Hi John,

          So if I understand you correctly, it is an ENC28J60, sketch upload works, the program just doesn’t seem to do anything.
          And … you get an invalid library error. Hmm, that is definitely a problem. Not sure why it would say that though.

          Easiest fix: remove Arduino IDE, remove the directory /Users/john/Documents/Arduino, reinstall Arduino, reinstall UIPEthernet.
          Just to make sure there is no misconfiguration.

          Reply

          hans

          • Mar 14, 2017 - 4:36 PM - john Comment Link

            Hi Hans,

            I followed your suggestion and removed all. 

            After that I reinstalled all (Arduino IDE 1.8.1 and the UIPEthernet library from your location – Github).

            On Windows all is working perfect now.

            On OSX I still have the following warning, but the sketch upload works and the code is fully functional after upload.

            /var/folders/bd/pzwcmknd3bd_c10t4kwkq_hc0000gn/T/arduino_modified_sketch_641225/HelloWorld.pde: In function 'void loop()':
            /var/folders/bd/pzwcmknd3bd_c10t4kwkq_hc0000gn/T/arduino_modified_sketch_641225/HelloWorld.pde:28:41: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
                 ethernet.print("<H1>Hello John</H1>");
                                                     ^

            Your suggestion and library SOLVED my problem.

            Thank you very much! God bless you Hans!

            john

          • Mar 15, 2017 - 8:50 AM - hans - Author: Comment Link

            Awesome! Glad to hear you’ve got it to work.
            Strange that the code compiles under Windows just fine but gives an error message under OS X. Weird.
            However, it’s just a warning so it compiles and gets uploaded I assume …?

            hans

  • Apr 27, 2017 - 3:07 PM - Harry Comment Link

    Thanks his article very help me in trying ENC28J60 with arduino uno, hopefully future can help develop library ENC28J60

    Reply

    Harry

  • Sep 2, 2017 - 9:06 AM - jim Comment Link

    hi everyone 

    i have connect an arduino nano to ENC2860 but i cant ping my coded ip 

    can help me ?

    Reply

    jim

    • Sep 10, 2017 - 3:39 PM - hans - Author: Comment Link

      Hi Jim,

      by the best of my knowledge, Ping depends on the library implementation since the hardware is super limited when it comes to the stack implementation (hence it’s lower price tag I assume). Not sure if the UIPEthernet library even supports this (even though I’ve found it to be one of the best out there for the ENC2860).

      Reply

      hans

  • Sep 10, 2017 - 5:54 AM Comment Link
  • Dec 12, 2017 - 3:32 AM - Cris Matthew Comment Link

    Hello..!! How can i use Ethernet Shield ENC28J60 with Grove Serial Camera?.

    Reply

    Cris Matthew

    • Dec 13, 2017 - 3:10 PM - hans - Author: Comment Link

      Hi Cris,

      I have not yet played with the Grove Serial Camera (I had to Google it and found this), so I wouldn’t know if it can be used together and how. 
      Sorry.

      Reply

      hans

  • Jan 25, 2018 - 11:56 AM - Sadie Comment Link

    Thanks for this!

    Reply

    Sadie

    • Jan 25, 2018 - 12:42 PM - hans - Author: Comment Link

      Thank you Sadie for taking the time to post a Thank-You note! It’s much appreciated! 

      Reply

      hans

  • Apr 14, 2018 - 4:37 AM - ramin Comment Link

    Hi, I want to make sure my ethernet is still working and one way to do that is to reinitialize it but after doing this my package lost increased.

    the problem is this code

    ether.begin(sizeof Ethernet::buffer, mymac) == 0

    I think every time I recall this line the package lost is increasing. How can I fix the problem, I can’t reinitiate the ether class becuase it is global class.

    bool checkEthernetControllerAccess()
    {
        bool result;

        pinMode(PIN_ETHER_RESET, OUTPUT); // this lets you pull the pin low.
        digitalWrite(PIN_ETHER_RESET, LOW); // this resets the ENC28J60 hardware
        delay(100); // this makes sure the ENC28j60 resets OK.
        digitalWrite(PIN_ETHER_RESET, HIGH); // this makes for a fast rise pulse;
        pinMode(PIN_ETHER_RESET, INPUT); // this releases the pin,(puts it in high impedance); lets the pullup in the board

     

        if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
        {

    #if DEBUG == 1
            Serial.println(F(“Failed to access Ethernet controller”));
    #endif

            result = false;
        }
        else
        {

    #if DEBUG == 1
            Serial.println(F(“Connected to Ethernet controller”));
    #endif

            result = true;
        }

        delay(500);
        if (result == true)
            initializeEthernet();

        IsEthernetControllerAccess = result;

        return result;
    }

    void initializeEthernet()
    {

        ether.staticSetup(myip, gwip, dns, mask);

        timer = 0; // start timing out right away

    #if DEBUG == 1
        ether.printIp(“IP:  “, ether.myip);
        ether.printIp(“GW:  “, ether.gwip);
        ether.printIp(“netmask:  “, ether.netmask);
       
    #endif

    }

    Reply

    ramin

    • Apr 16, 2018 - 7:49 AM - hans - Author: Comment Link

      Hi Ramin,

      this seems like a pretty extensive way of working with the ENJ.
      I used UIPEthernet and did it this way:

      if (!client.connect(server, 80)) {
            // Serial.println("-> Connection failure detected: Resetting ENC!"); 
            Enc28J60.init(mac);
          } else {
            client.stop();
          } 
      Reply

      hans

      • Apr 16, 2018 - 8:30 AM - ramin Comment Link

        Thanks, I will try it.

        I did this way:

        if (FailedConnectionTimeout >= 30)
            {
                resetFunc();  //call reset
            }

        void(*resetFunc) (void) = 0; //declare reset function @ address 0

        Reply

        ramin

  • May 19, 2018 - 3:21 PM - Alejandro Nicolas Sanchez Taccone Comment Link

    I love u!!!!
    2 hours trying to makes work an ENC28j60 with an arduino Mega2560!!!
    many libraries incompatibles. UIPEthernet:and your example make it work!

    Thanks!!!!!

    Reply

    Alejandro Nicolas Sanchez Taccone

    • May 20, 2018 - 10:06 AM - hans - Author: Comment Link

      Hi Alejandro!

      Thank you for taking the time to post a thank-you! Awesome!
      Glad to hear you got things going and the article has been helpful! 

      Reply

      hans

  • Jun 3, 2018 - 8:45 PM - Jonas Sorgenfrei Comment Link

    Hey,

    I got the Nano ethernet sield v1.0 as well.

    I tried your 1. code and it was working.

    I tried it now again, but it now it sends only those packages out the whole time:

    No.     Time           Source                Destination           Protocol Length Info
       2612 142.948460     54:55:58:10:00:24     54:55:58:10:00:24     0x0000   74     Ethernet II

    Frame 2612: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface 0
    Ethernet II, Src: 54:55:58:10:00:24 (54:55:58:10:00:24), Dst: 54:55:58:10:00:24 (54:55:58:10:00:24)
        Destination: 54:55:58:10:00:24 (54:55:58:10:00:24)
            Address: 54:55:58:10:00:24 (54:55:58:10:00:24)
            …. ..0. …. …. …. …. = LG bit: Globally unique address (factory default)
            …. …0 …. …. …. …. = IG bit: Individual address (unicast)
        Source: 54:55:58:10:00:24 (54:55:58:10:00:24)
            Address: 54:55:58:10:00:24 (54:55:58:10:00:24)
            …. ..0. …. …. …. …. = LG bit: Globally unique address (factory default)
            …. …0 …. …. …. …. = IG bit: Individual address (unicast)
        Type: Unknown (0x0000)
    Data (60 bytes)

    0000  00 00 00 3c 00 00 40 00 40 00 fc 6d c0 a8 01 02   …<..@.@..m….
    0010  c0 a8 01 02 00 50 00 50 00 00 00 27 00 00 00 27   …..P.P…’…’
    0020  50 19 00 00 0b 5e 00 00 3c 48 31 3e 48 65 6c 6c   P….^..<H1>Hell
    0030  6f 20 57 6f 72 6c 64 3c 2f 48 31 3e                           o World</H1>
        Data: 0000003c000040004000fc6dc0a80102c0a8010200500050…
        [Length: 60]

    I even can’t “ping” it anymore nor visiting the side using a web browser.

    I think it’s may be broken…

    Or does any one has an Idea?

    Kind Regards

    Jonas

    Reply

    Jonas Sorgenfrei

    • Jun 4, 2018 - 4:38 PM - hans - Author: Comment Link

      Hi Jonas,

      I’m not sure what kind of data I’m looking at, except that it suggests that source and destination are the same (54:55:58:10:00:24).
      My only suggestions would be:

      1) Full reset of the shield if you can, or power everything down and disconnect the shield from your Arduino AND your Ethernet cable.
      2) Verify your code (source vs destination, default gateway, etc).
      3) Verify your ethernet cable (or test with another cable to be sure).

      Wish I could be more helpful, maybe some else is more familiar with this specific setup?

      Reply

      hans

  • Oct 4, 2018 - 3:48 PM - Holger Dorman Comment Link

    The library DOWNLOAD – ETHER_28J60 and Ethershield doesn’t work. Already at the first compiler run an error occurs the a function in not correct declared : 

    sketch\ip_arp_udp_tcp.c:444:59: error: unknown type name ‘prog_char’ uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s)

    Is any version available, which is working fine?

    Regards Holger 

    Reply

    Holger Dorman

    • Oct 5, 2018 - 3:05 AM - hans - Author: Comment Link

      Hi Holger,

      sorry to hear you’r running into issue – I haven’t used the library in a while (for the latest version see the GitHub page).

      A quick Google did show me that there may be a possible issue;

      Did you properly install the Arduino IDE (you did not mention the platform you’re running – eg. Windows/Mac/Linux)? Running it from your Downloads directory may cause issues. Another issue is that the library is old and no longer maintained; “prog_char” is no longer used, it is now “const char *progmem_s” – Consider using UIPEthernet as it may be the better choice.

      Hope this helps. 

      Reply

      hans

  • Oct 7, 2018 - 11:45 AM - Holger Comment Link

    Hi Hans,

    thanks for you feedback. Meanwhile I made some researches with the following results:

    1. Measure the supply voltage 3.3V on the shield

    Result: It drops done to 2.2V at my “China Arduino Nano” if I connect the shield. Therefore I used an original Italian one. Result: 3.08V which should be in the range of the 28J60 Chip

    2. Replacing the shield

    Do to the fact, that the shield still doesn’ t work with the 3.08V, I swapped the shield. Now this shield is working fine with the library UIP-Ethernet. But in contrast the Ethercard library doesn’t work, although I used Pin 8 for Chip-Select.

    Do you know another source of libraries, because the compiled result of the UIP-Ethernet library use 58% of my available memory size?

    Regards

    Holger 

     

     

    Reply

    Holger

    • Oct 7, 2018 - 3:23 PM - hans - Author: Comment Link

      Hi Holger,

      Glad you gad something to work – yeah the voltage difference can be a pain, especially with clone Arduino’s (there are more problems with some of the clones).
      UIP-Ethernet was the smallest library I had found at the time.
      If I’d be doing something with networking, I may consider starting with one of those ESP8266 boards (on it’s own, and not as a shield for an Arduino).
      But I haven’t worked on those … yet … I have 2 ready to play with, but for some mysterious reason I keep running out of time in a day  – too many fun projects to do.

      Reply

      hans

      • Oct 8, 2018 - 3:03 PM - Holger Dorman Comment Link

        Hi Hans,

        I replaced the shield, that means the left one on your figure 2. With this, I can also use the small library  “Ethercard” without problems. This shield has an voltage regulator which supplies the ENC28J60 Chip with 3.3V from a 5V input.  Now for me I have to work on the  EMC protection of the Arduinio circuit, because I use it to control and configure a radio transmitter.

        Thanks much for your help and have nice time.

        Regards Holger

        Reply

        Holger Dorman

  • Feb 24, 2019 - 5:28 PM - Tom Comment Link

    Hi Hans,

    I am trying to implement a small application, which reads data from a web-browser with the library <ethercard>.. After installing the library the folling example script works fine. Thant means it prompts “NOW IT

    WORKS”. But how can I read characters which I enter on the web browser?

    #include <EtherCard.h>
    // Ethernet IP, default gateway and MAC addresses
    static byte myip[] = { 192,168,0,200 };
    static byte gwip[] = { 192,168,0,1 };
    static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

    byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

    const char page[] PROGMEM =
    “HTTP/1.0 503 Service Unavailable\r\n”
    “Content-Type: text/html\r\n”
    “Retry-After: 600\r\n”
    “\r\n”
    “<html>”
      “<head><title>”
        “Hello World!”
      “</title></head>”
      “<body>”
        “<h3>NOW IT WORKS</h3>”
      “</body>”
    “</html>”;

    void setup(){
      Serial.begin(57600);
      Serial.println(“\n[Hello World]”);

      if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
        Serial.println( “Failed to access Ethernet controller”);
      ether.staticSetup(myip, gwip);

      ether.printIp(“IP:  “, ether.myip);
      ether.printIp(“GW:  “, ether.gwip); 
      ether.printIp(“DNS: “, ether.dnsip); 
    }

    void loop(){
      // wait for an incoming TCP packet, but ignore its contents
      if (ether.packetLoop(ether.packetReceive()))
         {
           memcpy_P(ether.tcpOffset(), page, sizeof page);
           ether.httpServerReply(sizeof page – 1);
         }    
    }

    Reply

    Tom

    • Feb 25, 2019 - 3:12 AM - hans - Author: Comment Link

      Hi Tom!
      Reading data entered on the webpage/browser is a little more complicated and is probably a topic for the forum.
      To begin with, the webpage needs to have a HTML

      , you may have to read up on that.
      Once data arrives at the Arduino, you’ll have to dissect it and define the appropriate actions in your code.
      Unfortunately, I do not have a simple example handy …
      Reply

      hans

  • Mar 3, 2019 - 2:17 PM - Stephan Comment Link

    Configuration: Arduino Nano clone + ENC28J60 Ethernet Shield for Arduino Nano 3.0 RJ45 Webserver Module (V1.0) + Nano I/O Sensor Shield Modul for Arduino UNO R3 Nano V3.0

    As I used the UIPEthernet library with my Arduino Nano clone, everything worked fine – at first.

    Problems accured, when I wanted to use the D2 for a digital input with interrupts. As there were no schematics for the ENC28J60 Ethernet Shield, it took me some time to find out, that the D2 is used as interrupt-line for the Ethernet Shield. Even if it is not used, it pulls the level to High.

    The only solution is to use D3 as digital input with interrupts:

    const byte interruptPin = 3; // Pin with Data (2 is used by LAN)
    pinMode(interruptPin, INPUT);
    attachInterrupt(digitalPinToInterrupt(interruptPin), interruptroutine, CHANGE);
    Reply

    Stephan

  • Mar 12, 2019 - 3:25 AM - bikram Comment Link

    hello…:)…i am newer to arduino ..and i want to do a project with em18 reader and hr911105a 18/20 ethernet using arduino nano…i have done with my code…when i put card on em18 reader it sends to the server but always response false but against the card no i have code the ok response…please help me….

    #include <EtherCard.h>
    

    int count = 0; // count = 0

    char input[12]; // character array of size 12 

    boolean flag = 0; // flag =0

    // ethernet interface mac address, must be unique on the LAN

    static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

    byte Ethernet::buffer[700];

    unsigned long timer;

    //const char state = 0;

    ( *** code reduced in size *** )

    static void ethernet_callback(byte status, word off, word len) {

    Serial.println(">>>");

    Ethernet::buffer[off+300] = 0;

    Serial.println((const char*) Ethernet::buffer + off);

    }

    Reply

    bikram

    • Mar 12, 2019 - 9:20 AM - hans - Author: Comment Link

      Hi Bikram,

      welcome to Tweaking4All. 

      Since your project is going off topic (RFID card reader and different Ethernet shield), please start a topic in the forum.
      Feel free to post the link to the forum topic here, so others can see it and chime in …

      Reply

      hans

      • Mar 13, 2019 - 1:00 AM - bikram Comment Link

        sorry  for discussion  about off topic…..:)…can you please  tell me how to send any data to server  and get a return using hr911105a 18/20 this module …….please help

        Reply

        bikram

      • Mar 14, 2019 - 5:43 AM - hans - Author: Comment Link

        No worries 

        I’m not familiar with the “hr911105a 18/20”, but if you’d like to see an example on how to pull or push data with the shield used in this article, then please check out these articles: 

        – Pulling data from your Arduino (the server picks it up from the Arduino) and
        – Pushing data to a (PHP) server (probably more relevant for your question: push data from the Arduino to a server).

        I hope this gets you started in the right direction.

        Reply

        hans

  • Jul 27, 2020 - 7:04 AM - Bob Comment Link

    HI and thanks for a VERY usefull thread!

    Im settup a remote way of reading voltage and current via ethernet using Nano Every and Deek Robot ethernet shield ( ENC28J60) and the UIPEthernet library.

    After lost of strugling and swearing (I’m totally new to Arduino’s!!) I’ve eventually go it to act as a web server buy disconnecting pins D8 and D10 between the 2 and taking pin 8 from the Nano Every to pin 10 on the shield.

    I understand that the CS pin “should” be configurable on the Every but I can’t figure out how…

    for testing I’m using the “Tweaking4All.com – Temperature Drone – v1.0” sketch

    Your help would be appreciated.

    Bob

    Reply

    Bob

    • Jul 28, 2020 - 6:05 AM - Hans - Author: Comment Link

      Hi Bob,

      haha, I can totally relate to the struggling and swearing 

      As I’ve started playing with an ESP8266 as an Arduino replacement, I can say that for only $5 a piece, I can highly recommend looking into that.
      That aside … over the years I have found the ENC28J60 to be not so reliable when it comes to staying connected.
      Another note is that I’m not familiar with the Nano Every, but for now I’ll just assume this works similar to the Uno (in a smaller form factor?).

      I just looked at the wiring (I assume you used figure 3 of this article); I’m a little confused what you mean. This is probably because I haven’t done much with the ENC in a while.
      Could you elaborate (apologies from my end)?

      Reply

      Hans

  • Jul 28, 2020 - 6:25 AM - Bob Comment Link

    Thanks for the reply Hans,

    Unfortunately your link didn’t work for me, but if you mean this one My eBay Ethernet module (Deek Robot Nano Ethershield)

    then Yes (almost)!

    The shield sits below the Nano so all pins are connected through and what I’ve done is bend Nano pins 8 and 10 out at 90 deg so they don’t plug in. Then a jumper from Nano Every pin D8 to D10 on the shield and that works.

    I have found reference in posts about the other library’s (that are no longer supported!) for this shield about being able to change the CS pin on the NANO to suit the shield but can find nothing for the UIPEthernet library!

    Reply

    Bob

    • Jul 28, 2020 - 6:56 AM - Hans - Author: Comment Link

      Ah OK, now I’m getting it 
      Trying to find an answer, I did find this post on the GitHub page of UIPEthernet. It’s a little messy, but it seems that there may be a trick that could work for you.
      Especially as of this comment (on that same GitHub page) things may become interesting for your issue.

      Reply

      Hans

    • Jul 28, 2020 - 6:57 AM - Hans - Author: Comment Link

      p.s. apologies for pointing you to another resource – I haven’t done something like this and the link seems to provide useful info.

      Reply

      Hans

  • Jul 28, 2020 - 8:14 AM - Bob Comment Link

    Sorry Hans, you’ve lost me completely 

    Looking at the Nano Every drawings it shows SS as pin D8 but theres no ident against D10 so what would I use as an identifier and where about in the sketch does that go?

    I’m trying to keep the footpring as small as possible so mounting them side by side and jumpering is not really an option.

    Reply

    Bob

    • Jul 28, 2020 - 8:56 AM - Hans - Author: Comment Link

       I can totally understand that … I have to pay attention with this as well to not lose track ….

      If I understand things correctly …

      As I understand, UIPEthernet expects pin 10 (CS) to be used for SS. This is most likely defined as a fixed value in the library.
      After installing and looking at the files: in the directory for the UIPEthernet library, there is a subdirectory called “utility” which holds the file “Enc28J60Network.h“.
      In this file, the developer defines the used pins, pin 10 included.

      If I’m correct (apologies for not having my gear near me to check it out) we are looking for the place where “ENC28J60_CONTROL_CS” is being defined (from what I gathered out of that article).

      So when looking at that file (granted, this can be somewhat confusing), I see that it first tries to use the value SPI_CS (line #56).

      #define ENC28J60_CONTROL_CS SPI_CS

      Now, granted, I have no idea where SPI_CS comes from or what it’s value is (I assume this value will be different per Arduino board model?).

      An interesting to test do: see if you can print the default value for SPI_CS with Serial.println(SPI_CS); (debug monitor).

      Now we could try defining SPI_CS before including the UIPEthernet library, something like this:

      #define SPI_CS 8
      #include <UIPEthernet.h>
      ...

      This however will most likely throw and error, again: not sure since I do not know where and if SPI_CS is defined.
      The comment suggests, from what I understand, is modifying the library file. Personally I wouldn’t do that, as it will cause problems after future updates of the library.

      In C it is not uncommon to use the #undef statement, so maybe this works:

      #undef SPC_CS
      #define SPI_CS 8
      #include <UIPEthernet.h>
      ...

      I’m not sure if this will work (never tried it on an Arduino) and we may have to glue and “if” around it, for cases where SPI_CS wasn’t defined to begin with (but then the simple “#define SPI_CS 8” would have worked right away). This could look something like this:

      #ifdef SPC_CS
        #undef SPC_CS
      #endif
      #define SPI_CS 8
      #include <UIPEthernet.h>
      ...

      Again: I do not have the means handy to test this idea.

      If all of this throws an error, then another option would be to just define “ENC28J60_CONTROL_CS” straight (assuming line #29 [“#if defined(__MBED__)“] failed in the library file).
      You’ll see at line #73 that it checks if “ENC28J60_CONTROL_CS” is not defined [#if !defined(ENC28J60_CONTROL_CS)].
      So if we do this (before the library include!), then this may work as well:

      #define ENC28J60_CONTROL_CS 8
      #include <UIPEthernet.h>
      ...

      It’ll be a matter of trial and error.

      Note: the reason we define this before including the library, is so our changes will be used in the library.

      I’m pretty sure you’re now even more confused haha … hope this helps a little though

      Reply

      Hans

      • Aug 1, 2020 - 2:27 PM - Bob Comment Link

        Hi Hans,

        Appologies for taking so long to respond, I had to do some Work 

        Anyway, I’ve tried all of the above and with the exception of the “serial.println” nothing threw errors and nothing worked!

        I should point out that the Nano Every wants to use Data 8 but the Shield’s expecting Data 10… (I did adjust the commands accordingly!)

        Interestinly, I tried this #define ENC28J60_CONTROL_CS     PIN_D10 before the #INCLUDE and went to upload. Upload stuck at “Uploading to I/O Board”

        Any thoughts?

        In the statement

        #if !defined(ENC28J60_CONTROL_CS)

        there is a line

         #warning “Using LEONARDO borad PIN_A10 for ENC28J60_CONTROL_CS. Use UIPEthernet::init(uint8_t) to change it.”

        I’ve no idea how to use that, I’m hoping you do….

        Bob

        Reply

        Bob

        • Aug 2, 2020 - 2:29 AM - Hans - Author: Comment Link

          No worries Bob, I too have work at times that prevents me from jumping into my hobby projects as well 

          It looks like changing the CS pin is supported in an easier way, that I wasn’t aware of.
          Being unable to dig into it at the moment (about to walk out of the door), but before calling Ethernet.begin(), you may be able to call Ethernet.init( PIN );.
          Where “PIN” is the number of the pin you’d like to use.

          Worth a try (and you can skip the earlier discussed DEFINE and such).

          Reply

          Hans

        • Aug 2, 2020 - 2:29 AM - Hans - Author: Comment Link

          Reference in the changed code of UIPEthernet.

          Reply

          Hans

          • Aug 2, 2020 - 4:27 AM - Bob Comment Link

            Morning Hans,

            Sounds promising, but, looking at the linked code, I’m confused how to enter the pin number…

            I need to use Digital pin 10 so would that be D10 or are all pins called A…. ?

            Sorry for all the dum questions

            Bob

            Bob

          • Aug 4, 2020 - 10:34 AM - Hans - Author: Comment Link

            Hi Bob,

            apologies for the late reply – I’ve been traveling.
            And … you don’t have to apologize for the questions.

            I’m guessing the naming of the pins (I never really use the “official” naming) can be ignore. Just use the value 10 for PIN and give that a try.

            So replace Ethernet.begin(); with:

            Ethernet.init( 10 );
            Ethernet.begin();

            At least, that’s what I would try.

            Hans

  • Aug 11, 2020 - 7:27 AM - Bob Comment Link

    Hi Hans,

    Well the good news is that worked and I’ve now got the shield on top of the Nano Every with all pins connected and even a I2C display connected and everything works….

    I just need to build the rest of the hardware and get the sketch written to complete the project….. ONLY!!!

    Thanks again for your help

    Bob

    Reply

    Bob

    • Aug 18, 2020 - 3:33 AM - Hans - Author: Comment Link

      Haha  – good to hear things work now, glad I could be of some sort of help! 

      p.s. if you like, post your project in the forum once you’re done (totally optional of course).

      Reply

      Hans

      • Aug 18, 2020 - 5:56 AM - bOB Comment Link

        Morning Hans,

        I found another problem that I know you can’t help with….

        Did you know that Arduino’s run on smoke???

        I mistakenly connected 12V to one of the digital pins, the smoke escaped from the processor chip and it does not work any more…. Strange (DUH!!!!!)

        New one’s due tomorrow so I should be able to progress further then..

        Thanks again

        Bob

        Reply

        bOB

      • Aug 18, 2020 - 6:10 AM - Hans - Author: Comment Link

        Haha, the build in smoke generator – cool feature right? 

        Sorry to hear that you blew up your Arduino though   … interesting alternative: ESP8266 (about $5, tiny, much faster and much more memory).

        Reply

        Hans

  • Mar 14, 2021 - 3:26 PM - Husam Comment Link

    Hello 

    In udpServer (udpListner) Example, how can I reply any message to the client After I receive message from it?
    I Have Arduino Project with two way communication 

    Thank you for the nice library by the way 

    Reply

    Husam

    • Mar 15, 2021 - 7:36 AM - Hans - Author: Comment Link

      Hi Husam,

      I do not have an example for that – and I carefully assume you’re referring to the ETHER_28J60 library?
      This library is no longer under active development (Github).
      On that note, that using an ENC28J60 is at this time is something I can no longer recommend (due to proven instabilities).

      Maybe the project examples are helpful in case you’d like to proceed?

      Reply

      Hans

      • Mar 15, 2021 - 8:16 AM - Husam Comment Link

        Hello Hans, 

        Thank you for the response. 
        Yes I ment to use your libraray for ENC28J60, 
        Yesterday I tested the udpListner example and  it it’s working greate. 
        since you do not recommend ENC28J60 I think I will move to wiznet w5500 but it’s doubled priced.

        I will try by my self to reply the message to the client since all my hardware setup is ready

        Thank you again.

        Reply

        Husam

      • Mar 15, 2021 - 8:22 AM - Hans - Author: Comment Link

        I’d actually recommend getting an ESP8266 (see this article to get started – less than $5 per board).
        Those are very cheap, and completely replace the Arduino. It has very solid build-in WiFi, more memory and faster than most Arduino’s.

        Reply

        Hans



Your Comment …

Do not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.