Heres what I have on a remote sensor arrangement.
It produces the following web page:
This is the code that produces it , it has electricty consumption (all the stuff with 'blinks'), Dallas digital thermometer and analogue light level reading. It should give you some clues and you'll probably spot the code I lifted from the web server example......
/*
* Web Server
*
* A simple web server that shows the value of the analog input pins.
*/
#include <Ethernet.h>
#include <OneWire.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 201 };
int ledPin = 0; // Pin 13 guzzled by ethernet
int dallasPin = 1;
int litePin = 0;
unsigned long time = 0;
unsigned long time1;
unsigned long mins = 60000;
unsigned long blinktime = 0;
unsigned long totalblinks = 0; // blinks since start
unsigned long blinksmin = 0; // blinks this minute
unsigned long blinkshour = 0; // blinks this Hour
unsigned long lastblink = 0;
unsigned long prevblink = 0;
unsigned long secs = 0;
unsigned long hrs = 3600000;
unsigned long elaphrs = 0;
unsigned long elapmin = 0;
byte dallasadd1[8];
byte data[8];
int i;
int dallas1;
float light;
int lite;
boolean lighton = false;
float watts1 = 0; // on elapsed time since last blink
float rollavwatts = 100;
float blinktimefloat = 0;
float temp1 = 0;
float temp = 0;
Server server(80);
OneWire ds(dallasPin);
void setup()
{
Ethernet.begin(mac, ip);
server.begin();
pinMode(ledPin, OUTPUT);
attachInterrupt(0, blink, RISING);
ds.reset();
ds.reset_search();
ds.search(dallasadd1);
ds.select(dallasadd1);
ds.write(0x44,1);
}
void loop()
{
time = millis();
elaphrs = int(time / 3600000);
elapmin = elaphrs * 3600000;
elapmin = time - elapmin;
elapmin = elapmin / 60000;
if (time >= secs){ // 1 second loop
secs = time + 1000;
blinktime = max(lastblink - prevblink,time - lastblink);
blinktimefloat = float(blinktime) / 5;
watts1 = 3600000 / blinktimefloat;
ds.reset();
ds.select(dallasadd1);
ds.write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) { data[i] = ds.read(); };
dallas1 = (data[1] << 8) + data[0];
temp = float(dallas1);
temp1 = temp/16;
ds.reset();
ds.select(dallasadd1);
ds.write(0x44,1);
lite = analogRead(0);
light = float(light * 0.8 + lite * 0.2);
};
if (time >= time1){ // 0.2 second loop
time1 = time + 200;
if (lighton){ digitalWrite(ledPin, HIGH); lighton = false; }
else { digitalWrite(ledPin, LOW);};
};
if (time >= mins){ // 1 minute loop
mins = time + 60000;
blinksmin = 0;
rollavwatts = rollavwatts * 0.98 + watts1 * 0.02;
};
if (time >= hrs){ // 1 Hour loop
hrs = time + 3600000;
blinkshour = 0;
};
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("Welcome to the Majestic Monitor");
client.println("
");
client.print("Milliseconds since start : ");
client.print(time);
client.println("
");
client.print("Hours , Minutes since Start : ");
client.print(elaphrs);
client.print(" ");
client.print(elapmin);
client.println("
");
client.print("Blinks Total , Last Min , Last Hour : ");
client.print(totalblinks);
client.print(" ");
client.print(blinksmin);
client.print(" ");
client.print(blinkshour);
client.println("
");
client.print("Last Blink , Prev Blink, Last - Prev: ");
client.print(lastblink);
client.print(" ");
client.print(prevblink);
client.print(" ");
client.print(lastblink-prevblink);
client.println("
");
client.print("Watts , Rolling Average Watts: ");
client.print(watts1);
client.print(" ");
client.print(rollavwatts);
client.println("
");
client.print("Light Level: ");
client.print(int(light));
client.println("
");
client.print("Digital Thermometer : ");
client.print(temp1);
client.print(" Deg C ");
client.print(dallas1);
client.print(" ");
for( i = 0; i < 8; i++) {
client.print(dallasadd1[i], HEX); client.print(" "); }
;
client.println("
");
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}
void blink()
{
if (lastblink - time > 500){
lighton = true;
prevblink = lastblink;
lastblink = time;
totalblinks ++;
blinksmin ++;
blinkshour ++;
}
}