LM35DZ and Ethernet Shield

My First Post

I just got my first UNO yesterday. I tried to make the LM35DZ and Ethernet Shield work together as a data logger.
the hardware connection is simple, stack the shield on top of UNO, hook the LM35DZ to ethernet shield. and use A0 to read the input

but the number that I got does not make sense. the analog reading is ~800, after convert it to the temperature with the equation, the temp is about 309 C degree. that’s the room temperature.

temp = (5v / 1024_interval * Analog_Reading /100mv_per_degree)
= AnalogReading *0.488281

I read so many web pages but none resolves the problem.

Finally, I realized that the problem may be caused by Ethernet Shield.
I checked the output pin for Ethernet Shield, mine is version 5.
http://shieldlist.org/arduino/ethernet-v5

I found that Ethernet Shield use port A0 .

Although not used by most SD card libraries, A0 is connected to the SD slot’s write protect (WP) pin and A1 is connected to the card detect switch.

After I use port A4 to read the LM35, I got the right temperature, 22.4C. ;D

Code is below

/*
Web Server

A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.

Circuit:

  • Ethernet shield attached to pins 10, 11, 12, 13
  • Analog inputs attached to pins A0 through A5 (optional)

created 18 Dec 2009
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe

*/

#include <SPI.h>
#include <Ethernet.h>

float tempC = 0.0;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip = { 192,168,1, 177 };

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
Server server(80);

void setup()
{
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
}

void loop()
{

// listen for incoming clients
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you’ve gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == ‘\n’ && currentLineIsBlank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println();

//I modified the code here to let it print the temperature
client.print("the temperature is ");

tempC = (5.0*100.0 *analogRead(4))/1024.0; //convert the analog data to temperature

client.println("
");

break;
}
if (c == ‘\n’) {
// you’re starting a new line
currentLineIsBlank = true;
}
else if (c != ‘\r’) {
// you’ve gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}

Mity Fine , crabtang !

Thanks for pointing this out, already got rid of ethernet shield in my current project, not enough pins for everything at once... now A0 and A1 as well.

The schematic http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-schematic.pdf 10k pull up on A0 and A1, thats why I noticed them reading 1023 the first day my Arduino arrived, ha!

You would think the LM35DZ would drive a 10k pull up without problem???

The "WP" solder bridge just grounds A1, thats no help. But look at the third bridge above the silkscreen "Gnd" it appears to disconnect A1 ?? Not shown on schematic.

see also http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286284349

Perhaps just disconnect A0 and A1 and have no Write Protect, and catch the code fail when no SD card is present? You might have to cut traces to do it... unles you have enough pins for everything.

I've already given up using ethernet shield right now and saving it for next project, so am not gonne cut any traces....YET....