Go Down

Topic: SIM900 + TFT SCREEN Conflict Help (Read 106 times) previous topic - next topic

BarefacedDeath

any help appreciated as I am going crazy, ignore code snippet below as just pulling together modules to work with uno then will build proper sketch (code below is sandbox to test hardware working together).

I am using the keyestudio SIM900 with elegoo TFT touchscreen but getting errors and I think it is down to power 9 (which is SIM900 default)

I want to stack on the uno with no soldering or breadboard.

The GSM all works it is only when I add the TFT.

code below___________________________________

#include <SoftwareSerial.h>
#include <Adafruit_TFTLCD.h>
#include <Adafruit_GFX.h>   
#include <TouchScreen.h>

SoftwareSerial gsmSerial(6, 7); // set GSM serial port

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#define YP A3
#define XM A2
#define YM 9
#define XP 8

#define BLACK   0x0000

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 364);

void setup()
{
  Serial.begin(9600); // begin serial comms between Arduino and Arduino IDE
 
  Serial.println("Initializing GSM module serial comms...");
  gsmSerial.begin(19200); // begin serial comms between Arduino and SIM900
 
  while (!isGSMAvailable()) {
    powerCycle();
  }
 
  updateSerial();

  Serial.println("GSM module handshake...");
  gsmSerial.println("AT"); // handshake with SIM900
  updateSerial();
 
  gsmSerial.println("AT+CSQ"); // signal quality test, value range is 0-31 , 31 is the best
  updateSerial();
 
  gsmSerial.println("AT+CCID"); // read SIM information to confirm whether the SIM is plugged
  updateSerial();
 
  gsmSerial.println("AT+CREG?"); // check registered in the network
  updateSerial();
 
  gsmSerial.println("AT+COPS?"); // check registered in the network
  delay(100);
  String carrierName = toCarrierName(gsmSerial.readString());
  Serial.println(carrierName.c_str()); // display carrier name
  updateSerial();

  //// SCREEN TIME ////
  tft.begin();
  tft.fillScreen(BLACK);
 
  Serial.println("Touchscreen started");
  //// THE END ////
 
  //gsmSerial.println("AT+CMGD=1,4"); // Delete all SMS
 
  //sendSMS(); // send sms message
  //receiveSMS(); // receive sms message
  //callCELL(); // call cell number
 
}

void powerCycle()
{
  Serial.println("Power cycling GSM module...");
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(5000);
}

String toCarrierName(String gsmCopsResponse) {
  int from = gsmCopsResponse.indexOf('"');
  int to = gsmCopsResponse.lastIndexOf('"');
  return gsmCopsResponse.substring(from + 1, to); //  parse carrier name from AT-COPS? string
}

bool isGSMAvailable()
{
  gsmSerial.println("AT");
  delay(500);
  bool available = gsmSerial.available();
  updateSerial();
  return available;
}

void sendSMS()
{
  gsmSerial.println("AT+CMGF=1"); // configuring SMS mode
  updateSerial();
  gsmSerial.println("AT+CMGS=\"+44751551XXXX\"");
  updateSerial();
  gsmSerial.print("MESSAGE SENT"); // SMS message content
  updateSerial();
  gsmSerial.write(26);
}

void receiveSMS()
{
  gsmSerial.println("AT+CMGF=1"); // configuring SMS mode
  updateSerial();
  gsmSerial.print("AT+CNMI=2,2,0,0,0\r"); // send SMS data to serial out upon receipt
  delay(100);
  updateSerial();
}

void callCELL()
{
  gsmSerial.print("ATD+44751551XXXX;\r");// dial +44751551XXXX
  delay(100000);
  //gsmSerial.println("ATH");
  delay(200000);
}

void loop()
{
  updateSerial();
}

void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    gsmSerial.write(Serial.read());
  }
  while(gsmSerial.available())
  {
    Serial.write(gsmSerial.read());
  }
}

BarefacedDeath

note not being rude just need help :)

can anyone suggest another forum I may be able to resolve the above as struggling to get answers?

thanks in advance

Go Up