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](//www.tweaking4all.com/wp-content/uploads/2014/03/rj45-connector-391x280.jpg)
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](//www.tweaking4all.com/wp-content/uploads/2014/03/enc28j60-shield-variations-800x265.jpg)
ENC28J60 – Two examples of variations
Ad Blocking Detected Please consider disabling your ad blocker for our website.
We rely on these ads to be able to run our website.
You can of course support us in other ways (see Support Us on the left).
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)](//www.tweaking4all.com/wp-content/uploads/2014/03/nano-ethernet-shield-deek-robot-400x138.jpg)
My eBay Ethernet module (Deek Robot Nano Ethershield)
![My Arduino with ENC28J60 - A wiring example](//www.tweaking4all.com/wp-content/uploads/2014/03/arduino-enc28j60-wiring-308x280.jpg)
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
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.
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.
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");
}
} |
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.
hello …
‘m newbie would like to know if it is possible to send some data from the serial port to the client
Erick Alves Teixeria
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)
hans
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!
Bob
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?
hans
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.
Eduardo
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.
hans
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?
hans
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,
Eduardo
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.
hans
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
}
Adrian Miron
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.
hans
[…] Need more information on or sample code? I found the best information about using this module is here: tweaking4all.com […]
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)
Fred
Thanks Fred for the additional info! Much appreciated!
hans
Another good option is just change the library.
Look for “CS”, and you will get the Pin = 8, so change and save.
Edson Sobreira
Thanks, this with 5V helped me! As well as pin 10. Thanks!
Helge
hans
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
ben
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.
hans
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.
Stephan
Thanks for the tip Stephan!
hans
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
Lars
Thanks Lars for leaving a positive feedback
… it’s much appreciated!
hans
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??
Brian Wayne
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):
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):
hans
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? ??
Brian Wayne
I’m not sure what you mean … ?
hans
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.
Brian Wayne
In the URL, you could use percent-characters, ie. instead of a space use %20 etc.
hans
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
Lars
I assume you have a dedicated pin for the Ethernet board?
hans
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.
Dan
Good point Dan! Thanks!
hans
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??
Lars
I yet have to try that – by lack of a Mega board. But it would not surprise me …
hans
It works now – the MEGA has its SPI bus on th epins
SO
Lars
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.
Lars
Awesome Lars! Thank you for sharing this info – I’m sure others (including myself) will benefit from it!
hans
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:
to:
as outlined in the Readme.md included in the library, but in this shield we replace 53 with 10:
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.
Robert C
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:
For the HTML output you could do something like:
(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:
hans
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:
Or is it like:
What is this “something” dot “something”, and how do I read the variables in the URL? So I can end up with something like:
Robert C
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?
hans
I want to control the Arduino with a form so I can use my computer to switch something ON/OFF?
Robert C
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”):
hans
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
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
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
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
and in my void loop() after i have the 10 character id from reader i call findTag()
In findTag then i make the compare with the above approved list.
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
Thanks Narcomenos for the info. Nice, really nice project!![](//www.tweaking4all.com/wp-content/themes/tweaking4all/css/images/emoticons/t4a_cool.png)
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
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!
freddy
Hi Freddy,
It could be that you need to use different pins, see this comment just above yours.
Hope this helps
hans
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:
53, being your CS Pin.Try that. :)
Robert C
Thanks Robert for jumping in! Love it when visitors help each other!
hans
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!
:-)
freddy
Awesome! Great to hear it works!
hans
[…] TCP Communications between a PC and an Arduino Nano Using Lazarus / Free Pascal […]
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.
Brice
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 …
hans
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.
Dan Likins
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]
Dan Likins
Thanks Dan!
hans
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> ?
nikt
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?
hans
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).
nikt
By the best of my knowledge, I’m not including any other libraries … let me know how things go with the stock Arduino IDE!
hans
For those interested, I’ve found a plugin for NetBeans to do Arduino development. Is this the one you use Nikt?
hans
No. I use this: http://mattzz.no-ip.org/wiki/Projects/ArduinoAndNetbeans
nikt
Thanks for the link Nikt!
hans
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
Kevin
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.
hans
Thanks for the quick response.
I already found the problem.
The CS cable needed to be in arduino port 10.
Kevin
Awesome!
Glad to hear you’ve got it to work.
hans
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!
Daniel
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)
hans
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!!
Daniel
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):
Where “53” is the CS pin you’d like to use.
For Ethercard see Robert’s comments.
hans
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!!!
Daniel
You’re welcome … Glad to hear you’ve got something working …
hans
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
Hi Daniel!
You could try “resetting” the ENC28J60 with:
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
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
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
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
Akarsh
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 …
hans
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?
AKARSH
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 …
hans
Sorry for late reply Hans.
I think my ethernet shield is not compatible with nano which i’m using…
Akarsh
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 …
hans
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.
hans
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.
NEODODO
Hi NeoDodo!
Thank you for taking the effort to leave a nice feedback! Thanks, it’s much appreciated!
hans
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.
minu
Hi Minu,
sorry for the late reply …
What is your serial output showing? Did it output a valid IP address, gateway, and such?
hans
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?
Akarsh
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 …
hans
ok..hans.thanks
Akarsh
I can change by code, the SS pin? I have a connecting plate otherwise the A0 pin.
MaxiD
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.
hans
Sorry i’m use UIPEthernet
MaxiD
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).
hans
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.
TheFex
Yes, yes im test UIPEthernetand freez or erratical function
MaxiD
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.
TheFex
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
MaxiD
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:
It appears that the SPI pinout isn’t defined as a part of the SPI.h, which is why I declared it.
TheFex
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());
}
}
ben
1. Enc28j60 are 3v3 only. But pins cs,miso,mosi, sck, reset are 5v tolerant
maxid
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
Danie
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 …
hans
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
Danie
Very cool!![](//www.tweaking4all.com/wp-content/themes/tweaking4all/css/images/emoticons/t4a_cool.png)
hans
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.
Martin
Hi Martin,
I had the same problem as you. Use the Arduino IDE 1.0.5
Regards!
José
The error was from the library… From the header file, it was missing some part. I downloaded from GethUb again and it worked..
Martin
Awesome! Glad to hear you got it to work …
hans
Would you be kind and give me a link to the file that you downloded it ?
Haitham
This is the GitHub link.
hans
Thanks José for the suggestion
hans
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).
hans
I tried with the Arduio IDE older version, but that didn’t work for me.
Martin
Thansk bro, you are the man!!!
Regards,
Guillermo
Guillermo
Thanks Guillermo for taking the time to leave a nice comment! Its’ much appreciated
hans
Great post! Thank you for taking the time to do all this research and write about it.
Giannis
Thanks Giannis, it’s very much appriated
hans
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!!
Heini
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!
hans
[…] //www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/ […]
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.
Torres
Hi Torres!
Thank you very much for posting a nice “Thank you” note – it’s very much appreciated!
hans
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.
senderj
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
to
hans
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 …
Ricardo R
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.
hans
[…] Connecter le module Ethernet ENC28J60 à l’Arduino […]
[…] Arduino用ライブラリ(github)より利用可能 Web-Enable your Arduino with an Arduino ENC28J60 Ethernet shield …(Tweaking4All) […]
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
Haitham
To make sure you have the latest version, check out it’s GitHub page.
hans
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
Haitham
You can choose your own numbers.
Doctor
Thanks Doctor for chiming in.
Indeed you can pick your own numbers, as long as it’s unique in your network.
hans
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!
Doctor
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?
hans
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.
Doctor
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 …
hans
In addition:
Actually I used soft SPI for RF24 library as mentioned here, but it needs 3 additional pins.
Doctor
[…] Y aun más… //www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/ […]
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:
#define EthernetClient UIPClient
Can you point me in the right direction of how to compile this?
Thank you!
Dennis
Correction: the stack trace I get is from Webduino + UIPEthernet…
Dennis
Hi Dennis,
Or did you define “#define EthernetClient UIPClient” in your own code?
hans
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…
Dennis
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
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.
hans
At last, an ENC28J60 post that is thorough. Some insist that 5v will damage the module.
Gareth
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.
hans
[…] This is a good tutorial as well: //www.tweaking4all.com/hardware/arduino/ardui… […]
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
cassyarduino
Thanks Cassyarduino for posting the update here!
hans
Hi All!
I added support to MBED/SMeshStudio IDE.
Compiled to STM32F103RB (Nucleo).
You can download from:https://github.com/UIPEthernet/UIPEthernet
Best Regards
cassyarduino
Thanks Cassyarduino for all your work, and for keeping us up to date – excellent!
hans
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
cassyarduino
Awesome! Thanks for the update Cassyarduino
hans
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
cassyarduino
Thanks Cassyarduino for keeping us updated!
hans
Dude, thank you very much. Nice job ! It’ll save me lot of headache. Cheers !
AuLeeFor
Thanks AuLeeFor!![](https://www.tweaking4all.com/wp-content/themes/tweaking4all/css/images/emoticons/t4a_cool.png)
And thank you for taking the time to post a thank-you!
hans
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.
john
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?
hans
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)
John
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
john
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.
hans
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.
Your suggestion and library SOLVED my problem.
Thank you very much! God bless you Hans!
john
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
Thanks his article very help me in trying ENC28J60 with arduino uno, hopefully future can help develop library ENC28J60
Harry
hi everyone
i have connect an arduino nano to ENC2860 but i cant ping my coded ip
can help me ?
jim
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).
hans
p.s. Couldn’t find anything on ping, but it might requires more digging (https://github.com/ntruchsess/arduino_uip).
hans
[…] http://www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/ […]
Hello..!! How can i use Ethernet Shield ENC28J60 with Grove Serial Camera?.
Cris Matthew
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.
hans
Thanks for this!
Sadie
Thank you Sadie for taking the time to post a Thank-You note! It’s much appreciated!
hans
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
}
ramin
Hi Ramin,
this seems like a pretty extensive way of working with the ENJ.
I used UIPEthernet and did it this way:
hans
Thanks, I will try it.
I did this way:
if (FailedConnectionTimeout >= 30)
{
resetFunc(); //call reset
}
void(*resetFunc) (void) = 0; //declare reset function @ address 0
ramin
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!!!!!
Alejandro Nicolas Sanchez Taccone
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!
hans
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
Jonas Sorgenfrei
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?
hans
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
Holger Dorman
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.
hans
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
Holger
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).
– too many fun projects to do.
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
hans
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
Holger Dorman
Thanks Holger!
hans
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);
}
}
Tom
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
hans
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:
Stephan
Awesome that this finally works
hans
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….
bikram
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 …
hans
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
bikram
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.
hans
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
Bob
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)?
Hans
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)](https://www.tweaking4all.com/wp-content/uploads/2014/03/nano-ethernet-shield-deek-robot-400x138.jpg)
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!
Bob
Ah OK, now I’m getting it![](https://www.tweaking4all.com/wp-content/themes/tweaking4all/css/images/emoticons/t4a_cool.png)
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.
Hans
p.s. apologies for pointing you to another resource – I haven’t done something like this and the link seems to provide useful info.
Hans
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.
Bob
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).
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:
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:
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:
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:
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
Hans
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
Bob
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).
Hans
Reference in the changed code of UIPEthernet.
Hans
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
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:
At least, that’s what I would try.
Hans
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
Bob
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).
Hans
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
bOB
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).
Hans
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
Husam
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?
Hans
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.
Husam
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.
Hans