Seedstudio Wifi Shield v1.1 and Itead studio TFT

hi, this is my code:

// TFT - SEEDSTUDIO ITDB28:
#include <UTFT.h>
#include <UTouch.h>
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
UTFT myGLCD(ITDB28, 38,39,40,41);   
UTouch myTouch(6,5,4,3,2);
int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

// WIFLY - SEEDSTUDIO WIFI SHIELD V1.1: 
#include "Wifly.h"
#include <SoftwareSerial.h>
WiflyClass Wifly(10,11);


void drawButtons()
{

// Draw the buttons
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRoundRect (16, 172, 107, 208);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (16, 172, 107, 208);
  myGLCD.print("Carne", 40, 185);
  
  myGLCD.setColor(0, 255, 0);
  myGLCD.fillRoundRect (114, 172, 206, 208);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (114, 172, 206, 208);
  myGLCD.print("Peixe", 140, 185);
  
  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRoundRect (214, 172, 306, 208);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (214, 172, 306, 208);
  myGLCD.print("Dieta", 240, 185);
  
  myGLCD.setBackColor (0, 0, 0);
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable())
    myTouch.read();
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
}

void setup(){
  //all:
  Serial.begin(9600);
  
  // TFT Initial setup
  myGLCD.InitLCD(LANDSCAPE);
  //myGLCD.clrScr();
  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_EXTREME);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(0, 0, 255);
  drawButtons();

  //WIFLY initialization and parameterization:
  //Based on the pdf: WiFly-RN-UM.pdf
  Wifly.init();
  char ssid[] = "myWLAN";
  char passphrase[] = "";                         // for wpa and wpa2
  char key[] ="mypasswep";                       // "mypassAscii" converted is "mypasswep" : http://www.corecoding.com/utilities/wep2hex.php 
  //char ip[] = "192.168.10.10";                  // for static ip address
  //char gateway[] = "192.168.1.1";               // for static ip address
  //char mask[] = "255.255.255.0";                // for static ip address
  Wifly.sendCommand("$$", "CMD");
  Wifly.sendCommand("set w join 0\r", "AOK");
  Wifly.sendCommand("set comm remote 0\r", "AOK");
  Wifly.sendCommand("set w linkmon 5\r", "AOK");
  Wifly.sendCommand("set comm idle 0\r", "AOK");
  Wifly.sendCommand("set wlan auth 8\r","AOK");   // wep 128 = 1  || wep 64 = 8 || wap =2 || wap2-psk =4
  //Wifly.sendCommand("set dns address 192.168.1.2\r", "AOK");
  Wifly.sendCommand("set w ssid ","");
  Wifly.sendCommand(ssid, "", true);
  Wifly.sendCommand("\r", "AOK", true);
  //if(passphrase != NULL) {                        // if wap or wap2
  //  Wifly.sendCommand("set w phrase ","");
  //  Wifly.sendCommand(passphrase, "", true);
  //  Wifly.sendCommand("\r", "AOK", true);
  //}
  if(key != NULL) {                               // if wep128 or wep64
    Wifly.sendCommand("set w k ","");
    Wifly.sendCommand(key, "", true);
    Wifly.sendCommand("\r", "AOK", true);
  }
  Wifly.sendCommand("set ip dhcp 1\r","AOK");
  //Wifly.sendCommand("set ip address ", "");  // for static IP 
  //Wifly.sendCommand(ip, "", true);
  //Wifly.sendCommand("\r", "AOK", true);
  //Wifly.sendCommand("set ip gateway ", "");
  //Wifly.sendCommand(gateway, "", true);
  //Wifly.sendCommand("\r", "AOK", true);
  //Wifly.sendCommand("set ip netmask ", "");
  //Wifly.sendCommand(mask, "", true);
  //Wifly.sendCommand("\r", "AOK", true);
  
  Wifly.sendCommand("save\r", "Storing in config");
  Wifly.sendCommand("exit\r", "EXIT");
  Wifly.reboot();

  Wifly.join(ssid);
  Wifly.checkAssociated();
  //while(!Wifly.connect("192.168.10.191","90"));
  //Wifly.writeToSocket("Connected!");
  //end of initialization and parameterization:
  
  Serial.print("***** end of wifly config ******");  
}

void loop()
{
//  //WIFLIY LOOP
//  if(Wifly.canReadFromSocket()){
//    Wifly.readFromSocket();
//  }
//  if(Serial.available())
//  {
//    Wifly.print((char)Serial.read());
//  }

  // TFT LOOP

    if (myTouch.dataAvailable())
    {
       Serial.print("Touch avaliable"); 
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();
      
      // @hack to fix misplaced touch on unit
      x = myGLCD.getDisplayXSize() - x;
      
      if ((y>=172) && (y<=208))  
      {
          if ((x>=16) && (x<=107))  
        {
          waitForIt(16, 172, 107, 208);
          myGLCD.setColor(255, 255, 255);
          myGLCD.fillRect(0, 224, 319, 239);
          
          myGLCD.setFont(BigFont);
          myGLCD.print(" * text 1 * , 120);
          delay(1000);
        }
        else if ((x>=114) && (x<=206)) 
        {
          waitForIt(114, 172, 206, 208);
           myGLCD.setColor(255, 255, 255);
          myGLCD.fillRect(0, 224, 319, 239);
          
          myGLCD.setFont(BigFont);
          myGLCD.print(" * text 2 * ", CENTER, 120);
          delay(1000);
        }
        else if ((x>=214) && (x<=306))
        {
          waitForIt(214, 172, 306, 208);
           myGLCD.setColor(255, 255, 255);
          myGLCD.fillRect(0, 224, 319, 239);

          myGLCD.setFont(BigFont);
          myGLCD.print(" * text 3 * ", CENTER, 120);
          delay(1000);
        }
      }
    }
}

I compiled the code wifi and TFT separately and everything works fine …

however, together the touch does not work, can you help me?

Which Arduino (or clone) do you have? The high pin numbers in the myGLCD instance imply that you have a Mega-compatible Arduino or clone. The use of SoftwareSerial on such a device is a waste. Use the hardware serial ports and instances!

PaulS:
Which Arduino (or clone) do you have? The high pin numbers in the myGLCD instance imply that you have a Mega-compatible Arduino or clone. The use of SoftwareSerial on such a device is a waste. Use the hardware serial ports and instances!

I use Arduino Mega R3 2560…

My actual code:

//TFT
#include <UTFT.h>
#include <UTouch.h>
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
UTFT myGLCD(ITDB28, 38,39,40,41);   
UTouch myTouch(6,5,4,3,2);
int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

//LED
#include "RGBdriver.h"
#define CLK 9//pins definitions for the LED        
#define DIO 8
RGBdriver LED(CLK,DIO);

//buzzer
const int buzzerPin =  16;    

//rfid
#include <SoftwareSerial.h>
SoftwareSerial rfid(12, 13);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;     // counter for buffer array 

//RTC
#include <Wire.h>
#include "DS1307.h"
DS1307 clock;

//wifi
#include "Wifly.h"
WiflyClass Wifly(10,11);
char ssid[] = "****";
char passphrase[] = "";   //for wpa and wpa2
char key[] ="*****";   // **** converted : http://www.corecoding.com/utilities/wep2hex.php 

void setup()
{
  //all 
  Serial.begin(9600);

  //initial setup TFT
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_EXTREME);

  myGLCD.setFont(SmallFont);
  //drawButtons();

  //initial setup LED
  LED.begin(); // begin
  LED.SetColor(0, 0, 0); //Red. first node data
  LED.end();  

  //initial setup Buzzer
  pinMode(buzzerPin, OUTPUT);   

  //initial setup rfid:
  rfid.begin(9600); 


  //initial setup rtc
  clock.begin();
  //IF YOU NEED TO SET TIME UNCOMMENT:
  //clock.fillByYMD(2013,04,03);//Jan 19,2013
  //clock.fillByHMS(11,35,30);//15:28 30"
  //clock.fillDayOfWeek(WED);//day of week
  //clock.setTime();//write time to the RTC chip
  myGLCD.setColor(255,255,255);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.print("Aguarde por favor... a configurar wifi", CENTER, 128);
  //initial setup wifi
  Wifly.init();
  
  //char ip[] = "192.168.10.10"; // for static ip address
  //char gateway[] = "192.168.1.1";
  //char mask[] = "255.255.255.0";
  Wifly.sendCommand("$$", "CMD");
  Wifly.sendCommand("set u b 9600\r","AOK");
  Wifly.sendCommand("set w join 0\r", "AOK");
  Wifly.sendCommand("set comm remote 0\r", "AOK");
  Wifly.sendCommand("set w linkmon 5\r", "AOK");
  Wifly.sendCommand("set comm idle 0\r", "AOK");
  Wifly.sendCommand("set wlan auth 8\r","AOK");           // wep 128 = 1  || wpe 64 = 8 || wap =2 || wap2-psk =4
  //Wifly.sendCommand("set dns address 192.168.1.2\r", "AOK");
  Wifly.sendCommand("set w ssid ","");
  Wifly.sendCommand(ssid, "", true);
  Wifly.sendCommand("\r", "AOK", true);
  if(passphrase != NULL) {
    Wifly.sendCommand("set w phrase ","");
    Wifly.sendCommand(passphrase, "", true);
    Wifly.sendCommand("\r", "AOK", true);
  }
  if(key != NULL) {
    Wifly.sendCommand("set w k ","");
    Wifly.sendCommand(key, "", true);
    Wifly.sendCommand("\r", "AOK", true);
  }
  Wifly.sendCommand("set ip dhcp 1\r","AOK");
  //  Wifly.sendCommand("set ip address ", "");  // for static IP 
  //  Wifly.sendCommand(ip, "", true);
  //  Wifly.sendCommand("\r", "AOK", true);
  //  Wifly.sendCommand("set ip gateway ", "");
  //  Wifly.sendCommand(gateway, "", true);
  //  Wifly.sendCommand("\r", "AOK", true);
  //  Wifly.sendCommand("set ip netmask ", "");
  //  Wifly.sendCommand(mask, "", true);
  //  Wifly.sendCommand("\r", "AOK", true);
  Wifly.sendCommand("save\r", "Storing in config");
  Wifly.sendCommand("exit\r", "EXIT");
  Wifly.reboot();
    Wifly.join(ssid);
    Wifly.checkAssociated();
  //while(!Wifly.connect("192.168.10.191","90"));
    Wifly.writeToSocket("Connected!");

    
}

String cliente = "";

void loop()
{
  
    myGLCD.clrScr();
    Serial.println("LOOP READY");

  while (true)
  {
    //RFID:
 // DATE AND TIME
    myGLCD.setColor(255,255,255);
    myGLCD.setBackColor(0, 0, 0);
    char date_time[20]; 
    digitalClockDisplay(date_time);
    myGLCD.print(date_time, CENTER, 60);
    
    Serial.println(date_time);
    if (rfid.available())              // if date is comming from softwareserial port ==> data is comming from rfid shield
    {
      Serial.print("RFID AVALIABLE");
      while(rfid.available())          // reading data into char array 
      {
        buffer[count++]=rfid.read();     // writing data into array
        if(count == 64)break;
      }
      cliente = GetInfo(buffer);        
      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


      Serial.print("RFID FOUND");
      myGLCD.setFont(SmallFont);
      myGLCD.print("Funcionario: " + cliente, CENTER, 40);
      waitclick();
      LED.begin(); // begin
      LED.SetColor(0, 0, 0); //Red. first node data
      LED.end();        
      myGLCD.clrScr();
      myGLCD.setFont(SmallFont);

      clearPendingRfidData();
      delay(500);
    }    
  }
}

blablabla

rfid and wifi are in conflict …

when active “wifi” → “rfid.available () == false”

rfid and wifi are in conflict ..

when active "wifi" -> "rfid.available () == false"

Neither should be using SoftwareSerial when you have 4 hardware serial ports.

PaulS:

rfid and wifi are in conflict ..

when active "wifi" -> "rfid.available () == false"

Neither should be using SoftwareSerial when you have 4 hardware serial ports.

Please indicate how can I do it?

Please indicate how can I do it?

Start with the RFID reader, as that it is a simpler change. Get rid of the SoftwareSerial instance that is trying to read the RFID data. Connect the reader to one of the hardware serial pairs of pins (RX1/TX1, RX2/TX2, etc.). Then, use Serial1, Serial2, or Serial3 (corresponding to the pins you connected the reader to) instead of rfid.

Changing the WiFly class may be more of an issue. I don't know, because I don't know where you got the library.

PaulS:

Please indicate how can I do it?

Start with the RFID reader, as that it is a simpler change. Get rid of the SoftwareSerial instance that is trying to read the RFID data. Connect the reader to one of the hardware serial pairs of pins (RX1/TX1, RX2/TX2, etc.). Then, use Serial1, Serial2, or Serial3 (corresponding to the pins you connected the reader to) instead of rfid.

Changing the WiFly class may be more of an issue. I don't know, because I don't know where you got the library.

ok, thank you..

tomorrow I will test this solution.

hi,

worked very well with RFID ..

but how do I put this in Serial3?

#include "SoftwareSerial.h"
#include "Wifly.h"
WiflyClass Wifly(10,11);

but how do I put this in Serial3?

You start by providing a link to the library in question. It may, or may not, be possible to change it. It may, or may not, be necessary to change it. Have you tested? If there is only ONE instance of SoftwareSerial, using the correct pins, it may be OK.

PaulS:

but how do I put this in Serial3?

You start by providing a link to the library in question. It may, or may not, be possible to change it. It may, or may not, be necessary to change it. Have you tested? If there is only ONE instance of SoftwareSerial, using the correct pins, it may be OK.

http://www.seeedstudio.com/wiki/images/b/b8/WifiShield.zip

yes.. I tested with SoftwareSerial (10,11) and works well but i need to use Serial3 pins...

but i need to use Serial3 pins…

Doesn’t seem likely. That class derives from SoftwareSerial. Changing the class to HardwareSerial class is going to be a challenge.

Does the shield even cover the Serial3 pins? Is it going to be possible to set the jumpers to use the Serial3 pins?