Go Down

Topic: Temp Sensor does not get reasonable result (Read 1 time) previous topic - next topic

fruit112358

Hi All,

I am totally new to arduino, even hardware, could someone help me out with below problem:

I have an arduino UNO and DFROBOT ethernet shield which connected with each other. Then, I connect a temperature sensor (lm 35 dz) to the ethernet shield, 5 v power supply. Additionally, I use a 9 volts AC power supply for the entire unit. I use following formula to calculate centigrade from pin output: signal*voltage*100/1023, voltage here is 4.98 volts measured manually.

However, result is near 40 degree while real temperature is only 24 degree. Also I measure the voltage between power supply and GND of this temp sensor, it is about 0.25 volts which multiple by 100 is close to real temperature.

I do not know what's wrong? Could anyone give me some idea or clues about it?

Regards,
Jie

robtillaart

Can you post your sketch (use the #button for appropiate tagging) and a drawing how you connected the LM35?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

fruit112358

#2
Jun 21, 2011, 06:04 pm Last Edit: Jun 22, 2011, 10:44 am by fruit112358 Reason: 1
my code as following:
Code: [Select]
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10,10,102,160 };
unsigned int localPort = 8012;

int sensorPin_Light = A0;
int sensorValue_Light = 0;

int sensorPin_Temp = A1;
int sensorValue_Temp = 0;
char sensorValue_Temp_Char[2] ;

byte remoteIP[] = { 10,10,102,133 };
int remotePort = 58121; // the destination port

void setup() {
 Ethernet.begin(mac,ip);
 Udp.begin(localPort);
 
 Serial.begin(9600);
}

void loop() {
 
 sensorValue_Light = analogRead(sensorPin_Light);
 sensorValue_Temp = analogRead(sensorPin_Temp);
 
 //udp packet can have max 160 bits for data.
 char udp_content[20] ;
 //four char is used for every integer's digital whose max value is 1024, and end with ','
 char sensorValue_Light_Char[5] ;
 itoa (sensorValue_Light, sensorValue_Light_Char, 10);
 
 char sensorValue_Temp_Char[5] ;
 itoa (sensorValue_Temp, sensorValue_Temp_Char, 10);


 strcpy (udp_content,sensorValue_Light_Char);
 strcat (udp_content,",");
 strcat (udp_content,sensorValue_Temp_Char);
 strcat (udp_content,",");

 Serial.println(udp_content);
 
 Udp.sendPacket(udp_content, remoteIP, remotePort );
 delay(2000);
}


how i connect the lm35:
5v for power, GND line connect with GND pin and analog in 1 for temperature.
PS. meanwhile, I also use a light intensity sensor with A0.


wildbill

This:
Code: [Select]
sensorValue_Light = analogRead(sensorPin_Light);
sensorValue_Temp = analogRead(sensorPin_Temp);


may be problematic. The analog pins share a single A2D converter. If you try to read from multiple pins in rapid succession, the later results tend to be inaccurate. Recent posts have suggested a couple of remedies: use a small delay between readings or take two readings for each input and ignore the first. In your case, just commenting out the analogRead for the light should show you if that is the issue.

robtillaart

Please modify your post, select the code and use the # button , thank you
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up