this is your code modified by myself to the test:
/*
Web client sketch for IDE v1.0.1 and w5100/w5200
Posted October 2012 by SurferTim
*/
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,20);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress server(74,125,227,16); // Google
//IPAddress server(173,194,35,191); // Google
EthernetClient client;
int totalCount = 0;
int loopCount = 0;
char pageAdd[32];
// Define pins and Libraries of TFT LCD 1.8"
//#define sclk 13
//#define mosi 11
#define ss1 7
#define dc 9
#define rst -1 // you can also connect this to the Arduino reset
Adafruit_ST7735 tft = Adafruit_ST7735(ss1, dc, rst);
int i = 1;
void setup() {
Serial.begin(9600);
// disable TFT SPI
pinMode(7,OUTPUT);
digitalWrite(7,HIGH);
// disable SD SPI
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
// Start ethernet
Serial.println("Starting ethernet...");
Ethernet.begin(mac, ip, gateway, gateway, subnet);
// If using dhcp, comment out the line above
// and uncomment the next 2 lines
// if(!Ethernet.begin(mac)) Serial.println("failed");
// else Serial.println("ok");
Serial.println(Ethernet.localIP());
delay(2000);
Serial.println("Ready");
tft.initR(INITR_REDTAB); // initialize a ST7735R chip, red tab
}
void loop()
{
digitalWrite(10, LOW);
if(loopCount < 30)
{
// if loopCount is less than 30, just delay a second
delay(1000);
}
else
{
// every thirty seconds this runs
loopCount = 0;
// Modify next line to load different page
// or pass values to server
sprintf(pageAdd,"/",totalCount);
// sprintf(pageAdd,"/arduino.php?test=%u",totalCount);
if(!getPage(server,pageAdd)) Serial.print("Fail ");
else Serial.print("Pass ");
totalCount++;
Serial.println(totalCount,DEC);
}
loopCount++;
}
byte getPage(IPAddress ipBuf,char *page)
{
int inChar;
char outBuf[128];
Serial.print("connecting...");
if(client.connect(ipBuf,80))
{
Serial.println("connected");
sprintf(outBuf,"GET %s HTTP/1.0\r\n\r\n",page);
client.write(outBuf);
}
else
{
Serial.println("failed");
return 0;
}
// connectLoop controls the hardware fail timeout
int connectLoop = 0;
while(client.connected())
{
while(client.available())
{
inChar = client.read();
Serial.write(inChar);
// set connectLoop to zero if a packet arrives
connectLoop = 0;
}
connectLoop++;
// if more than 10000 milliseconds since the last packet
if(connectLoop > 10000)
{
// then close the connection from this end.
Serial.println();
Serial.println("Timeout");
client.stop();
}
// this is a delay for the connectLoop timing
delay(1);
}
Serial.println();
Serial.println("disconnecting.");
// close client end
client.stop();
digitalWrite(10,HIGH);
digitalWrite(7, LOW);
tft.setTextWrap(true);
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 5);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.setTextColor(ST7735_GREEN);
tft.println(" Weather Station");
tft.println(" Fabro1");
Serial.print(i++);
tft.println(i++);
digitalWrite(7,HIGH);
return 1;
}