Simultanious communication with SPI and Softwareserial between cc3000 and GSM900

Hello dear Arduino enthusiasts

So far I've been able to solve all problems by researching but now I've run into an error that I've been unable to solve so far.

Hardware I'm Using

  • Arduino Mega 2560
  • CC3000 Wifi Shield
  • SIM900 Shield

Functionality

The Project I'm working on reads multiple sensor values and sends out an alarm text message if a defined threshold is passed.
It also should read incoming text messages and immediatley answer with the present values to the phone number the text message came from.
The data should also get written localy on the SD card of the CC3000 and get passed on to a PHP script that stores the data in a MySQL database.

The Problem
All of the functions are working but sadly not at the same time. If I don't exclude the initialitiation of the cc3000 from the setup() loop, the SIM900 isn't able to read incoming data from the software serial.
However if I comment out the cc3000_setup() function from the setup() loop, the text message recieving function works perfectly.
Funny enought outgoing text messages seem to work with the wifi shield initialized.

Somehow there must be some kind of conflict between the cc3000.begin() and the mySerial.read() function.

I've tried searching for similar setups but haven't found much related to combining cc3000 and SIM900.

I'd be really grateful if you could have a look into the code and think of a possible solution.

My thought was to initialize the wifi shield everytime i want to call the http request and reset the shield totally after the request has been finished. I haven't found a function in the adafruit CC3000 library that resets the shield. The only function I've found is the cc3000.disconnect() but it doen't seem to be enought.

Thanks for having a look into this

Best regards
Paul

Final.ino (12.7 KB)

Reply and use the Attach feature below the text box to attach your sketch.

Thanks! Tips on good programming practice are very welcome too!
It's more or less a copy-paste job with a lot of modifications.

Serial monitor output when cc3000_setup() is commented out and i send a text:

Configuration of SIM900...

OKOK

OKOK

OKOK

OKOK
Initialisierung Wifi Shield...

IP Addr: 192.168.43.130
Netmask: 255.255.255.0
Gateway: 192.168.43.1
DHCPsrv: 192.168.43.1
DNSserv: 192.168.43.1
MyPC -> 192.168.43.209
Serial available...

sensorPin1: 24.07
sensorPin2: 633
sensorPin3: 766
Alles im Lot

sensorPin1: 24.07
sensorPin2: 633
sensorPin3: 766
Alles im Lot

Serial monitor output when cc3000_setup() is not commented out and i send a text:

Configuration of SIM900...

OKOK

OKOK

OKOK

OKOK
Serial available...

sensorPin1: 24.07
sensorPin2: 633
sensorPin3: 764
Alles im Lot

sensorPin1: 24.07
sensorPin2: 633
sensorPin3: 766
Alles im Lot

Serial available...

+CMT: "+4********,"","15/11/13,14:56:21+04"
 
Mobile Number is: +4********
Message Text: 
sensorPin1: 24.07
sensorPin2: 633
sensorPin3: 766
Alles im Lot

Serial available...

OK

> 
> 
+CMGS: 44

OK
sensorPin1: 24.07
sensorPin2: 633
sensorPin3: 766
Alles im Lot

sensorPin1: 24.07
sensorPin2: 633
sensorPin3: 766
Alles im Lot

Found the problem.

Accidentally had RX pin of SoftwareSerial mySerial(10, 8) on the same pin as #define ADAFRUIT_CC3000_CS 10

Working perfectly now :))