Tuesday, 7 October 2014

Ethernet(ENC28J60) Interfaced Arduino

In this Artical we will see how to establish communication between computer/mobile to Arduino in a LAN or Wireless Network. We are interfacing the ENC28J60 Ethernet controller to Arduino so that our Arduino will be the one of member of that network. Once it will done the arduino can control things in that network or the arduino can be controlled by the other devices of that network it might be computer or mobile. Interfacing Arduino with the ENC28J60 will further gives us the freedom of using the internet on Arduino but before that we need to learn how to do all that networking stuff in a locan network.

Soon I will post about how to control the things in local network, how to send data on a local network, and how to interfaced with Android devices or how to make IOT Devices. IOT Devices are quite famous.
 

A simple block diagram of the data flow  is in the image below.


Ethernet Module( ENC28J60):  Microchip's ENC28J60 is a 28-pin,  Ethernet Controller with on board MAC & PHY, 8 Kbytes of Buffer RAM and an SPI serial interface. With a small foot print package size the ENC28J60 minimizes complexity, board space and cost. It used in so many application like Industrial Automation, Building Automation, Home Control, Security and Instrumentation, IOT Devices.
You can build Your own circuit but I use the Module to save my time.



VIRTUAL SIMULATION: I first simulate my design on the Proteus ISIS to make sure I am working in right direction and also to save my time. In ISIS their is already a component named "ENC28J60 ethernet controller" so I picked it from the library. Now I picked up the Arduino and connect it with the ethernet controller.


if the link dont work please comment

* Connections:   
  
Now make these connection in the ISIS design tool.


SOFTWARE: Now we all done with the Virtual Hardware Design lets make the software. All you need is the Ethercard Library for this example. Download it from here EtherCard. Click here
  • Extract the ZIP file , copy and paste the folder in your Arduino1.xx/library/  
  • once you place the folder in your arduino library folder restart your Arduino IDE
  • Now  go to ethercard > Examples > backsoon
 
 Compile the code  : if facing any problem then go to :  How To Simulate Arduino in ISIS

Make some changes in the program as given below
changes are in Red colour
Arduino code
/*#############################################################################
###############################################################################*/

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

#define STATIC 0  // set to 1 to disable DHCP (adjust myip/gwip values below)

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

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

// char page[] is the HTML page you are uploading ..
char page[] PROGMEM =
"HTTP/1.0 503 My Seriavice \r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "2embeddedrobotics "
  "</title></head>"
  "<body>"
    "<h3>Welcome to 2embeddedrobotics</h3>"
    "<p><em>"
      "The World of IOT Devices .<br />"
      "yipeee   Congrats...."
    "</em></p>"

   "</body>"
"</html>"
;

void setup(){
  Serial.begin(9600);
  Serial.println("\n[backSoon]");
 
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  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);
  }
}
/*##############################################################################
###############################################################################*/

now compile the code with prefrence compile. in file option.. so that you will get the .HEX file for ISIS.







Now you have done every thing . Hit the Play Button and it will give you the assigned IP address in serial monitor now write it down on a paper.

 
open the web browser and write the IP address of your arduino in the browser.
 

 Now you can watch this page on any device connected to that network  As I show.

HARDWARE: We already did everything in virtual now we just need to connet each component as per the connection given in starting.
Now upload the program to your Arduino and turn on its Serial monitor so that u can get Your 
"IP in Serial Monitor" and just open browser and put your IP and check the webpage.



Now you have done then note your IP from the serial monitor and Enjoy..
Wish you a very good Luck.
 
 

About the Author

Vikas Sharma

Author & Editor

Hobbyst Researcher and working in electronics domain, M.Tech in VLSI Design and Embedded Systems.

49 comments:

  1. when i try to run this project it says "writting to non-assigned register [0x41]=0x00 U1" to simulation log and "Failed to access Ethernet controller" to virtual terminal. Do you know why this error occurred?

    ReplyDelete
    Replies
    1. 3 question: 1> DID you connected a lan to your PC
      2> if so then edit properties of enc28j60 and check network card no
      3> if network card no is not in the edit properties of enc28j60 thenu need higher version of proteus i am using 7.8

      Delete
    2. I connected to wifi network. When i connected to a LAN you project work, Thank.

      Delete
    3. i have the same problem bro someone help me writting to non-assigned register [0x41]=0x00 U1

      Delete
  2. Hi Sir !
    I try to run your project on Proteus 7.10 and I edited MAC, IP and Gateway, choose card number in enc28j60.
    Connected to LAN cable.
    but when i run, Terminal only show : [backSoon].
    Please guide me sir !!Thanks you so much !!!
    [backSoon]

    ReplyDelete
    Replies
    1. when i run, Terminal only show : [backSoon].

      Delete
  3. Im running your project on Proteus 8 and I edited MAC, IP and Gateway, and I tried with all card numbers in ENC28J60.
    Connected to LAN cable.
    but when I run, Terminal only show : [backSoon].

    Could you please tell what´s wrong??

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. I tried this project but while running the serial monitor i found out letters and not any ip address at 9600 baud rate when i changed the baud rate to 57600 i got an indication of backsoon. I have a doubt on how to check whether ethernet is connected to the router or there is any indication on PC's device manager or in networking or there is some more configuration required. I found your project very interesting and thanks you in advance .Please kindly give me your reply.

    ReplyDelete
  6. I'm new and I hope somebody can help me. I got this erros in Isiss when I try to simulate de programe:

    Failed to initialize: WinPcap Drivers
    [SPICE]Error202: Too many iterations withoutconvergence

    ReplyDelete
  7. In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,
    from C:\Users\Alexandre Borges\Documents\Arduino\libraries\ethercard-master/EtherCard.h:28,
    from arduino_temp.ino:7:
    arduino_temp.ino:24:13: error: variable 'page' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
    Erro compilando.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  8. your blogs is awesome.
    V Music
    Now you can listen to your choice of songs wherever you go. Just subscriber to our V Music service and listen to more than 50 thousand songs. Enjoy latest filmy songs, private albums, regional songs and many more. So what are you waiting for, just follow any one step to subscribe:
    Dial 5606001 (toll free) from your Phone.
    Activate : Dial 5606001 (toll free) from your Phone. Deactivate Dial 155223 from your phone. Subscription Charges: Rs 30 for 30 Days to enjoy Music.

    ReplyDelete
  9. Hello sir, I got similar error on proteus 'virtual terminal' screen. It shows 'Failed to access Ethernet controller' by trying 'dev_hub_net.cpp.hex' file and also shows '[backSoon]' by trying 'backSoon.cpp.hex' file (or vice versa).
    You notice above that see enc28j60's card number, Network card number.
    What do you mean by this? I looked to enc28j60 in your arduino+ethernet circuit in proteus. On ISIS 'Edit Component' window, there is Network Card No: 1. Is it right? or what is its mean? There are card numbers: default,0,1,2,3,4,5.
    What does it do? which one must write there, why?
    I know question is a bit boring, so, we need your helpfulness, if you please. yours sincerely (from Turkey)... :-)

    ReplyDelete
  10. Hello!!! Excellent but I get this error i proteus: invalid opcode 0x9419 at PC=0x23D4 and failed to initialize WinPcap Drivers... as I do?

    ReplyDelete
  11. Hello visit your post, it is excellent, but some said that should change what is in red. I do not understand that part, you could tell, because that's the only thing missing for me to work, I do not check my ip address or anything in the simulation

    ReplyDelete
  12. I declared the page varibale const and tried
    I am getting "simulation not running in real time due to excessive cpu load"

    ReplyDelete
  13. How to connect a lan to PC to process this project in Proteus ? Thank you for your replying

    ReplyDelete
    Replies
    1. just connect your internet wire with your pc

      Delete
  14. Sir pls the code is not working and in the virtual screen it shows only backsoon and pls.. reply

    ReplyDelete
    Replies
    1. hi switch pin of cs from 10 to 8 or 8 to 10

      Delete
    2. Respected sir,
      Thanks for your immediate reply and presently the ip address is appearing on virtual terminal but the DNS is appearing as 0.0.0.0
      Thank you

      pls reply......

      Delete
  15. i could not find why DNS is 0.0.0.0 may be due to this the ip is not loading in browser any suggestion please

    ReplyDelete
  16. This is by far the most usefull post on this topic.

    Thanks for the tutorial

    ReplyDelete
  17. variable 'page' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
    how to solve this error?

    ReplyDelete
  18. hello sir,
    this link doesn't work with me
    * DOWNLOAD FULL PROJECT IN ZIP FILE CLICK HERE *

    ReplyDelete
  19. This was the time before the ESP8266 which now allows the arduino through wifi. And of course, NodeMCU which can be used as a standalone server using Arduino IDE.

    ReplyDelete
  20. i receive this error

    "Failed to initialize WinPcap Drivers"


    then what should i do?

    ReplyDelete
  21. https://suntos.com.np/avr/ENC28J60%20Ethernet%20Controller

    ReplyDelete
  22. thanks for sharing the information.Indian Cyber Army is announcing “ Summer Internship 2018” on “ Ethical hacking and Cyber Crime Investigation” for the enthusiasts of Cyber security. Here internship will give you on-the-job experience, help you learn whether you and Cyber security industry are a good match and can provide you with valuable connections and references. Here interns are usually exposed to a wide variety of tasks and responsibilities which allows the intern to showcase their strengths by working on projects for various managers that work on different parts of Indian Cyber Army. Becoming a high performing intern is a fantastic way to improve your employment prospects. This internship can be a great way to get your foot in the door of success with a prestigious or desirable Organization

    ReplyDelete
  23. Thanks for the information.It is really nice .Information security is the set of processes that maintain the confidentiality, integrity and availability of business data in its various forms.In this age of Technology advancement, computer and information technology have not only brought convenience to citizens in modern life but also for policemen & various Government officials of the nation to fight cybercrime through various modus operandi. Indian Cyber Army has been dedicated in fighting cyber crime, striving to maintain law and order in cyberspace so as to ensure that everyone remains digitally safe.Read more:- Information Security

    ReplyDelete
  24. thanks for sharing the more valuable information.
    Indian Cyber Army credibility in Ethical hacking training & Cybercrime investigation training is acknowledged across nation as we offer hands on practical knowledge and full assistance with basic as well as advanced level ethical hacking & cybercrime investigation courses. The training is conducted by subject specialist corporate professionals with wide experience in managing real-time ethical hacking/ cyber security projects. Indian Cyber Army implements a blend of academic learning and practical sessions to give the candidate optimum exposure.Ethical hacking training ,
    Ethical hacking course

    ReplyDelete
  25. I couldn't get response from real model of this sample
    I'm using Arduino uno & ENC28J60 with Microchip MCU
    and also I couldn't see my ethercard's IP in network monitor
    why? I can share pictures if you want.

    ReplyDelete
  26. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
    Data Science Training in Chennai
    Data science training in bangalore
    Data science online training
    Data science training in pune
    Data science training in kalyan nagar

    ReplyDelete
  27. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Devops training in Chennai
    Devops training in Bangalore
    Devops Online training
    Devops training in Pune

    ReplyDelete
  28. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!
    java training in chennai | java training in bangalore

    java training in tambaram | java training in velachery

    java training in omr | oracle training in chennai

    ReplyDelete
  29. This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot. 

    angularjs Training in chennai
    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    ReplyDelete
  30. myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

    ReplyDelete
  31. When I initially commented, I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thanks.
    Amazon Web Services Training in OMR , Chennai | Best AWS Training in OMR,Chennai
    AWS Training in Chennai |Best Amazon Web Services Training in Chennai
    AWS Training in Bangalore |Best AWS training in Bangalore
    Amazon Web Services Training in Tambaram, Chennai|Best AWS Training in Tambaram, Chennai

    ReplyDelete
  32. in my Virtual terminal, only show BackSoon, do you know how i can solved?

    obs: people with the problem about the "page" only change the parameter of variable for "const char page[] PROGMEN = ..."

    ReplyDelete
  33. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me.
    python training in chennai
    python training in Bangalore
    Python training institute in chennai

    ReplyDelete
  34. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Devops training in sholinganallur
    Devops training in velachery
    Devops training in annanagar
    Devops training in tambaram

    ReplyDelete
  35. I am really enjoying reading your well-written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.
    Hadoop course in Marathahalli Bangalore
    DevOps course in Marathahalli Bangalore
    Blockchain course in Marathahalli Bangalore
    Python course in Marathahalli Bangalore
    Power Bi course in Marathahalli Bangalore

    ReplyDelete
  36. Good job in presenting the correct content with the clear explanation. The content looks real with valid information. Good Work

    DevOps is currently a popular model currently organizations all over the world moving towards to it. Your post gave a clear idea about knowing the DevOps model and its importance.

    Good to learn about DevOps at this time.


    devops training in chennai | devops training in chennai with placement | devops training in chennai omr | devops training in velachery | devops training in chennai tambaram | devops institutes in chennai | devops certification in chennai

    ReplyDelete

 
2embeddedrobotics © 2015 - Designed by Templateism.com