Skip to content

Commit d16eeb0

Browse files
author
Tom Igoe
committed
Modified Pachube examples to use manual Ethernet config if DCHP fails.
1 parent 6a68361 commit d16eeb0

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

libraries/Ethernet/examples/PachubeClient/PachubeClient.ino

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Ethernet shield attached to pins 10, 11, 12, 13
1212
1313
created 15 March 2010
14-
updated 4 Sep 2010
14+
updated 26 Oct 2011
1515
by Tom Igoe
1616
1717
http://www.tigoe.net/pcomp/code/category/arduinowiring/873
@@ -28,6 +28,9 @@
2828
byte mac[] = {
2929
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
3030

31+
// fill in an available IP address on your network here,
32+
// for manual configuration:
33+
IPAddress ip(10,0,1,20);
3134
// initialize the library instance:
3235
EthernetClient client;
3336

@@ -38,15 +41,14 @@ const int postingInterval = 10000; //delay between updates to Pachube.com
3841
void setup() {
3942
// start serial port:
4043
Serial.begin(9600);
44+
// give the ethernet module time to boot up:
45+
delay(1000);
4146
// start the Ethernet connection:
4247
if (Ethernet.begin(mac) == 0) {
4348
Serial.println("Failed to configure Ethernet using DHCP");
44-
// no point in carrying on, so do nothing forevermore:
45-
for(;;)
46-
;
49+
// Configure manually:
50+
Ethernet.begin(mac, ip);
4751
}
48-
// give the ethernet module time to boot up:
49-
delay(1000);
5052
}
5153

5254
void loop() {

libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Ethernet shield attached to pins 10, 11, 12, 13
1515
1616
created 15 March 2010
17-
updated 4 Sep 2010
17+
updated 26 Oct 2011
1818
by Tom Igoe
1919
2020
This code is in the public domain.
@@ -28,6 +28,9 @@
2828
// fill in your address here:
2929
byte mac[] = {
3030
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
31+
// fill in an available IP address on your network here,
32+
// for manual configuration:
33+
IPAddress ip(10,0,1,20);
3134

3235
// initialize the library instance:
3336
EthernetClient client;
@@ -37,16 +40,16 @@ boolean lastConnected = false; // state of the connection last time through
3740
const int postingInterval = 10000; //delay between updates to Pachube.com
3841

3942
void setup() {
40-
// start the ethernet connection and serial port:
43+
// start serial port:
4144
Serial.begin(9600);
45+
// give the ethernet module time to boot up:
46+
delay(1000);
47+
// start the Ethernet connection:
4248
if (Ethernet.begin(mac) == 0) {
4349
Serial.println("Failed to configure Ethernet using DHCP");
44-
// no point in carrying on, so do nothing forevermore:
45-
for(;;)
46-
;
50+
// Configure manually:
51+
Ethernet.begin(mac, ip);
4752
}
48-
// give the ethernet module time to boot up:
49-
delay(1000);
5053
}
5154

5255
void loop() {

0 commit comments

Comments
 (0)