Here are my components. Added the pin call out for quick reference,
Mega 2560
Adafruit FONA 800 shield - FONA_RX 51, FONA_TX 50, FONA_RST 11
Adafruit 2.8" TFT shield - TFT_DC 9, TFT_CS 10, SD_CS 4, STMPE_CS 8
All components have stacking headers.
When I stack the 2.8" TFT with the Mega 2560, everything works great. I can access the SD and TFT works.
When I stack the FONA with the Mega 2560, everything works great. I can send and receive SMS.
The issues is when I use both the TFT and FONA together, I can not access the SD. The original program is over 1,000 lines, so I coded a test sketch to get the TFT / FONA / Mega 2560 all working together with minimal functionality. But, I cannot get it working. Couldn't find FONA, and SD initialization failed.
All I want to do is get the 3 components talking to each other.
Could I get some input on the below sketch so the SD initializes and the FONA will send/rec AT command?
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_STMPE610.h>
#include <SoftwareSerial.h>
#include <SD.h>
#include "Adafruit_FONA.h"
// For the Adafruit FONA shield
#define FONA_RX 51
#define FONA_TX 50
#define FONA_RST 11
// For the Adafruit TFT shield
#define TFT_DC 9
#define TFT_CS 10
#define SD_CS 4
// this is a large buffer for FONA replies
char replybuffer[255];
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// The STMPE610 uses hardware SPI on the shield, and #8
#define STMPE_CS 8
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
// FONA
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
uint8_t type;
void setup() {
while (!Serial);
Serial.begin(4800);
Serial.println("Entering setup");
tft.begin();
//tft.fillScreen(ILI9341_BLACK);
//tft.setCursor(85,150);
//tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
//tft.setTextSize(2);
//tft.print("TESTING"); //main Home screen name
// SD Initalation
pinMode(4, OUTPUT);
if (!SD.begin(SD_CS)) {
Serial.println("initialization failed!");
}
if (!ts.begin()) {
Serial.println("Couldn't start touchscreen controller");
while (1);
}
fonaSerial->begin(4800);
if (! fona.begin(*fonaSerial)) {
Serial.println(F("Couldn't find FONA"));
while (1);
}
}
void loop() {
}