Two devices using SPI problem WifiShield 101

Hello guys, I'm a newbie with Arduino and electronics.

I'm working on a energy meter using Arduino Mega 2560. I'm using an energy metering IC from Analog Devices (ADE7759) which communicates via SPI using ports 50 51 52 53 (53 is for SS). Also im using WifiShield 101 which also communicates using SPI but with the SS on pin 10.

I'm having issues using this two devices sharing one SPI bus. I do turn off the SS pin on the device I want to communicate with and when its done I set it HIGH.

Sometimes it works and sometimes the energy metering IC has problems with the SPI communication.

Plus I'm trying to send values to a database every 5 seconds using TimerOne interrupt and it freezes.

Plus I'm trying to send values to a database every 5 seconds using TimerOne interrupt and it freezes.

That is doomed to failure. When the interrupt service routine is running, interrupts are disabled. Using timer interrupts is not the way to make sending data to a server happen on a regular schedule.