// Message to post
char msg[] = "Hello, World! I'm Arduino!";
void setup()
{
delay(1000);
Ethernet.begin(mac, ip);
// or you can use DHCP for autoomatic IP address configuration.
// Ethernet.begin(mac);
Serial.begin(9600);
Serial.println("connecting ...");
if (twitter.post(msg)) {
// Specify &Serial to output received response to Serial.
// If no output is required, you can just omit the argument, e.g.
// int status = twitter.wait();
int status = twitter.wait();
The IP address is valid. I have used it to send emails to my gmail account. I am using arduino UNO and the shield is connected through RJ45 cable.
Inclusion of '&Serial' as below doesnt affect the output anyway.
int status = twitter.wait(&Serial);
The statement ' if (twitter.post(msg))' returns true which means it is able to establish connection to twitter.
The problem lies in the posting process. Should return HTTP status code in response from Twitter, e.g. 200 - OK. Only available after posting the message is done. But in my case the status is 0 rather than 200. :~
The code you're getting is supposed to be an HTTP status code but clearly isn't; presumably the connection has closed or failed without providing an HTTP response. I suggest you pass in a Print* argument to wait() so that you can see what is being received. You should normally see something line "HTTP/1.1 200" but evidently that isn't happening in this case.
So when you changed the wait statement the serial output didn't change, right?
At this point, the only thing I can think of this that DNS isn't working for the board. Add the following "print" statements and report back on the result.
void setup()
{
delay(1000);
Ethernet.begin(mac, ip);
// or you can use DHCP for autoomatic IP address configuration.
// Ethernet.begin(mac);
Serial.begin(9600);
Ethernet.localIP.printTo(Serial);
Ethernet.subnetMask.printTo(Serial);
Ethernet.gatewayIP.printTo(Serial);
Ethernet.dnsServerIP.printTo(Serial);
// ..
I don’t know much about networks, but is it okay to have the same IPs for gateway and dns as shown in the result. I used this statement: Ethernet.begin(mac, ip);
When I included dns i.e Ethernet.begin(mac, ip, dns); the dns IP changes:
I compared my working code with yours, the only difference I see I'm using DHCP to get a ip address it takes about 5 secs to get a ip from my router. Posting to Twitter is really fast. If you get a error 403
you send a duplicate tweet. I copied this right from my working sketch. If you want to follow me on twitter @AlertsChicago I'm posting weather and emergency broadcast alerts here in Chicago.
Don
void setup()
{
delay(1000);
if (!Ethernet.begin(mac)) // Try to connect using DHCP
Ethernet.begin(mac, ip); // Try to connect using a Static IP address.
delay(100);
Serial.begin(9600);
delay(100);
Serial.print(F("Connected to IP address: ")); // Print out the IP address.
for (int i = 0; i < 4; i++)
{
Serial.print(Ethernet.localIP()[i], DEC);
Serial.print(".");
}
Serial.println();
Serial.println();
}
I copied this right from my working sketch.
if you want to follow me on twitter @AlertsChicago
I am using my universities network so due to restrictions, I cannot use DHCP to automatically assign the IP hence iam doing it manually.
Ok i declared the DNS server IP:
did anything post to twitter? if you use those setting in your computer can you get on the internet
get to twitter or google, yahoo? to see if they really would maybe ping, traceroute
403 means you are trying to send a duplicate tweet...
Don
The posting is okay....
Thought nothing was being posted by looking at errors i was getting.
Its working now...Thanks mate.
But m worried about the errors i am getting...if i ignore it, will it b fine?
I bet the after the Arduino is completed programing it resets runs your setup code posting the message.
Then you fire up the serial monitor and the board resets again, you double tweeted.
If you remove the posting of the tweet from setup() function and do something like this in loop() you can control it yourself using the serial monitor put a "t" in the line and press send....
void loop()
{
byte inChar;
inChar = Serial.read();
delay(100);
if(inChar == 't')
{
Serial.println("connecting ...");
if (twitter.post(msg))
{
// Specify &Serial to output received response to Serial.
// If no output is required, you can just omit the argument, e.g.
// int status = twitter.wait();
int status = twitter.wait();
if (status == 200) {
Serial.println("OK.");
}
else
{
Serial.print("failed : code ");
Serial.println(status);
}
inChar = 0;
}
}
Abelavit:
HTTP/1.0 403 Forbidden
what might be wrong now?
That means you've succeeded in accessing the network but the server didn't like your tweet. It means you've solved the problem. Now if you want to sends tweets for real, you need to make them unique.
Peter
I think that after the Ardunio programs it resets and runs his code. Then he is watching it via serial monitor to debug and that is why he is double posting or tweeting that will give you a 403 since he is sending the same message. He will need to change his tweet some too since he can't keep sending the same thing.
Maybe read millis
unsigned long time;
time = millis();
//prints time since program started
client.println(time);
Abelavit:
I am using my universities network so due to restrictions, I cannot use DHCP to automatically assign the IP hence iam doing it manually.
Ok i declared the DNS server IP:
Error 403 - Status is a duplicate.
failed : code 403
what might be wrong now?
There maybe a problem in the future if some other computer starts using that assigned IP assigned. It would be nice if the university would give you another IP address for your second computer.