Currently I am building a device incorporating a TFT screen, a GSM module, and an Arduino Mega. However, the GSM Module and the TFT share some pins.
To solve this problem, I have the GSM Module hooked into an Arduino Uno, and the TFT hooked into the Mega. Via Software Serial, the two Arduino's communicate, and interact with their corresponding hardware accordingly.
However, relaying data over Software Serial in this manner is proving to be quite challenging for me. So, I am wondering if there is a way to have the GSM Module AND the TFT Module BOTH plugged into the Arduino Mega. Again, the problem is that both utilize the same Digital Pins.
Any help would be great! This problem is really stumping me, and I need your help! :o
-SQ
Which pins ?
It is not unusual for serial devices to share pins and usually the chip select pin is configurable.
If you post links for your devices, maybe you get some specific help here.
6v6gt:
Which pins ?
It is not unusual for serial devices to share pins and usually the chip select pin is configurable.
If you post links for your devices, maybe you get some specific help here.
//GPRS Shield is connected to the Software UART
#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
It also appears that the GPRS shield jumper pins can be directly connected to. Remove the 2 bridging pieces and connect the chosen pins on your Arduino directly to the GPRS jumper pins marked GPRS_TX and GPRS_TX.
6v6gt:
From here http://www.geeetech.com/wiki/index.php/Arduino_GPRS_Shield it looks like you can configure the GSM sketch to use different pins for software serial. It warns you about which pins are appropriate for the Mega: pins marked GPRS_TX and GPRS_TX.
Yes, you can change the Software Serial pins... But it also says
"D7 - Used if you select software serial port to communicate with GPRS Shield
D8 - Used if you select software serial port to communicate with GPRS Shield
D9 - Used for software control the power up or down of the SIM900"
The code assumes 1 hardware serial interface PC <--> Arduino and 1 software serial interface Arduino <--> GPRS board
//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART
#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0; // counter for buffer array
void setup()
{
GPRS.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the Serial port of Arduino baud rate.
}
void loop()
{
if (GPRS.available()) // if date is comming from softwareserial port ==> data is comming from gprs shield
{
while(GPRS.available()) // reading data into char array
{
buffer[count++]=GPRS.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0; // set counter of while loop to zero
}
if (Serial.available()) // if data is available on hardwareserial port ==> data is comming from PC or notebook
GPRS.write(Serial.read()); // write it to the GPRS shield
}
void clearBufferArray() // function to clear buffer array
{
for (int i=0; i<count;i++)
{ buffer[i]=NULL;} // clear all index of array with command NULL
}
I guess what you have to do to avoid using pins 7 and 8 on the Mega is:
modify the code to use the Mega's Serial1 port instead of the software serial port by changing references to 'GPRS.' to 'Serial1.' and commenting out the line 'SoftwareSerial GPRS( 7, 8 );'
connect the Mega's Serial1 pins (18 and 19 ) to the jumper pins on the GPRS board marked GPRS_TX and GPRS_TX visible in the link below (and discard the 2 jumper bridging pieces): Arduino GPRS Shield - Geeetech Wiki
stupid-questions:
Yes, you can change the Software Serial pins... But it also says
"D7 - Used if you select software serial port to communicate with GPRS Shield
D8 - Used if you select software serial port to communicate with GPRS Shield
D9 - Used for software control the power up or down of the SIM900"
THOSE are the pins that I am worrying about...
-SQ
I can't find the actual pinout documentation for the LCD, nor example code for it, so it's not clear which pins it uses. If it uses those pins, that's an issue. If it doesn't, then it's not an issue.
DrAzzy:
I can't find the actual pinout documentation for the LCD, nor example code for it, so it's not clear which pins it uses. If it uses those pins, that's an issue. If it doesn't, then it's not an issue.
Oh it does. I tested it when disconnecting those pins. It cause black outs in some areas of the screen.
You could try posting the code that you have working for the TFT on the Mega and the GPRS module on the Uno and see if anyone can help.
You may have to end up connecting at least one of the devices with hook up wires instead of stacking the shields on each other and end up playing with the parameters to softwareserial.
Since the retailer of the TFT screen is also selling stuff like cosmetics and hair nets, you are unlikely to get great technical support there.
6v6gt:
You could try posting the code that you have working for the TFT on the Mega and the GPRS module on the Uno and see if anyone can help.
You may have to end up connecting at least one of the devices with hook up wires instead of stacking the shields on each other and end up playing with the parameters to softwareserial.
Since the retailer of the TFT screen is also selling stuff like cosmetics and hair nets, you are unlikely to get great technical support there.
I already am hooking the TFT up with wires, not stacking it.
Some code for the GSM Module is found at the GSM link I first provided. (Post #3)
As far as the TFT, here is some basic code. (File Attached)
THANK YOU SO MUCH EVERYONE FOR THE HELP SO FAR!!! I love it!
So here is my question:
Can somebody please give me a definite answer about how to change the DIGITAL pins that the GSM module uses. I am aware you can change the Software Serial pins, but can you change Digital Pins 7, 8, and 9? Or ARE those the Software Serial pins you guys are referring to? If so, how do I change those?
Have you actually got the TFT screen working with the Mega ?
Can you draw a schematic showing the Mega pins and the TFT pins and their interconnection.
From the sketch you've provided (here are the definitions), it talks about pins A0 to A4 and also, for the Mega, pins 22 through 29.
// This sketch has been Refurbished by BUHOSOFT
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.
//#define DEBUG
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
. . .
. . .
. . .
In principle, if you are using softwareserial to talk to a device, you specify in the softwareserial declaration which pins on the Arduino you are going to connect the device to. It is as simple as that.
sureview:
you could use the nextion lcd touchscreen display, much simpler to integrate and its controlled via serial , there is an arduino library for it
Guys, this is proving to be such a problem. (In general, the TFT screen)
I have decided to do this.
I have gotten the Nextion touch screen display, however it won't work! I put my Nextion Touch Screen display issue in a different post. PLEASE, take a look and help me there with this problem: