South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« on: January 07, 2013, 01:13:08 pm » |
Hi all. I'm working on a project in which the circuit will be active 24/7. However, only the arduino will be needed 24/7 and the Ethernet shield only when necessary. I thought what I could do is use a digital pin on the arduino to switch power to the ethernet shield only when an event has been detected because of the high power consumption of the shield. However using this method, the code in void setup() will not run and the board won't be set up. I have tried to modify the following example from Pushingbox.com by putting all the Ethernet setup stuff in its own function and calling it after the pinstate has been read, but I get all sorts of errors on compiling  //// // // General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2 // ////
#include <SPI.h> #include <Ethernet.h>
///////////////// // MODIFY HERE // ///////////////// byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want char DEVID1[] = "Your_DevID_Here"; //Scenario : "The mailbox is open"
//Numeric Pin where you connect your switch uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
// Debug mode boolean DEBUG = true; ////////////// // End // //////////////
char serverName[] = "api.pushingbox.com"; boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1 boolean lastConnected = false; // State of the connection last time through the main loop
// 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() { Serial.begin(9600); pinMode(pinDevid1, INPUT); // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } else{ Serial.println("Ethernet ready"); // print the Ethernet board/shield's IP address: Serial.print("My IP address: "); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000); }
void loop() { //// // Listening for the pinDevid1 state //// if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON { if(DEBUG){Serial.println("pinDevid1 is HIGH");} pinDevid1State = true; //Sending request to PushingBox when the pin is HIGHT sendToPushingBox(DEVID1); } if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF { if(DEBUG){Serial.println("pinDevid1 is LOW");} pinDevid1State = false; //Sending request to PushingBox when the pin is LOW //sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable } //DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK" if (client.available()) { char c = client.read(); if(DEBUG){Serial.print(c);} } // if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){Serial.println();} if(DEBUG){Serial.println("disconnecting.");} client.stop(); } lastConnected = client.connected(); }
//Function for sending the request to PushingBox void sendToPushingBox(char devid[]){ client.stop(); if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) { if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");} client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Arduino"); client.println(); } else { if(DEBUG){Serial.println("connection failed");} } }
|
|
|
|
« Last Edit: January 08, 2013, 11:12:04 pm by dtokez »
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 315
Posts: 35519
Seattle, WA USA
|
 |
« Reply #1 on: January 07, 2013, 01:23:49 pm » |
I thought what I could do is use a digital pin on the arduino to switch power to the ethernet shield only when an event has been detected because of the high power consumption of the shield. However using this method, the code in void setup() will not run and the board won't be set up. You want to use a pin that can supply a max of 40mA to power an ethernet shield? I don't think so. but I get all sorts of errors on compiling But, you aren't going to share them, because they are private?
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #2 on: January 07, 2013, 01:37:09 pm » |
Obviously not supplying 240mA direct from a pin lol  Just got this to compile but can't test for a while until I am home, from your experience does it look like it would work? //// // // General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2 // ////
#include <SPI.h> #include <Ethernet.h>
// Debug mode boolean DEBUG = true;
//Numeric Pin where you connect your switch uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
char serverName[] = "api.pushingbox.com"; boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1 boolean lastConnected = false; // State of the connection last time through the main loop
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want char DEVID1[] = "Your_DevID_Here"; //Scenario : "The mailbox is open"
void ethernetStart(){ byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
// 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;
// start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } else{ Serial.println("Ethernet ready"); // print the Ethernet board/shield's IP address: Serial.print("My IP address: "); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000); }
void setup() { Serial.begin(9600); pinMode(pinDevid1, INPUT); }
void loop() { //// // Listening for the pinDevid1 state //// if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON { if(DEBUG){Serial.println("pinDevid1 is HIGH");} void ethernetStart(); pinDevid1State = true; //Sending request to PushingBox when the pin is HIGHT sendToPushingBox(DEVID1); } if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF { if(DEBUG){Serial.println("pinDevid1 is LOW");} pinDevid1State = false; //Sending request to PushingBox when the pin is LOW //sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable } /* //DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK" if (client.available()) { char c = client.read(); if(DEBUG){Serial.print(c);} } // if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){Serial.println();} if(DEBUG){Serial.println("disconnecting.");} client.stop(); } lastConnected = client.connected(); */ }
//Function for sending the request to PushingBox void sendToPushingBox(char devid[]){ EthernetClient client; client.stop(); if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) { if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");} client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Arduino"); client.println(); } else { if(DEBUG){Serial.println("connection failed");} } }
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 315
Posts: 35519
Seattle, WA USA
|
 |
« Reply #3 on: January 07, 2013, 03:12:56 pm » |
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3 Then, why isn't the variable named mailboxPin? boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1 I like mailboxState better.
Useful. void ethernetStart(); A function prototype, not a function call. If you create a connection, you MUST read all data that the client sends. Otherwise, that socket is never made available for re-use.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #4 on: January 07, 2013, 04:06:11 pm » |
Hi again.
The code is taken straight from the example I have not customised it for my project yet. It will send notifications to mine and my partners mobile phones if an alarm state is triggered.
Could you please elaborate on the last comment you made? I thought that I could call the ethernet setup procedure from my code?
How could I make sure that I read all the data from the client?
Many thanks
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 315
Posts: 35519
Seattle, WA USA
|
 |
« Reply #5 on: January 07, 2013, 05:40:49 pm » |
Could you please elaborate on the last comment you made? I thought that I could call the ethernet setup procedure from my code? The example has code: /* //DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK" if (client.available()) { char c = client.read(); if(DEBUG){Serial.print(c);} } // if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){Serial.println();} if(DEBUG){Serial.println("disconnecting.");} client.stop(); } lastConnected = client.connected(); */ Why is this commented out? It is important. When a connection is made, a buffer is created, and a socket tied up. Until the buffer is empty, the socket can not be freed. Unless the socket is freed, the number of available sockets is decreased by 1. Since there are only 4 to begin with, 4 connections, and you need to reset the Arduino. Reading all the client data, which you should do to make sure that the post was successful, is necessary to empty the buffer so that the socket can be closed and reused.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #6 on: January 07, 2013, 07:06:09 pm » |
Paul, thank you for that explanation! I have now un commented that section, I thought it was purely for debugging. I had to add EthernetClient client; to get it to compile. I am testing now but can't get it working. Using the un-edited example it works fine. On the serial monitor i get the following: pinDevid1 is LOW connecting... connected sendind request pinDevid1 is HIGH
From this code: //// // // General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2 // ////
#include <SPI.h> #include <Ethernet.h>
// Debug mode boolean DEBUG = true;
//Numeric Pin where you connect your switch uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
//const int ethernetPWR = 4;
char serverName[] = "api.pushingbox.com"; boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1 boolean lastConnected = false; // State of the connection last time through the main loop
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want char DEVID1[] = "v7855F2ED5D6D177"; //DAN#Scenario : "Alarm state - FULL ALARM CONDITION"
void ethernetStart(){ byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
// 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;
// start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } else{ Serial.println("Ethernet ready"); // print the Ethernet board/shield's IP address: Serial.print("My IP address: "); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000); }
void setup() { Serial.begin(9600); pinMode(pinDevid1, INPUT); //pinMode(ethernetPWR, OUTPUT); digitalWrite(pinDevid1, HIGH); //digitalWrite(ethernetPWR, LOW); }
void loop() { //// // Listening for the pinDevid1 state //// if (digitalRead(pinDevid1) == LOW && pinDevid1State == false) // switch on pinDevid1 is ON { if(DEBUG){Serial.println("pinDevid1 is LOW");} //digitalWrite(ethernetPWR, HIGH); delay(100); void ethernetStart(); //Run ethernet setup routine pinDevid1State = true; //Sending request to PushingBox when the pin is HIGHT sendToPushingBox(DEVID1); } if (digitalRead(pinDevid1) == HIGH && pinDevid1State == true) // switch on pinDevid1 is OFF { if(DEBUG){Serial.println("pinDevid1 is HIGH");} pinDevid1State = false; //Sending request to PushingBox when the pin is LOW //sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable } //DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK" EthernetClient client; if (client.available()) { char c = client.read(); if(DEBUG){Serial.print(c);} } // if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){Serial.println();} if(DEBUG){Serial.println("disconnecting.");} client.stop(); } lastConnected = client.connected(); }
//Function for sending the request to PushingBox void sendToPushingBox(char devid[]){ EthernetClient client; client.stop(); if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) { if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");} client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Arduino"); client.println(); } else { if(DEBUG){Serial.println("connection failed");} } } From the unedited code, I get this feedback: Ethernet ready My IP address: 192.168.0.14 pinDevid1 is HIGH connecting... connected sendind request HTTP/1.1 200 OK Set-Cookie: 60gp=R717319988; path=/; expires=Tue, 08-Jan-2013 01:23:52 GMT Date: Tue, 08 Jan 2013 00:03:40 GMT Server: Apache/2.2.X (OVH) Content-Location: pushingbox.php Vary: negotiate,Accept-Encoding TCN: choice X-Powered-By: PHP/5.2.17 Content-Length: 0 Content-Type: text/html
pinDevid1 is LOW
disconnecting.
From this code: //// // // General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2 // ////
#include <SPI.h> #include <Ethernet.h>
///////////////// // MODIFY HERE // ///////////////// byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want char DEVID1[] = "v7855F2ED5D6D177"; //Scenario : "The mailbox is open"
//Numeric Pin where you connect your switch uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
// Debug mode boolean DEBUG = true; ////////////// // End // //////////////
char serverName[] = "api.pushingbox.com"; boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1 boolean lastConnected = false; // State of the connection last time through the main loop
// 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() { Serial.begin(9600); pinMode(pinDevid1, INPUT); // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } else{ Serial.println("Ethernet ready"); // print the Ethernet board/shield's IP address: Serial.print("My IP address: "); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000); }
void loop() { //// // Listening for the pinDevid1 state //// if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON { if(DEBUG){Serial.println("pinDevid1 is HIGH");} pinDevid1State = true; //Sending request to PushingBox when the pin is HIGHT sendToPushingBox(DEVID1); } if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF { if(DEBUG){Serial.println("pinDevid1 is LOW");} pinDevid1State = false; //Sending request to PushingBox when the pin is LOW //sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable } //DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK" if (client.available()) { char c = client.read(); if(DEBUG){Serial.print(c);} } // if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){Serial.println();} if(DEBUG){Serial.println("disconnecting.");} client.stop(); } lastConnected = client.connected(); }
//Function for sending the request to PushingBox void sendToPushingBox(char devid[]){ client.stop(); if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) { if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");} client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Arduino"); client.println(); } else { if(DEBUG){Serial.println("connection failed");} } } Have I got something in the set up in the wrong order do you think?
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #7 on: January 07, 2013, 07:15:29 pm » |
OK, my bad. I was calling void ethernet setup(); instead of ethernet setup(); It now works and I get notifications. I will now try and control the power from the arduino. The thing I am noticing now is that I am not getting some of the handshake feedback via serial I'm only getting this: pinDevid1 is LOW Ethernet ready My IP address: 192.168.0.14 connecting... connected sendind request pinDevid1 is HIGH
When I expect this (from the example code running): Ethernet ready My IP address: 192.168.0.14 pinDevid1 is HIGH connecting... connected sendind request HTTP/1.1 200 OK Set-Cookie: 60gp=R717319988; path=/; expires=Tue, 08-Jan-2013 01:23:52 GMT Date: Tue, 08 Jan 2013 00:03:40 GMT Server: Apache/2.2.X (OVH) Content-Location: pushingbox.php Vary: negotiate,Accept-Encoding TCN: choice X-Powered-By: PHP/5.2.17 Content-Length: 0 Content-Type: text/html
pinDevid1 is LOW any ideas, I'm stumped because it is working OK?
|
|
|
|
« Last Edit: January 07, 2013, 07:17:06 pm by dtokez »
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #8 on: January 08, 2013, 08:47:27 pm » |
I still can't fathom this out. Through lots of debugging I have worked out that if I power up the Ethernet shield at the same time as the Arduino (connected to Arduino 5v), everything runs and works fine. However, if I power up the Ethernet shield (connect it to Arduino 5v) after the Arduino has been powered up and started running, the Ethernet does not seem to initialize and the last debugging message I get back via serial is 'Starting Ethernet setup' so it must be hanging up in this function: void ethernetStart(){ delay(100); if(DEBUG){ Serial.println("Starting ethernet setup"); }
// start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } else{ Serial.println("Ethernet ready"); // print the Ethernet board/shield's IP address: Serial.print("My IP address: "); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000); if(DEBUG){ Serial.println("Finished ethernet setup"); } //serial debugging }
After a long time (10-20 seconds or so) it bombs out and I get 'Failed to configure Ethernet using DHCP' via Serial then runs the while loop doing nothing. I have been through the code many times, and I can't understand why it is happening. I can't see anything that is running only once in the setup() that would need the Ethernet shield to be powered up at that particular time? The main loop and the global variables are obviously the same if the shield is powered or not? What is happening at the time of powering up the Arduino that appears to be crucial for the shield to initialize properly? whole code: //// // // General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2 // ////
#include <SPI.h> #include <Ethernet.h>
// Debug mode boolean DEBUG = true;
//Numeric Pin where you connect your switch uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
const int ethernetPWR = 4;
char serverName[] = "api.pushingbox.com"; boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1 boolean lastConnected = false; // State of the connection last time through the main loop
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want char DEVID1[] = "v7855F2ED5D6D177"; //DAN#Scenario : "Alarm state - FULL ALARM CONDITION"
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
// 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 ethernetStart(){ delay(100); if(DEBUG){ Serial.println("Starting ethernet setup"); }
// start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } else{ Serial.println("Ethernet ready"); // print the Ethernet board/shield's IP address: Serial.print("My IP address: "); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000); if(DEBUG){ Serial.println("Finished ethernet setup"); } //serial debugging }
void setup() { Serial.begin(9600); pinMode(pinDevid1, INPUT); pinMode(ethernetPWR, OUTPUT);
digitalWrite(pinDevid1, HIGH); digitalWrite(ethernetPWR, LOW);
}
void loop() {
//// // Listening for the pinDevid1 state //// if (digitalRead(pinDevid1) == LOW && pinDevid1State == false) // switch on pinDevid1 is ON { if(DEBUG){ Serial.println("pinDevid1 is LOW"); }
digitalWrite(ethernetPWR, HIGH); delay(2000);
ethernetStart(); //Run ethernet setup routine pinDevid1State = true; //Sending request to PushingBox when the pin is HIGHT sendToPushingBox(DEVID1); } if (digitalRead(pinDevid1) == HIGH && pinDevid1State == true) // switch on pinDevid1 is OFF { if(DEBUG){ Serial.println("pinDevid1 is HIGH"); }
//digitalWrite(ethernetPWR, LOW); delay(100);
pinDevid1State = false; //Sending request to PushingBox when the pin is LOW //sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable }
//DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK"
if (client.available()) { char c = client.read(); if(DEBUG){ Serial.print(c); } }
// if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){ Serial.println(); } if(DEBUG){ Serial.println("disconnecting."); } client.stop(); digitalWrite(ethernetPWR, LOW); if(DEBUG){ Serial.println("PWR DOWN"); } } lastConnected = client.connected();
}
//Function for sending the request to PushingBox void sendToPushingBox(char devid[]){
client.stop(); if(DEBUG){ Serial.println("connecting..."); }
if (client.connect(serverName, 80)) { if(DEBUG){ Serial.println("connected"); }
if(DEBUG){ Serial.println("sending request"); } client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Arduino"); client.println(); } else { if(DEBUG){ Serial.println("connection failed"); } } }
|
|
|
|
« Last Edit: January 08, 2013, 11:15:16 pm by dtokez »
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #9 on: January 09, 2013, 07:03:30 am » |
can any experts help me out here? I'm getting very frustrated with it now, I'd really like to not have to have the Ethernet shield running 24/7 
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 50
Posts: 3451
|
 |
« Reply #10 on: January 09, 2013, 08:13:02 am » |
Obviously not supplying 240mA direct from a pin lol
How are you controlling the power? Unlike the w5100, the wiznet w5200 ethernet IC has power-down mode, but is not available from Arduino. Maybe someday Arduino will incorporate that model into their inventory. It also has: a faster SPI bus speed (20MHz rather than 4MHz) 8 sockets rather than 4 twice the internal memory. EKitsZone made a w5200 ethernet shield for a while, but I do not see that on their webpage now. ??
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #11 on: January 09, 2013, 10:02:54 am » |
Hi Surfer Tim. I used a transistor, but thinking that the volt drop over it was causing the Ethernet controller to not function properly I then tried a relay to ensure a clean 5v supply. But I'n not using anything now because as I'm fault finding, I'm manually connecting 5V to the shield either before the Arduino has booted or afterwards. Really annoying me now, I just can't understand what happens differently from the arduino powering up at the same time as the shield vs shield powering up after the arduino. It must be a bug in the Ethernet setup section in my code I'm sure  Any ideas?
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 50
Posts: 3451
|
 |
« Reply #12 on: January 09, 2013, 10:16:46 am » |
I haven't tested any of this yet. I was hoping the w5200 would be adopted by the Arduno crew, but that has not happened yet. According to the ethernet shield schematic, the +5v comes over two pins. The 5v pin on the Arduino power connector, and the ICSP 5v pin. Have you taken that into consideration? http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-06-schematic.pdfIt could also be you are not allowing enough time for the shield to connect properly with the router and get its mac/ip into the ARP table. It could take a couple seconds on my system before it can access outside (wan) stuff. edit: How are you powering the Arduino/shield? USB or power jack?
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 482
|
 |
« Reply #13 on: January 09, 2013, 10:52:25 am » |
The w5200 does sound a much nicer chip from what you are saying!
I have lifted the input leg of the 3.3v regulator and I am supplying 5v directly to that. Strangly the Ethernet shield was still powered, and it appeared to come from the 3.3v supply on the Uno so I bent the pin header out of the way to isolate it from the Ethernet shield.
I currently have a 2 second delay after I use a digital Pin to power up the Ethernet shield but have tried 5 seconds+ and that doesn't work so I don't think it is that kind of issue because when the Uno and Ethernet shield are powered up simultaneously, there is no delay in the setup of the w5100. That is why I don't understand what is missing from the set-up if I power up the shield later than the Uno.
At the moment the Uno is supplying the power via the USB jack.
Thanks
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 50
Posts: 3451
|
 |
« Reply #14 on: January 09, 2013, 11:12:52 am » |
I tried my ethernet shield with both the 5v and 3.3v power pins bent so they do not connect to the Arduino. It still works, powered by the ICSP pins. I was going to try bending that pin, but it is shorter, and resists being bent. I don't want to damage my Mega testing this.
|
|
|
|
|
Logged
|
|
|
|
|
|