Hello, I have been using version 23 very happy but was thinking of upgrading to 1.0.
however i am having trouble with the webclient example cause you can no longer specify the ip of the arduino and the gateway of the router.
i have tried the following with the following error
/*
Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
by David A. Mellis
*/
#include <SPI.h> #include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte ip[] = { 192,168,1,177 };
byte gateway[] = { 192,168,1,1 };
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(173,194,33,104); // Google
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// start the serial library:
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac, ip, gateway) == 0) {
//if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;
;
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;
;
}
}
WebClient.cpp: In function 'void setup()':
WebClient:33: error: void value not ignored as it ought to be
Normally, your router can take care of dns for clients, so I would try the same ip for both the gateway and dns server. That is how my routers issue dhcp settings. It issues its ip as the dns server. Otherwise, try the dns ip your localnet computers use in their settings.
Add: I was interrupted by work Here is an example.
That is a correct error. Only
Ethernet.begin(mac);
returns a value. All others (believe it or not!) are a void type. Use just
Ethernet.begin(mac,ip,gateway,gateway);
uppsss sorry for my stupid question then .
thats correct it solved the issue, however does not connect eventhough i am using same ip, gateway and server as in arduino 22 version
/*
Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
by David A. Mellis
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte ip[] = { 192,168,1,177 };
byte gateway[] = { 192,168,1,1 };
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(173,194,33,104); // Google
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// start the serial library:
Serial.begin(9600);
// start the Ethernet connection:
// if (Ethernet.begin(mac,ip,gateway,gateway) == 0) {
Ethernet.begin(mac,ip,gateway,gateway);
{
// Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// for(;;)
// ;
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}
..._Arduino\arduino-1.0\libraries\EEPROM\EEPROM.cpp: In member function 'void EEPROMClass::writeInt(int, int)':
..._Arduino\arduino-1.0\libraries\EEPROM\EEPROM.cpp:56: error: 'Byte' was not declared in this scope
...\arduino-1.0\libraries\EEPROM\EEPROM.cpp:57: error: expected `)' before 'value'
the byte is doing a cast,right? why the error? maybe i need to include "WConstants.h"??
I was getting an error with that included but commenting it solved it, dont know if its related to the BYTE issue.
SuferTim that seems to fix the problem. although now i have an incompatibility with RTC so need to fix it and see if all compiles, ill report back if it solved the issue.
Paul I got an error in arduino1.0 calling Wconstants.h, commenting it remove the error and did not throw any new errors. is this normal?
btw, anyone know if a dead easy RTC library for arduino1.0, one where i can just call RTC.seconds() etc to get the values?