UNO + Ethernet shield + interrupts

Hi there,

I am new here so please be gently... :slight_smile:

I have a problem to make working together UNO, W5100 and manual button which call the interrupt (attachInterrupt()) that controls the relay.

UNO and W5100 check a device on the network and if cannot connect to it the relay is started. That works fine. But there is also a manual way to start the relay - by pressing the button. And here I am lost. Because it works but not always.
Let say I start my UNO; the IP adress is assigned by DHCP, network device is checked. After a while I press the button - relay is started as expected but the W5100 loses the IP address - it is set to 0.0.0.0 - of course there is no network connection, and only thing that can be done is to power off the whole device or upload the code to UNO (which is actually the same thing - UNO and W5100 are restarted). Functions Ethernet.begin() and Ethernet.maintain() do not work.
The strangest thing is that sometimes everything works fine and the button can be pressed several times without causing any troubles. The other time even the first time sets IP to zeroes.
Without pressing the button everything is working fine - I ran it for over 30 hours.
It isn't a power problem - UNO and W5100 are powered from one power supply and the relay from another - and both are powerful enough. Anyway, the problem occurs even if the relay is removed.
I do not thing it is the code - if it was the problem wouldn't occur so randomly.
It probably isn't an overloaded UNO pin as there is a transistor between the UNO and the relay.

Any advice what else should I check? I am now very experienced Arduino user...

Thanks in advance.

Michael

If you are connecting the relay to the Arduino, that is very bad.

ieee488:
If you are connecting the relay to the Arduino, that is very bad.

Thanks for the replay. Can you please explain why it is bad and how that is related to my problem which happens even when the relay is removed. Thank you in advance.

Regards.

Michael

I do not thing it is the code

You'd be wrong, then. EVERYTHING on the Arduino is all about the code.

PaulS:
EVERYTHING on the Arduino is all about the code.

That was my initial thoughts too. But then I realised it "behaves" differently every time it is powered up, and now I am not so sure. But as I said - I am not very experienced.

Thanks for the replay.

Regards.

Michael