Offline
Newbie
Karma: 0
Posts: 2
|
 |
« on: January 23, 2013, 07:51:11 am » |
I'm a beginner and I'm trying to train myself following step-by-step "Arduino Project Book" teachings.
I implemented project 03 (love-o-meter) but the value measured by the sensor varies between 144 and 146, that means 0 volts and a temperature of -50.00 degrees. I tried to "heat" the sensor for some minutes with my fingers (preheated) without any results.
The circuit is (or seems to be) the one explained on the book, and the same is for the code.
Is it possible there is some problem with the sensor?
Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 90
Posts: 9407
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #1 on: January 23, 2013, 01:59:00 pm » |
best to check all connections, and if you connected the sensor not "in reverse"
|
|
|
|
|
Logged
|
|
|
|
|
Portugal
Offline
Newbie
Karma: 0
Posts: 2
Human Knowledge belongs to the World
|
 |
« Reply #2 on: January 23, 2013, 05:40:49 pm » |
Hi !
Like Kukulo, i had the same problem. When doing that project, i didn't get any output in the serial monitor nor getting the sensor the report anything.. I've checked and re-checked the connections... nothing...
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #3 on: January 25, 2013, 04:13:44 pm » |
Hi to everyone, i had a this problem too: i received an output on serial but the degrees was always negative (i tested it in a room, about 19/20°C) so i tried to check the code and the wiring and it was all right. So i used a multimeter to calculate the central pin output (black wire on GND red in central pin) and i had 0.0 V in output. Au contraire with the red wire on the positive pin of the sensor and the black on central I saw 4,36 V. So i thought that the project is probably wrong in facts if you put a very "big" resistance (800 Kohms) between the positive pin and the central one it does work. Maybe i'm wrong but try to fix this in your future starter kit version.
|
|
|
|
|
Logged
|
|
|
|
|
Wahiawa, Hawaii
Offline
Sr. Member
Karma: 11
Posts: 365
|
 |
« Reply #4 on: January 26, 2013, 04:38:26 am » |
I implemented project 03 (love-o-meter) but the value measured by the sensor varies between 144 and 146, that means 0 volts and a temperature of -50.00 degrees.
The formula for the voltage should be; Voltage = (sensor / 1024) X 5.0 So if you had a sensor value of 145 then it should be (145/1024) X 5 = 0.71 volts, not 0 volts. Temperature = (voltage - 0.5) X 100 So if you had a sensor value of 145 and 0.71 volts, then temperature will calculate to (0.71 - 0.5) X 100 = 21 degrees C. Looks like your TMP 36 is working correctly.
|
|
|
|
|
Logged
|
|
|
|
|
Wahiawa, Hawaii
Offline
Sr. Member
Karma: 11
Posts: 365
|
 |
« Reply #5 on: January 26, 2013, 04:56:05 am » |
So i used a multimeter to calculate the central pin output (black wire on GND red in central pin) and i had 0.0 V in output. Au contraire with the red wire on the positive pin of the sensor and the black on central I saw 4,36 V.
If you had 4.36V between the left pin and center pin then that means you should have read 0.64V (assuming you are using 5V power) between the center pin and GND. It looks like you didn't make a good connection with your meter if you read 0V. Using the formulas the temperature is (0.64 - 0.5) X 100 = 14 degrees C. This is colder than you said but that depends on how accurate your voltage readings were. It looks like your TMP 36 is working also.
|
|
|
|
|
Logged
|
|
|
|
|
Denmark
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #6 on: January 29, 2013, 01:46:17 pm » |
I have a problem with the sensor values jumping from 0 to ~85 every approximately 1 sec
The board is set up exactly as the book describes, left pin to 5V, mid pin to A0, right pin to GND.
example print:
Sensor Value: 0, Volts: 0.00, Degrees: 20.00 Sensor Value: 0, Volts: 0.00, Degrees: 20.00 Sensor Value: 0, Volts: 0.00, Degrees: 20.00 Sensor Value: 6, Volts: 0.03, Degrees: 17.07 Sensor Value: 36, Volts: 0.18, Degrees: 2.42 Sensor Value: 65, Volts: 0.32, Degrees: -11.74 Sensor Value: 79, Volts: 0.39, Degrees: -18.57 Sensor Value: 78, Volts: 0.38, Degrees: -18.09 Sensor Value: 59, Volts: 0.29, Degrees: -8.81 Sensor Value: 28, Volts: 0.14, Degrees: 6.33 Sensor Value: 4, Volts: 0.02, Degrees: 18.05 Sensor Value: 0, Volts: 0.00, Degrees: 20.00 Sensor Value: 0, Volts: 0.00, Degrees: 20.00 Sensor Value: 0, Volts: 0.00, Degrees: 20.00
Any idea what i'm doing wrong?
|
|
|
|
|
Logged
|
|
|
|
|
Wahiawa, Hawaii
Offline
Sr. Member
Karma: 11
Posts: 365
|
 |
« Reply #7 on: January 29, 2013, 01:58:25 pm » |
Any idea what i'm doing wrong?
Please post your code.
|
|
|
|
|
Logged
|
|
|
|
|
Denmark
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #8 on: January 30, 2013, 04:02:24 am » |
Any idea what i'm doing wrong?
Please post your code. Should be the same as in the manual. const int sensorPin = A0; const float baselineTemp = 20.0;
void setup(){ Serial.begin(9600); for(int pinNumber = 2; pinNumber < 5; pinNumber++){ pinMode(pinNumber, OUTPUT); digitalWrite(pinNumber, LOW); } }
void loop(){ int sensorVal = analogRead(sensorPin); Serial.print("Sensor Value: "); Serial.print(sensorVal); float voltage = (sensorVal/1024.0)*5.0; Serial.print(", Volts: "); Serial.print(voltage); Serial.print(", Degrees: "); float temperature = (voltage - .5)*100; Serial.println(temperature); if(temperature < baselineTemp){ digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){ digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, LOW); } else if(temperature >= baselineTemp +6){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); } delay(100); }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #9 on: January 30, 2013, 05:55:27 am » |
I implemented project 03 (love-o-meter) but the value measured by the sensor varies between 144 and 146, that means 0 volts and a temperature of -50.00 degrees.
The formula for the voltage should be; Voltage = (sensor / 1024) X 5.0 So if you had a sensor value of 145 then it should be (145/1024) X 5 = 0.71 volts, not 0 volts. Thank you, hiduino! Do you know what? I calculated Voltage by multiplying to 0.5 instead of 5.0  Adjusting the multiplication factor, it works fine. Just a short note: if I write "Voltage = (sensor /1024) * 5.0", Voltage is calculated as 0.00; instead, if I write "Voltage = (sensor /1024 .0) * 5.0", the result is correct (not zero). Do I need to write any number using at least a decimal place after point? But this is not really a problem for me: probably, a better knowledge of this specific coding language could help me in avoiding this kind of mistakes.
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 90
Posts: 9407
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #10 on: January 30, 2013, 02:34:06 pm » |
There are rules how the compiler handles math operators. If both are int the result will be int. That is why sensor/1024 = 0; and sensor/1024.0 = >0;
Furthermore from performance point of view it is always faster to multiply than to divide e.g.
x/10.0 is slower than x * 0.1;
|
|
|
|
|
Logged
|
|
|
|
|
Denmark
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #11 on: January 30, 2013, 03:19:39 pm » |
Any idea what i'm doing wrong?
Please post your code. Should be the same as in the manual. const int sensorPin = A0; const float baselineTemp = 20.0;
void setup(){ Serial.begin(9600); for(int pinNumber = 2; pinNumber < 5; pinNumber++){ pinMode(pinNumber, OUTPUT); digitalWrite(pinNumber, LOW); } }
void loop(){ int sensorVal = analogRead(sensorPin); Serial.print("Sensor Value: "); Serial.print(sensorVal); float voltage = (sensorVal/1024.0)*5.0; Serial.print(", Volts: "); Serial.print(voltage); Serial.print(", Degrees: "); float temperature = (voltage - .5)*100; Serial.println(temperature); if(temperature < baselineTemp){ digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){ digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, LOW); } else if(temperature >= baselineTemp +6){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); } delay(100); } I just realised i had made some changes, so the numbers are different (but still not correct). This is the true outprint example with the above code: Sensor Value: 52, Volts: 0.25, Degrees: -24.61 Sensor Value: 53, Volts: 0.26, Degrees: -24.12 Sensor Value: 56, Volts: 0.27, Degrees: -22.66 Sensor Value: 61, Volts: 0.30, Degrees: -20.21 Sensor Value: 69, Volts: 0.34, Degrees: -16.31 Sensor Value: 74, Volts: 0.36, Degrees: -13.87 Sensor Value: 75, Volts: 0.37, Degrees: -13.38 Sensor Value: 73, Volts: 0.36, Degrees: -14.36 Sensor Value: 68, Volts: 0.33, Degrees: -16.80 Sensor Value: 58, Volts: 0.28, Degrees: -21.68 Sensor Value: 56, Volts: 0.27, Degrees: -22.66 Sensor Value: 53, Volts: 0.26, Degrees: -24.12 Sensor Value: 52, Volts: 0.25, Degrees: -24.61
|
|
|
|
|
Logged
|
|
|
|
|
Wahiawa, Hawaii
Offline
Sr. Member
Karma: 11
Posts: 365
|
 |
« Reply #12 on: January 30, 2013, 04:17:20 pm » |
I just realised i had made some changes, so the numbers are different (but still not correct). This is the true outprint example with the above code:
Sensor Value: 52, Volts: 0.25, Degrees: -24.61 Sensor Value: 53, Volts: 0.26, Degrees: -24.12 Sensor Value: 56, Volts: 0.27, Degrees: -22.66 Sensor Value: 61, Volts: 0.30, Degrees: -20.21 Sensor Value: 69, Volts: 0.34, Degrees: -16.31 Sensor Value: 74, Volts: 0.36, Degrees: -13.87 Sensor Value: 75, Volts: 0.37, Degrees: -13.38 Sensor Value: 73, Volts: 0.36, Degrees: -14.36 Sensor Value: 68, Volts: 0.33, Degrees: -16.80 Sensor Value: 58, Volts: 0.28, Degrees: -21.68 Sensor Value: 56, Volts: 0.27, Degrees: -22.66 Sensor Value: 53, Volts: 0.26, Degrees: -24.12 Sensor Value: 52, Volts: 0.25, Degrees: -24.61
Looks like your sensor acts more like a TMP 35 range. If you remove the - .5 from the formula (temperature = voltage * 100) do the readings make sense? Are the sensor values changing that fast? It could be bad connections causing sporadic readings. Otherwise I guess it could be just a bad sensor.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #13 on: January 31, 2013, 12:00:34 pm » |
My sensor doesn't seem to work either. I get these values: Sensor value: 26, Volts: 0.13, degrees C: -37.30 Sensor value: 25, Volts: 0.12, degrees C: -37.79 I have the same code as in the manual, and connected everything like the manual too. If i use 3.3V instead of 5V i get: Sensor value: 34, Volts: 0.17, degrees C: -33.40 Sensor value: 34, Volts: 0.17, degrees C: -33.40
|
|
|
|
|
Logged
|
|
|
|
|
Denmark
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #14 on: January 31, 2013, 12:07:05 pm » |
I just realised i had made some changes, so the numbers are different (but still not correct). This is the true outprint example with the above code:
Sensor Value: 52, Volts: 0.25, Degrees: -24.61 Sensor Value: 53, Volts: 0.26, Degrees: -24.12 Sensor Value: 56, Volts: 0.27, Degrees: -22.66 Sensor Value: 61, Volts: 0.30, Degrees: -20.21 Sensor Value: 69, Volts: 0.34, Degrees: -16.31 Sensor Value: 74, Volts: 0.36, Degrees: -13.87 Sensor Value: 75, Volts: 0.37, Degrees: -13.38 Sensor Value: 73, Volts: 0.36, Degrees: -14.36 Sensor Value: 68, Volts: 0.33, Degrees: -16.80 Sensor Value: 58, Volts: 0.28, Degrees: -21.68 Sensor Value: 56, Volts: 0.27, Degrees: -22.66 Sensor Value: 53, Volts: 0.26, Degrees: -24.12 Sensor Value: 52, Volts: 0.25, Degrees: -24.61
Looks like your sensor acts more like a TMP 35 range. If you remove the - .5 from the formula (temperature = voltage * 100) do the readings make sense? Are the sensor values changing that fast? It could be bad connections causing sporadic readings. Otherwise I guess it could be just a bad sensor. Above print is with 100ms delay. Also, the sensor does not react on temperature changes at all. I've tried with different sensors of the same type, the result is the same (print below is without the -.5): Sensor Value: 55, Volts: 0.27, Degrees: 26.86 Sensor Value: 55, Volts: 0.27, Degrees: 26.86 Sensor Value: 56, Volts: 0.27, Degrees: 27.34 Sensor Value: 57, Volts: 0.28, Degrees: 27.83 Sensor Value: 60, Volts: 0.29, Degrees: 29.30 Sensor Value: 67, Volts: 0.33, Degrees: 32.71 Sensor Value: 72, Volts: 0.35, Degrees: 35.16 Sensor Value: 75, Volts: 0.37, Degrees: 36.62 Sensor Value: 75, Volts: 0.37, Degrees: 36.62 Sensor Value: 70, Volts: 0.34, Degrees: 34.18 Sensor Value: 64, Volts: 0.31, Degrees: 31.25 Sensor Value: 59, Volts: 0.29, Degrees: 28.81 Sensor Value: 57, Volts: 0.28, Degrees: 27.83 Sensor Value: 56, Volts: 0.27, Degrees: 27.34 Sensor Value: 55, Volts: 0.27, Degrees: 26.86 Sensor Value: 55, Volts: 0.27, Degrees: 26.86 EDIT: Something is very wrong, if i change the sensors position on the breadboard i get different values..
|
|
|
|
« Last Edit: January 31, 2013, 02:07:13 pm by Garmien »
|
Logged
|
|
|
|
|
|