Page 1 of 1

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

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

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.

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

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
Size: 23.6 KiB
Date: March 23, 2014
 Download Now 


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
Size: 92.7 KiB
Date: March 23, 2014
 Download Now 


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

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
Version: 1.01
Size: 99.6 KiB
Date: March 23, 2014
 Download Now 


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");
  }
}

Donation options


Donations are very much appreciated, but not required. Donations will be used for web-hosting expenses, project hardware or a motivational boost (a drink or snack). Thank you very much for those have donated already! It's truly AwEsOmE to see that folks like our articles and small applications.

Comments


There are 136 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

  • 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
  • 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



Your Comment …

Friendly request to 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.
Tweaking4All will never share your email address with others.