Ethernet blocking a relay in setup() [solved]

Hi all,

I'm currently trying to make a project that will switch a fridge on and off when it reaches the right temperature, and send the data over the network. I have a number of components working, but the ethernet seems to be blocking the power. I have a relay controlling the power for the fridge. This works in a script on it's own. I'm running the relay by using a signal pin for power, which I write HIGH in setup(), then I write another signal pin HIGH in the loop() when I want the fridge on. This works well, except if setup() contains Ethernet.begin(). That one line of code seems to be what's blocking the relay. Everything else works. The temperature sensors are read and the data is sent over the network. The red LED on the relay comes on, so it looks like it has power, but not control.
I have tried commenting out everything else except for the relay and ethernet code, and I've tried adding a massive delay, up to one minute, after the ethernet begin call, but this has made no difference.
I have attached the code below. It could be an issue with my setup, as far as I can tell, but I don't think there's anything wrong with the loop that executes. Do I need to find a different ethernet library which prevents blocking? From what I could see on Github, the current library has been designed to prevent blocking now, so I'm surprised that this is happening.
Any pointers on how I can fix this would be greatly appreciated.

sendtemps.ino (4.95 KB)

this two pins
const int MAINSPIN = 52; // pin to switch relay controlling fridge
const int RELAYPOWERPIN = 53; // signal pin to be switched on providing power for fridge relay

are SPI pins used by the Ethernet shield over the ICSP header

Thanks for letting me know about that. I hadn't thought of that possibility.
I tried using pins 2 and 3, and it seems to work perfectly now. How can I tell which pins are being used by what? Do I just have to check datasheets on all the components I'm using?
Also, is there a way to mark posts as solved on this forum?

Also, is there a way to mark posts as solved on this forum?

You can do this by editing your original post. Spelled out in paragraph 14 of the "How to use this forum" thread.