Go Down

Topic: Issue Project 3 (-36°) (Read 1 time) previous topic - next topic

Reddox_

Hello guy's, yesterday I did the project 3 of the Arduino Uno book ("Love O meter"), and I had an issue:
My "setup" seems good and my code is perfect (even if the "Serial.prinIn" is replaced by "Serail.print" because it occasionate an error). The problem is that, has you'll see, when I look in my monitor series, he detect's -36° C (How is not normal I guess ^^), and because of that, the LED's don't turn on. If you need more details, look at the sreenshots or ask me.

PS: Sorry for my horrible grammar, I'm French  :smiley-sad-blue:

Code: [Select]

const int sensorPin = A0;
 const float baselineTemp = 20.0;
 void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
for(int pinNumber = 2; pinNumber<5; pinNumber++){
  pinMode(pinNumber,OUTPUT);
  digitalWrite(pinNumber, LOW);
}
}

void loop() {
  // put your main code here, to run repeatedly:
int sensorVal = analogRead(sensorPin);
Serial.print("Valeur capteur :");
Serial.print(sensorVal);
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", Volts : ");
Serial.print(voltage);
Serial.print(", Degres C : ");
float temperature = (voltage - .5) * 100;
Serial.print(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(600);
}




 -29.00Valeur capteur :35, Volts : 0.17, Degres C : -32.91Valeur capteur :32, Volts : 0.16, Degres C : -34.38Valeur capteur :34, Volts : 0.17, Degres C : -33.40Valeur capteur :37, Volts : 0.18, Degres C : -31.93Valeur capteur :50, Volts : 0.24, Degres C : -25.59Valeur capteur :57, Volts : 0.28, Degres C : -22.17Valeur capteur :64, Volts : 0.31, Degres C : -18.75Valeur capteur :72, Volts : 0.35, Degres C : -14.84Valeur capteur :73, Volts : 0.36, Degres C : -14.36Valeur capteur :71, Volts : 0.35, Degres C : -15.33Valeur capteur :68, Volts : 0.33, Degres C : -16.80Valeur capteur :58, Volts : 0.28, Degres C : -21.68Valeur capteur :49, Volts : 0.24,

Fensu

#1
Jan 25, 2017, 04:46 am Last Edit: Jan 25, 2017, 04:55 am by Fensu
Sorry I'm pretty new to electronics as well so I probably won't be much help, but I'll do my best. To start off with, do you have a thermometer to tell what your actual room temperature is?

According to the datasheet for the tmp36 sensor, at 25C the middle wire should be outputting a voltage of 0.75 volts. Assuming you're input is 5v(you're plugged into usb on computer right?), then the sensorVal SHOULD be (1023/5v)*0.75v =  153.45

You're only getting a sensorVal of about 35. What that means, is either your input voltage is much higher than 5v (somewhere around 22v), your tmpsensor is outputting much too low of voltage (somewhere around 0.17v at 25C), or both of those are correct and your Analog to digital converter on A0 Pin is faulty and converting 0.75 volts to 35 value incorrectly.

So my guess is either you're input voltage is too high, your tmpsensor is faulty, or your analog input pin is faulty.

Maybe try using analog input 1 instead of 0 to rule out the analog input (don't forget to change the sensorPin in your code)? If you have a multimeter, can you check the voltage on the middle wire of the tmpsensor?


curlyc

i think its a hardware issue but to rule that out upload the sketch they made for it

file/examples/StarterKit_BasicKit/p03_loveometer and run that

RRivoallan

Hi Reddox,

That sounds stupid, but are you sure to use the correct TMP36 component on your breadboard?

The arduino kit provides transistors that look like very similar (damned!)

Renaud

Reddox_

Thank you guys for your answers,  I'll try to give you more informations so we can solve the problem. First of all,  I don't live in North pole so my room is about 19°.I give you a photo of the bread board but it seems to be good.  I use the 5V output of the arduino card who is connected to my computer,  so it shouldn't be a problem of Voltage.  When I upload the exemple to my card, it unfortunately doesn't change anything
When I change from A0 to A1, it also not resolve the issue.
Hope well find a solution,  Reddox_
https://twitter.com/PabloThiebaut/status/825282661811904512

oqibidipo

You have the BC547 in your circuit instead of the TMP36. I tried it and got similar results.
The identification is marked on the flat side, but may be hard to read.
They may be easier to tell apart by the leads, in my kit TMP36 has straight leads and BC547 has bent outer leads.

Warning:
If you put the TMP36 backwards on the breadboard and get results in the 250 °C range, those values are real! Don't touch the sensor, I already did that for you. (OUCH!)

Reddox_

OMFG You where right!  How can you see the difference!  The tmp 36 wasn't in the right place, he was lost we the wires.  Sorry for the times you wasted,  I am juste the biggest idiot on earth

Reddox_

Funny fact,  I just burned myself by replacing the Tmp 36...  GENIUS

Go Up