So i have this W5500 shield, and after a bit of fiddling i got it to respond and show me the IP address on the Serial port.
I first uploaded an example
#include <SPI.h>
#include <Ethernet.h>
#define RX_PIN 13
#define SD_CS 15
#define W5500_CS 2
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,2);
void setup() {
Serial.begin(115200);
// disable SD card if one in the slot
pinMode(SD_CS,OUTPUT);
digitalWrite(SD_CS,HIGH);
Serial.println("Starting ethernet");
Ethernet.init(W5500_CS); // set the CS pin
Ethernet.begin(mac,ip);
pinMode(RX_PIN, INPUT);
delay(1000);
pinMode(RX_PIN, FUNCTION_2);
Serial.println(Ethernet.localIP());
}
void loop() {
}
There is also an SD card in the schematic which uses GPIO15 as CS, and the W5500 uses GPIO2 for that.
I did a small check on the pinMode, basically i am using GPIO 13 both for SPI and as an RX pin for UART0, and i wanted to make sure that i can keep doing this (i did the same thing with the SD card and that went fine) and i think it's fine. As an SPI master you transfer information at the moment that you want.
So anyway this works as expected, so i thought i should try a basic webserver
#define RX_PIN 13
#define SD_CS 15
#define W5500_CS 2
#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, 0xAD, 0xBE, 0xEF, 0xFE, 0xEB
};
IPAddress ip(192, 168, 0, 177);
// 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(115200);
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
Serial.println();
Serial.println("Starting ethernet");
Ethernet.init(W5500_CS); // set the CS pin
Ethernet.begin(mac, ip);
pinMode(RX_PIN, INPUT);
delay(1000);
pinMode(RX_PIN, FUNCTION_2);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
static uint32_t ipshow = millis();
if (millis() - ipshow > 1000) {
ipshow = millis();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
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(0);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("<br />");
}
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");
}
}
and again the Serial monitor returns the information i expect to get, but when i connect a UTP cable to the RJ45 to my laptop i should just be able to type the IP address in my browser and get served the page (i must be missing something here of course) but this doesn't happen.
There is no firewall settings anywhere i have to change is there ? i mean my browser has permission.
I added the sending of the IP to check if the w5500 is still properly connected to the ESP8266 (it's a 12-f btw)
I can of course not be sure there is not a power issue, but i am thinking to exclude that possibility.
atm it is powered from the 5v pin of an UNO (that i am using as the USB-TTL) and both the ESP and the W5500 are getting 3.3v by converting that with a LD1117 3.3v in a TO-220 package, this hardly gets warm, and with the 5v providing near 500mA (i actually realize this is all on a dongle , but it should still be more than 400mA) i am fairly confident this is not the cause, the w5500 uses a lot less power than the wifi part of the ESP8266, and that is not connected to anything. (it is still on, there are valid credentials still in the wifi part of the flash, so the AP does show up)
But again maybe i'm wrong.
All of the schematics i can provide, but really it is quite a lot of work (which will need doing at some point i guess) and it connects to the ESP's SPI just fine, and the rest doesn't really need drawing.
So what am i missing ?