Go Down

Topic: Ethernet Shield Interrupts??? (Read 1 time) previous topic - next topic

m0zjo

Hi i'm a newbie needing some advice

I have recently acquired a Ethernet shield, data shield and arduino UNO and am using it for a data-logging.

I would like the capability of a web server so my clients can view the arduino's status from afar...

To do this I would like the Ethernet shield to interrupt the arduino when a data request is received so the arduino can print the web page and then return back to the code to continue logging.

I haven't been able to work out the Ethernet shield interrupt arrangement and the W5100 data sheet hasn't been much help. I know that pin 2 is used but that as far as I got.
When does the shield interrupt? Does the pin go high or low?

I appreciate any help  :D
Tnx for your time  ;)

MarkT

You need to regularly call ES_enc28j60PacketReceive() - it returns 0 if no packet available I believe.  Look at the webserver examples.
[ I won't respond to messages, use the forum please ]

PaulS

Quote
To do this I would like the Ethernet shield to interrupt the arduino when a data request is received so the arduino can print the web page and then return back to the code to continue logging.

You should show the code that you think needs to be interrupted. Most likely, properly structuring of the code would not require interrupting anything.

Quote
I have recently acquired a Ethernet shield

Some details about which one would be useful.

m0zjo

Here is the code that I would like to integrate a Ethernet server into
It will just be a simple webpage displaying what the device is



Quote

void loop(void)    // Start Looping Here
{
  DateTime now;

  // delay for the amount of time we want between readings
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
 
  digitalWrite(greenLEDpin, HIGH);
 
  // log milliseconds since starting
  uint32_t m = millis();
  logfile.print(m);           // milliseconds since start
  logfile.print(", ");   
#if ECHO_TO_SERIAL
  Serial.print(m);         // milliseconds since start
  Serial.print(", "); 
#endif

  // fetch the time
  now = RTC.now();
  // log time
  logfile.print(now.unixtime()); // seconds since 1/1/1970
  logfile.print(", ");
  //logfile.print('"'); AR during file test
  logfile.print(now.day(), DEC);
  logfile.print("/");
  logfile.print(now.month(), DEC);
  logfile.print("/");
  logfile.print(now.year(), DEC);
  logfile.print(' ');   
  logfile.print(now.hour(), DEC);
  logfile.print(":");
  logfile.print(now.minute(), DEC);
  logfile.print(":");
  logfile.print(now.second(), DEC);
  //logfile.print(',');
 
  //logfile.print('"');AR during file test

#if ECHO_TO_SERIAL
  Serial.print(now.unixtime()); // seconds since 1/1/1970
  Serial.print(", ");
  //Serial.print('"');ar comment
  Serial.print(now.day(), DEC);
  Serial.print("/");
  Serial.print(now.month(), DEC);
  Serial.print("/");
  Serial.print(now.year(), DEC);
  Serial.print(" ");
  Serial.print(now.hour(), DEC);
  Serial.print(":");
  Serial.print(now.minute(), DEC);
  Serial.print(":");
  Serial.print(now.second(), DEC);
  //Serial.print(",");
    //Serial.print('"'); AR comment
#endif //ECHO_TO_SERIAL
 
  analogRead(tempPin0);
  delay(10);
  int tempReading0 = analogRead(tempPin0);
 
 
  analogRead(tempPin1);
  delay(10);
  int tempReading1 = analogRead(tempPin1);

 
  // converting that reading to voltage, for 3.3v arduino use 3.3, for 5.0, use 5.0
  float voltage0 = tempReading0 * aref_voltage / 1024; 
  float temperatureC0 = (voltage0 - 0.5) * 100 ;
  float temperatureF0 = (temperatureC0 * 9 / 5) + 32;
 
 
  // converting that reading to voltage, for 3.3v arduino use 3.3, for 5.0, use 5.0
  float voltage1 = tempReading1 * aref_voltage / 1024; 
  float temperatureC1 = (voltage1 - 0.5) * 100 ;
  float temperatureF1 = (temperatureC1 * 9 / 5) + 32;
 
  logfile.print(", ");   
  logfile.print(temperatureC0);
  logfile.print(", ");   
  logfile.print(temperatureC1);
#if ECHO_TO_SERIAL
  Serial.print(", ");   
  Serial.print(temperatureC0);
  Serial.print(", ");   
  Serial.print(temperatureC1);
#endif //ECHO_TO_SERIAL

  // Log the estimated 'VCC' voltage by measuring the internal 1.1v ref
  analogRead(BANDGAPREF);
  delay(10);
  int refReading = analogRead(BANDGAPREF);
  float supplyvoltage = (bandgap_voltage * 1024) / refReading;
 
  logfile.print(", ");
  logfile.print(supplyvoltage);
#if ECHO_TO_SERIAL
  Serial.print(", ");   
  Serial.print(supplyvoltage);
#endif // ECHO_TO_SERIAL

  logfile.println();
#if ECHO_TO_SERIAL
  Serial.println();
#endif // ECHO_TO_SERIAL

  digitalWrite(greenLEDpin, LOW);

  // Now we write data to disk! Don't sync too often - requires 2048 bytes of I/O to SD card
  // which uses a bunch of power and takes time
  if ((millis() - syncTime) < SYNC_INTERVAL) return;
  syncTime = millis();
 
  // blink LED to show we are syncing data to the card & updating FAT!
  digitalWrite(redLEDpin, HIGH);
  logfile.flush();
  digitalWrite(redLEDpin, LOW);
 
}




I am using the http://www.oomlout.co.uk/ethernet-shield-for-arduino-p-188.html


Thanks for your replys

PaulS

Code: [Select]
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
No. No. No. Learn to use millis() to see if it is time to log the data.

Add a check for a client connection in loop(). If a connection is made, send the same data as part of a form, using client.print(), just like Serial.print().

Go Up