Go Down

Topic: Twittering with Arduino+Ethernet Shield (Read 3 times) previous topic - next topic

PeterH

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.
I only provide help via the forum - please do not contact me for private consultancy.

mkwired

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.

Code: [Select]

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);
  // ..

Frisky

What Arduino are you using? If your using the Uno there is not enough sram. I had to use my Atmega2560 board and the example worked fine.
Don

Abelavit

I tried with Atmega2560 board and still no luck.
The result is:

117.17.80.199
255.255.255.0
117.17.80.1
117.17.80.1
connecting ...
failed : code 0

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:

117.17.80.199
255.255.255.0
117.17.80.1
6.0.0.0
connecting ...
failed : code 0

In either case the IP of dns server is different compared to my desktop computer.
Is there way to declare the dns IP?

Frisky

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
Code: [Select]

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

Go Up