Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« on: February 28, 2012, 02:45:17 am » |
Hello, I am using LM335 Temperature sensor. Here is my code: float celsius = 0, kelvin=0;
void setup() { Serial.begin(9600); }
void loop() { kelvin = analogRead(0) * 0.004882812 * 100; celsius = kelvin - 273.15; Serial.print("Celsius: "); Serial.println(celsius); Serial.print("Kelvin: "); Serial.println(kelvin); Serial.println(); delay(1000); } Output: Celsius: 41.30 Kelvin: 314.45
Celsius: 41.30 Kelvin: 314.45
Celsius: 41.30 Kelvin: 314.45
Celsius: 41.30 Kelvin: 314.45
41.30 degrees C is unusual. I am testing inside my room where the temperature is 19 degrees C. Please help me correct readings. Thanks. Z
|
|
|
|
« Last Edit: February 28, 2012, 02:59:26 am by zeus2kx »
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 23
Posts: 1381
Now, More Than Ever
|
 |
« Reply #1 on: February 28, 2012, 08:13:13 am » |
Insert a Serial.print statement to knock out the analogRead(0) result.
|
|
|
|
|
Logged
|
Don't Be Upset By The Results You Didn't Get With The Work You Didn't Do
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #2 on: February 28, 2012, 10:46:00 am » |
Insert a Serial.print statement to knock out the analogRead(0) result.
Thanks for reply. I added, here is the output. Celsius: 41.30 Kelvin: 314.45 Analog Read: 644
Celsius: 41.79 Kelvin: 314.94 Analog Read: 644
Celsius: 41.79 Kelvin: 314.94 Analog Read: 645
What can I do to solve this issue? Thanks. Z
|
|
|
|
|
Logged
|
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 24
Posts: 2354
|
 |
« Reply #3 on: February 28, 2012, 10:57:21 am » |
How do you have it wired up?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 23
Posts: 1381
Now, More Than Ever
|
 |
« Reply #4 on: February 28, 2012, 11:02:32 am » |
Well, your analogRead result means there's about 3.1V (645 * 4.888mV = 3152mV == 310K - 273 = 42C). Are the wires to the sensor short? They should be as short as possible. Try a bypass cap at the sensor, 0.1uF from +V to Gnd, too.
5V / 1023 = 4.888mV (per count)
|
|
|
|
|
Logged
|
Don't Be Upset By The Results You Didn't Get With The Work You Didn't Do
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #5 on: February 28, 2012, 11:08:55 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #6 on: February 28, 2012, 11:15:18 am » |
Are the wires to the sensor short? They should be as short as possible. Try a bypass cap at the sensor, 0.1uF from +V to Gnd, too.
5V / 1023 = 4.888mV (per count)
Thanks. No, wire length is almost like a foot.
|
|
|
|
|
Logged
|
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #7 on: February 28, 2012, 11:25:17 am » |
Kindly confirm the circuit so that I fix sensor on board itself.
Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #8 on: February 28, 2012, 12:01:31 pm » |
I tried connecting 0.1uF between +V and Gnd but no significant changes. 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 23
Posts: 1381
Now, More Than Ever
|
 |
« Reply #9 on: February 28, 2012, 01:02:53 pm » |
You may be coupling noise into the analogRead with those 1 foot wires. Better try as short as possible. Your application likely requires remote placement, but try and find out if this helps first. Your circuit looks like what I've seen recommended.
|
|
|
|
|
Logged
|
Don't Be Upset By The Results You Didn't Get With The Work You Didn't Do
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #10 on: February 28, 2012, 01:09:51 pm » |
I soldered on the board but yet no change in readings.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 23
Posts: 1381
Now, More Than Ever
|
 |
« Reply #11 on: February 28, 2012, 01:17:23 pm » |
Have you put a voltmeter to the LM335 output (right there on the board)? If it's "3V" then maybe it's defective.
|
|
|
|
|
Logged
|
Don't Be Upset By The Results You Didn't Get With The Work You Didn't Do
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #12 on: February 28, 2012, 01:55:47 pm » |
Nope, I am home, don't have one now but can check tomorrow.
|
|
|
|
|
Logged
|
|
|
|
|
Israel
Offline
Jr. Member
Karma: 0
Posts: 84
|
 |
« Reply #13 on: February 29, 2012, 10:49:51 am » |
I found the problem that there wasn't any problem just that Arduino was only connected through USB, not with AC adopter.
Thanks all for your support.
Z
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 23
Posts: 1381
Now, More Than Ever
|
 |
« Reply #14 on: February 29, 2012, 01:23:38 pm » |
But,... I... Well, OK then.
|
|
|
|
|
Logged
|
Don't Be Upset By The Results You Didn't Get With The Work You Didn't Do
|
|
|
|
|