Hi
im have made a ENC28J60 module following these instructions.
I have made this exact circuit on to a breadboard. However the issue I am having is that it suddenly closes the socket I opened. I mean it works i can send a value to it and turn on an led, however randomly like 4 hours half a day the socket closes and I can’t send a value.
#include <EtherCard.h>
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte myip[4] = {192,168,1,177};
byte Ethernet::buffer[700];
Stash stash;
//String readString;
int x;
char* incomingData;
int led = 9;
String con = "1";
void setup () {
Serial.begin(9600);
pinMode(led, OUTPUT);
//Serial.println("[CPU Monitor]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F("[ERROR] Failed to access Ethernet Controller."));
if (!ether.dhcpSetup())
Serial.println(F("[ERROR] DHCP Connection Failure."));
ether.staticSetup(myip);
ether.hisport = 23;
//ether.printIp("[INFO] My IP: ", ether.myip);
//ether.printIp("[INFO] Gateway: ", ether.gwip);
//ether.printIp("[INFO] DNS Server: ", ether.dnsip);
ether.persistTcpConnection(true);
}
void loop () {
uint16_t payloadPos = ether.packetLoop(ether.packetReceive());
if (payloadPos > 0)
{
incomingData = (char *) Ethernet::buffer + payloadPos;
x = atoi(incomingData);
//Serial.println(x);
}
if(x == 1){
digitalWrite(led, HIGH);
Serial.println(con);
}else{
digitalWrite(led, LOW);
}
}
Above is my code which i am using. Once again it does work but then suddenly it doesn’t
I’m not sure if it is a hardware issue or a software issue, so was wondering if someone could help me. Also if it is possible to check if there is a connection using an if statement, or a way in which it always tries to connect if the socket closes.
Thank you