Hello!
I'm trying to make this combo work, with little success.
My goal for now is just to make the shield work; I tried to test it with the WebServer example.
The shield I'm using is the DFRobot Ethernet Shield for Arduino - W5200 (DFR0272), with the EthernetMod libraries.
I modified the IP address and added:
// disable SD card if one in the slot
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
Even if there is no SD card in the slot.
What happens:
No response from the specified, unoccupied ip (192.168.1.169) via web browser.
Red power leds on, no other movement.
What I tried:
- Using different libraries: WizNet, SeedStudio
What I didn't try:
- Looking at the serial monitor. Unfortunately, the pc is too far from the router, so I cannot connect both at the same time.
Any input is appreciated.
Thank you!
GarrettLM:
- Looking at the serial monitor. Unfortunately, the pc is too far from the router, so I cannot connect both at the same time.
if you cannot connect the serial monitor at the same time check the code for
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
which will cause the program to hang waiting for a serial connection
if found comment out the code
the library I use with my Ethernet shield V1 is Ethernet - Arduino Reference
Is this is the board you are using?
https://www.dfrobot.com/wiki/index.php/DFRduino_Ethernet_Shield#Connection
If so, you must insure the PWRDN (Power Down) and RST (Reset) pins are set correctly. They should be on D8 and D9.
// RST HIGH
pinMode(8,OUTPUT);
digitalWrite(8,HIGH);
// PWRDN LOW
pinMode(9,OUTPUT);
digitalWrite(9,LOW);
horace:
if you cannot connect the serial monitor at the same time check the code
Thank you, I missed that!
SurferTim:
Is this is the board you are using?
DFRduino_Ethernet_Shield-DFRobot
Indeed, that's the one.
Thanks to your tips, the status LEDs (POWER, LINK and SPEED) are now on.
However, I can't seem to get it to work.
I managed to connect the serial monitor and it just says "server is at 0.0.0.0".
And of course, no response from browser.
Did I miss anything else?
Thank you
looks like you are not using DHCP and need to explicitly set up an IP address
post you code?
Insure you are using an ethernet library for the w5200.
Edit: This library has been known to work for the w5200. Follow the instructions to use with the w5200.
SurferTim:
Insure you are using an ethernet library for the w5200.
Indeed, I noticed I used another library last time.
I checked I'm properly using the EthernetMod (GitHub - per1234/EthernetMod: Modified Arduino Ethernet Library).
Now, it still does not work, but the serial monitor says "server is at 42.15.218.86"
horace:
post you code?
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
Ethernet shield attached to pins 10, 11, 12, 13
Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
modified 02 Sept 2015
by Arturo Guadalupi
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xBD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 169);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// disable DS card if one in the slot
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
// RST HIGH
pinMode(8,OUTPUT);
digitalWrite(8,HIGH);
// PWRDN LOW
pinMode(9,OUTPUT);
digitalWrite(9,LOW);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// 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) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("
");
}
client.println("</html>");
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(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
Ethernet.maintain();
}
}
I'll try using the WIZ libraries now, thank you.
if I run the code on my Ethernet Shield V1 and use a web client to access the displayed IP I get on the serial monitor
server is at 192.168.1.169
new client
GET / HTTP/1.1
Host: 192.168.1.169
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
client disconnected
do you have the correct library for your board?
the code you posted states
Ethernet shield attached to pins 10, 11, 12, 13
That library you posted a link to is apparently for a w5100, not the w5200.
Insure you follow the instructions on the page, especially this in utility/w5100,h.
Change this:
typedef uint8_t SOCKET;
//#define W5100_ETHERNET_SHIELD
//#define W5200_ETHERNET_SHIELD
#define W5500_ETHERNET_SHIELD
to this:
typedef uint8_t SOCKET;
//#define W5100_ETHERNET_SHIELD
#define W5200_ETHERNET_SHIELD
//#define W5500_ETHERNET_SHIELD
SurferTim:
That library you posted a link to is apparently for a w5100, not the w5200.
I think I got mislead, where I found it said it was compatible with both with automatic recognition.
horace:
do you have the correct library for your board?
Indeed I didn't.
I changed the libary to the WIZ one and it works like a charm.
Thank you!