Hi all, as title suggested, I have no issue to send out single tweet in the program. I already updated Twitter.h and Twitter.cpp to compatible with wifi shield. The issue is occurs when I have multiple tweet's need to post. I've put some delay around 2 minute in between each tweets to avoid over load the server. The result only first tweet posted up and the second one is connection failed. Please refer to my code below. Thanks in advance... $) $) $)
#include <SPI.h>
#include <Twitter.h>
#include <WiFi.h>
char ssid[] = "Farizal_Mi3";// your network SSID (name)
char pass[] = "abcdefgh"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
WiFiServer server(80);
String readString;
// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("MY TOKEN");
void setup()
{
delay(1000);
Serial.begin(9600);
// start the WiFi connection and the server:
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
while(true); // don't continue
}
String fv = WiFi.firmwareVersion();
if( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
server.begin(); // start the web server on port 80
printWifiStatus(); // you're connected now, so print out the status
}//Setup END
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
// print where to go in a browser:
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
}
void loop()
{
delay(1000);
Serial.println("First tweet is sending...");
if (twitter.post("@mdfarizal8 Hi From Galileo : test tweet First"))
{
Serial.println ("First tweet : OK.");
}
else
{
Serial.println("First tweet connection failed.");
}
Serial.println("Delay 2 min");
delay(60000); //Msg interval delay
Serial.println("Delay 1 min");
delay(60000); //Msg interval delay
Serial.println("End Delay");
delay(1000);
Serial.println("Second tweet is sending...");
if (twitter.post("@mdfarizal8 Hi From Galileo : test tweet 2nd"))
{
Serial.println ("Second tweet :OK.");
}
else
{
Serial.println("Second tweet connection failed.");
}
do{} while(1>0); // endless loop
}
Below is an output from serial monitor:
Attempting to connect to Network named: Farizal_Mi3
SSID: Farizal_Mi3
IP Address: 192.168. 43.128
signal strength (RSSI):-51 dBm
To see this page in action, open a browser to http://192.168. 43.128
First tweet is sending...
First tweet : OK.
Delay 2 min
Delay 1 min
End Delay
Second tweet is sending...
Second tweet connection failed.