random IP when digit read from eeprom [solved]

[edit] Reason is hw problem with the shield

Hello,

My boards are mega2560 with enet wisnet 5100 r3

To avoid IP conflicts in 'dev' board and 'field' board I read the ls IP digit from eeprom
so if the field board address should be a.b.c.124 and the dev one a.b.c.123; 124 and 123 are read for respective boards eeprom

I have at global scope

byte mac[] = {0x00, 0xaa, 0xbb, 0xcc, 0xde, 0x02};
IPAddress myIP (192, 168, 002, EEPROM.read(loIPlocation));
IPAddress netDNS (192, 168, 002, 001);
IPAddress gateway(192, 168, 002, 001);
IPAddress subnet (255, 255, 255, 000);
IPAddress smsServer(192, 168, 2, 224);

and during setup a call to enetStart();

defined by

void enetStart() {
  report(F("enet start-> starting Ethernet\r\n"), MI_VERB);
  Ethernet.begin(mac, myIP, netDNS, gateway, subnet);
  report(F("My ip is "), MI_VERB); Serial.println(Ethernet.localIP());

I run this code w/o the ethernet cable.
what I see since this is implemented is that the printed Ethernet.localIP() is many things, ranging from 0.0.0.0 to the correct IP. Furtheremore I have a hard time to have a wrong IP again once it's shown the correct one, even after cycling the power.

I have conscience that mac should differ too and will implement it likewise.

Can someone please suggest what is wrong?

Thanks for your help

Please post a complete program that demonstrates the problem

Which Arduino are you using ? An ESP8266 perchance ?
How is the data being saved to EEPROM in the first place ?

The code hase 3.3 k lines + libs

my dev board is mega r3 + wisnet r3 both chinese. field board is sparkfun mega +chinese enet

The eeprom is written with a ui for the first time then reset is sent. The eeprom value is confirmed AND it's not just the LS IP digit which gets corrupted

It is not impossible that it's a hw issue on the dev board because I did not notice de problem on the field board BUT I don't play as much with the field one

The code hase 3.3 k lines + libs

Write a simple program to read the value(s) from the EEPROM. Are they correct ?

Thank you UKHeliBob, Do you fly helicopters?

Yes the eeprom value is confirmed. the dev board eeprom returns 123 at location loIPlocation

Since no one of the gurus here had something to say about the code, I must reach the conclusion that there's a wrong mechanical contact between the mega board and the enet shield of my dev board. Indeed I've lost many hours because of poor hw issues

Or, there could be a problem with the code you didn't post.
I've lost many hours not seeing code.

Code attached. Thanks for any help
libs in next post(.7z refused)

_19.ino (110 KB)

libs in zip

libraries.zip (11.2 KB)

I meant the cut-down minimal test code that demonstrates the problem.

However, the F() macro also works with client.print.

AWOL:
However, the F() macro also works with client.print.

Thanks!

AWOL:
I meant the cut-down minimal test code that demonstrates the problem.

This is not reproducible upon request even with the full code, as is: It happened twice. 1st time the LS digit became 52 and the 3 MS (i think) was correct. the second time all 4 digits became 0. Now all is good, no IP corruption. Also, this never happened on the 'field' mega/enet combo

AWOL:
However, the F() macro also works with client.print.

indeed could make subsential ram economy with client.print. Thanks a lot!
It seems however that it is not as simple when the string is argument of other functions e.g in

clientCondPrint("DATA\r\n");

defined by

void clientCondPrint(const char* string) {
sp(string); if(getArg(DO_EMAIL)) client.print(string);
}

or in

strcat(genBuf, "--sensor open-- * <-> open ");

guy_c:
It seems however that it is not as simple when the string is argument of other functions e.g in

clientCondPrint("DATA\r\n");

defined by

void clientCondPrint(const char* string) {
sp(string); if(getArg(DO_EMAIL)) client.print(string);
}

or in

strcat(genBuf, "--sensor open-- * <-> open ");

strcat_P