Accelerometer (I2C) and Fona Shield (software serial) won't work together

I am using a Fona 808 shield with an Arduino Uno and the LSM303 accelerometer. The accelerometer is connected via I2C and the Fona uses software serial.

My project requires the accelerometer to be continuously polled and occasionally talk with the fona. I wrote a program that just used the fona, but once I added the accelerometer code the program would hang a few seconds after comms had been opened with the Fona. I have tested both the accelerometer and the fona shield separately, and they work fine. So, I wrote another smaller (test) program (which is attached below) to find the origin of the program, which I identified to be:



After these lines of code are added, the problem arises. As I said before, this is what I see a few seconds after comms have been opened with the Fona.

My test program reads the value from the accelerometer, calculates the magnitude of the acceleration and if it's over 20, it prints "Over 20", while also initialising Fona serial.

My question is: Why don't the accelerometer (I2C) and the Fona (Serial) work together and how this be fixed?

AccelerometerandFonaTest.ino (1.13 KB)

I don't expect any interference of I2C and software serial. The problem must reside somewhere in your code. AFAIR SoftwareSerial is not buffered and not interrupt driven. Have you tried AltSoftSerial instead?