unstable analog inputs

Hey Guys

hope u are all having a good weekend

ive been trying to modify some code to build a soft of home automation system.
but im seeing some very unstable analog inputs
and i cant realy find why

im using the ethernet shield and the sensor shield and 2 lm35 sensors boards from dfrobot

when refreshing the page or enabling outputs the temperature vallues wil change slightly

#include <LED.h>
#include <WString.h>
#include <Ethernet.h>
#include <avr/pgmspace.h>
prog_char string_0[] PROGMEM = "";
prog_char string_1[] PROGMEM = "<tr><td><input type=submit name=b1 value=Led1></td><td>";
prog_char string_2[] PROGMEM = "<tr><td><input type=submit name=b2 value=Led2></td><td>";
prog_char string_3[] PROGMEM = "<tr><td><input type=submit name=b3 value=Led3></td><td>";
prog_char string_4[] PROGMEM = "<tr><td><input type=submit name=b4 value=Led4></td><td>";
prog_char string_5[] PROGMEM = "<tr><td><input type=submit name=b5 value=Led5></td><td>";
prog_char string_6[] PROGMEM = "<tr><td><input type=submit name=b6 value=Led6></td><td>";
prog_char string_7[] PROGMEM = "</form>";
prog_char string_8[] PROGMEM = "<img src=data:image/gif;base64,R0lGODlhEAAQAKIAAAD/AACGAISGhMbHxv///wAAAAAAAAAAACwAAAAAEAAQAAADUEiq1b6QNEHFGC2W6srFyyY0QAk0V8GM5WJ6qlgA7ptuc20GME4TplKAJ/EBg4BhDIYUKosp5JAokWB2U6LKiilkM1XGpxPSeAYQcKRIhiQAADs= alt=On ></td><td>";
prog_char string_9[] PROGMEM = "<img src=data:image/gif;base64,R0lGODlhEAAQAKIAAP////f398DAwICAgAAAAAAAAAAAAAAAACwAAAAAEAAQAAADTRiq1L4wtEGHEC2S6sjFyzY0H+aB0ngB7OcRqcoC5Tl5cymot9CWFAKgR9MFhy/dhYO8nD7MoQQDrYykU5O1wYIxXI6ZN3SaISPkTiQBADs= alt=Off ></td><td>";
prog_char string_10[] PROGMEM = "";
PROGMEM const char *string_table[] = // change "string_table" name to suit
{
string_0,
string_1,
string_2,
string_3,
string_4,
string_5,
string_6,
string_7,
string_8,
string_9,
string_10
};
char buffer[400]; // make sure this is large enough for the largest string it must hold
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 15 };
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };
String inString = String(35);
Server server(80);
LED led1 = LED(2);
LED led2 = LED(3);
LED led3 = LED(4);
LED led4 = LED(5);
LED led5 = LED(6);
LED led6 = LED(7);
LED led7 = LED(8);
LED led8 = LED(9);
String msg="";
int tam=0;
int st1=9,st2=9,st3=9,st4=9,st5=9,st6=9,st7=9,st8=9;
void setup()
{

Ethernet.begin(mac, ip,gateway,subnet);
server.begin();
}
void loop()
{
long tmp;
  
Client client = server.available();
int led=0;
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 (inString.length() < 35) {
inString.append(c);
}
if (c == '\n' && current_line_is_blank) {
if(inString.contains("b1")){
led1.toggle();
if(led1.getState()) st1=8;
else st1=9;
led=1;
}
if(inString.contains("b2")){
led2.toggle();
if(led2.getState()) st2=8;
else st2=9;
led=2;
}
if(inString.contains("b3")){
led3.toggle();
if(led3.getState()) st3=8;
else st3=9;
led=3;
}
if(inString.contains("b4")){
led4.toggle();
if(led4.getState()) st4=8;
else st4=9;
led=4;
}
if(inString.contains("b5")){
led5.toggle();
if(led5.getState()) st5=8;
else st5=9;
led=5;

}
if(inString.contains("b6")){
led6.toggle();
if(led6.getState()) st6=8;
else st6=9;
led=6;
}

if(inString.contains("msg")){
strcpy(msg,inString.substring(inString.indexOf("g")+2,inString.indexOf(" H")));
//Serial.print("msg: ");
//Serial.println(msg);
}
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
          //Scrivo l'intestazione
          client.println("<html>");
          //client.println("<META http-equiv=REFRESH content=3; url=/ >");
          client.println("<style> a:link{font:8pt/11pt verdana; color:red} a:visited {font:8pt/11pt verdana; color:blue} body {font:8pt/11pt verdana; color:black; background-color:white} </style>");
          client.println("<title>Home Automation </title>");
          client.println("</head>");
          client.println("<body>");
          client.println("<img src=http://members.quicknet.nl/m.vos2/logo.gif></td><td>");
          client.println("<font size= 4><form method=GET>");        
          
          
         
          
client.println("  ");
client.print("Temp 1 is ");
analogReference(DEFAULT);
delay(10);
tmp=((long)analogRead(0)*5000)/1024;
client.print(tmp / 10);
client.print(".");
client.print(tmp % 10 );
client.print(" C");

client.println("
");
client.println("  ");
client.print("Temp 2 is ");
analogReference(DEFAULT);
delay(10);
tmp=((long)analogRead(1)*5000)/1024;
client.print(tmp / 10);
client.print(".");
client.print(tmp % 10);
client.print(" C" );
client.println("<P> 
");
          
client.println("<table width=100>");          
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[0]))); // Necessary casts and dereferencing, just copy.
client.println( buffer );
for (int i = 1; i < 8; i++)
{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i]))); // Necessary casts and dereferencing, just copy.
client.println( buffer );
switch(i){
          client.println("B");
case 1: strcpy_P(buffer, (char*)pgm_read_word(&(string_table[st1]))); client.println( buffer ); break;
case 2: strcpy_P(buffer, (char*)pgm_read_word(&(string_table[st2]))); client.println( buffer ); break;
case 3: strcpy_P(buffer, (char*)pgm_read_word(&(string_table[st3]))); client.println( buffer ); break;
case 4: strcpy_P(buffer, (char*)pgm_read_word(&(string_table[st4]))); client.println( buffer ); break;
case 5: strcpy_P(buffer, (char*)pgm_read_word(&(string_table[st5]))); client.println( buffer ); break;
case 6: strcpy_P(buffer, (char*)pgm_read_word(&(string_table[st6]))); client.println( buffer ); break;
}
delay(30);
}

          client.println("</table>");
          client.println("<a href=/>Refresh</a>");
          client.println("</body>");
          client.println("</html>");        
          
          
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);
inString = "";
client.stop();
}
}

First thing I noticed is two calls to analogReference, with an argument of DEFAULT. Since this is the default setting, this function does not need to be called at all.

when refreshing the page or enabling outputs the temperature vallues wil change slightly

Slightly as in 1 degree, or slightly as in 10 degrees? The lm35 is rated at +/- 0.5 degrees C.

Does the LED library set the pinMode?

wel it varies between .5 and 2,5 degrees

The LM35s need a rock solid analogue reference voltage to give repeatable results, its more than possible the voltage swings a bit when accessing stuff via the ethernet shield because its quite a power hog. How are you powering the board/shield ?

wel currently its running on usb power. but the results are the same when powering the board from my lab psu