I just wired my module ENC28J60 to my Arduino Mega R3 according to the table given in the following website, the library is also available in the following link
But when I upload the first example in the library named backSoon , the Serial Monitor prints "backSoon" and then gets stuck. There is no output after that whatsoever.
When I enter the ip of the Arduino in the browser,
An error is displayed saying the site cannot be reached.
The Ethernet is connected to the router and my PC is connected to the router via WiFi.
Pinging the Arduino IP gives the following output
ping 192.168.1.180
Pinging 192.168.1.180 with 32 bytes of data:
Reply from 192.168.1.180: bytes=32 time=5ms TTL=64
Reply from 192.168.1.180: bytes=32 time=2ms TTL=64
Reply from 192.168.1.180: bytes=32 time=2ms TTL=64
Reply from 192.168.1.180: bytes=32 time=2ms TTL=64
Ping statistics for 192.168.1.180:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 5ms, Average = 2ms
I followed this method after watching the tutorial I found on YouTube
I browsed the internet for multiple tutorials but to no avail.
The red led for power is glowing on the lan module.
The yellow on the lan module is on and orange led is blinking.
I would appreciate any advise on your behalf
Thank You in advance
But when I upload the first example in the library named backSoon , the Serial Monitor prints "backSoon" and then gets stuck. There is no output after that whatsoever.
If backSoon is the last output in the serial monitor, how do you know what IP to connect to?
Post more information about the network your connecting your Arduino to. Do you connect to a switch? If yes, what type/model? If you connect directly to your PC, is the cable crossed?
I dont know what I did, but the HTML module is working all of a sudden. All I remember is I changed Static 1 to disable DHCP and changed the baud rate from 9600 to 57600.
@pylon
There is a parameter to set the IP in the sketch, so i pinged the same IP address.
There is a parameter to set the IP in the sketch, so i pinged the same IP address.
Yes, but that parameter is disabled by default. That why we are asking to post the code you're using even if you think it's the standard example.
If the static IP is disabled you must have the serial output telling you what IP your Arduino got by DHCP, otherwise you cannot connect to it.
pylon:
Yes, but that parameter is disabled by default. That why we are asking to post the code you're using even if you think it's the standard example.
If the static IP is disabled you must have the serial output telling you what IP your Arduino got by DHCP, otherwise you cannot connect to it.
Oh okay. Thank You for your reply. I understand why it was not working earlier.
Following is the code that worked for me
// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl>
//
// License: GPLv2
#include <EtherCard.h>
#define STATIC 1 // set to 1 to disable DHCP (adjust myip/gwip values below)
#if STATIC
// ethernet interface ip address
static byte myip[] = { 192, 168, 1, 180 };
// 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
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>"
"Service Temporarily Unavailable"
"</title></head>"
"<body>"
"Hello World"
"<h3>This service is currently unavailable</h3>"
"<p><em>"
"The main server is currently off-line.
"
"Please try again later."
"</em></p>"
"</body>"
"</html>"
;
void setup() {
Serial.begin(57600);
Serial.println("\n[backSoon]");
// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, 53) == 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);
}
}