So the chip and wires are almost working (green light on, orange does not),
But I must be missing something if Ethernet.begin(...)
doesn't work..
Starting w/ libs, installed NCD_Ethernet_Overlay via Workbench,
And activated with #include <Ethernet.h> (and in turn "w5500.h", <EthernetClient.h>, etc.)
Here's the serial output; curiously, it doesn't return the manually set IP addr after Ethernet.begin()
, and on 2nd pass it returns nothing -
0000009299 [app] INFO: Trying Eth.begin
0000010300 [app] INFO: Spec IP addr is: 192.168.0.150
0000010300 [app] INFO: Eth IP addr is: 255.255.255.255
0000010301 [app] INFO: Could not cnx to serv
0000012305 [app] INFO: Trying Eth.begin
0000013306 [app] INFO: Spec IP addr is: 192.168.0.150
0000013306 [app] INFO: Eth IP addr is: 5.0.0.0
And code -
#include <Ethernet.h>
unsigned long lastLogT = 0;
unsigned long tcpRead = 3000; // 3s
bool cnxT = false;
SerialLogHandler logHandler(115200, LOG_LEVEL_INFO);
EthernetClient eClient; // Global instance
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed };
IPAddress locIP(192,168,0,150);
IPAddress servIP(192,168,0,39);
int servPort = 1701;
void setup() {
System.disableFeature(FEATURE_ETHERNET_DETECTION);
lastLogT = millis();
if (!cnxT) {
Log.info("Trying Eth.begin");
Ethernet.begin(mac, locIP, locIP, locIP); // Repeat IP for Gateway, DNS
Log.info("Defined IP is: %s", locIP.toString().c_str());
Log.info("Actual IP is: %s", Ethernet.localIP().toString().c_str());
}
}
void loop() {
if (millis() - lastLogT >= tcpRead) {
lastLogT = millis();
if (!eClient.connected()) {
if (eClient.connect(servIP, servPort, 1)){
Log.info("Connected to serv");
} else {
Log.info("Could not cnx to serv");
}
} else {
eClient.println("user1");
if (eClient.available() > 0) {
while (eClient.available() > 0){
Log.info((const char*)eClient.read());
}
}
}
}
}
I should add telnet to same server IP works great, from a 'similar' (192.168.0.100) PC with same settings (same 192.168.0.100 IP addr for its Gateway, DNS as well).
EDIT -
Actually reports localIP = 5.0.0.0 as corrected above