Difference between revisions of "Temperature Sensor."

From Hackteria Wiki
Jump to: navigation, search
Line 2: Line 2:
 
Reauben Samson has made an incubator and we need to check if it is working. We used a digital thermometer,<br>  
 
Reauben Samson has made an incubator and we need to check if it is working. We used a digital thermometer,<br>  
 
it gives us different readings after every 15 minutes and we concluded it does not work so now we are <br>
 
it gives us different readings after every 15 minutes and we concluded it does not work so now we are <br>
building a temperature sensor using the Arduino Uno board and LM35 temperature sensor.<br>
+
building a temperature sensor using the Arduino Uno board and LM35 temperature sensor. The main aim is to keep <br>
 +
a constant temperature using a light bulb as our heat source. We will be using a CPU fan to cool down the light bulb <br>
 +
and to keep the incubator at a certain threshold temperature. <br>
 +
 
 +
<br>
 +
Parts list:
 +
CPU fan
 +
LED
 +
Light bulb (230 VOLT, 75 WATTS) <br>
 +
LM 35 (temperature sensor) <br>
 +
Diode (2N3904 - E25) <br>
 +
Relay (JQC-3F 6 VOLT) <br>
 +
Wire <br>
 +
Arduino Uno <br>
 +
 
 +
<br><br>
 +
<B> Arduino Code LM 35 Temperature Sensor </B>
 +
float tempC;                            // create variable to store the temperature in.
 +
int tempPin = 0;                        // Attach vout to analog pin 0.
 +
int led = 13;                          // attach led to pin 13.
 +
int fan1 = 3;                          // attach base of transistor to digital pin 3.
 +
int pos = 0;                            // create variable to store the position of the servo motor.
 +
 
 +
void setup()                            // Will execute once at the start of the code.
 +
{
 +
  Serial.begin(9600);                  // opens serial port, sets data rate to 9600 bps
 +
  pinMode (led, OUTPUT);                // sets the led pin 13 up as an output.
 +
  pinMode (fan1, OUTPUT);              // sets the fan1 pin 3 up as an output.
 +
 
 +
}
 +
 
 +
void loop()                            // code here will continue to replay nutil powered off.
 +
{
 +
  tempC = analogRead(tempPin);          // read the analog value from the lm35 sensor.
 +
  tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade.
 +
  Serial.print((byte)tempC);            // send the data to the computer.
 +
 
 +
    if (tempC > 38)                    // creates bool expression for analyzation. if it evaluates to true,
 +
    {                                  // the body of the if statement will execute.
 +
   
 +
      digitalWrite (led, HIGH);        // turns on led.
 +
      digitalWrite (fan1, HIGH);        // turns on fan1.
 +
   
 +
    }
 +
    else                                // if the if equation evaluates to false the else statement will execute.
 +
    {
 +
     
 +
      digitalWrite (led, LOW);          // turns off led.
 +
      digitalWrite (fan1, LOW);        // turns off fan1.
 +
     
 +
    }
 +
  delay(3000);                          // wait 3 seconds before redoing the loop.
 +
}
 +
</p>

Revision as of 10:20, 13 April 2013

Reauben Samson has made an incubator and we need to check if it is working. We used a digital thermometer,
it gives us different readings after every 15 minutes and we concluded it does not work so now we are
building a temperature sensor using the Arduino Uno board and LM35 temperature sensor. The main aim is to keep
a constant temperature using a light bulb as our heat source. We will be using a CPU fan to cool down the light bulb
and to keep the incubator at a certain threshold temperature.

Parts list: CPU fan LED Light bulb (230 VOLT, 75 WATTS)
LM 35 (temperature sensor)
Diode (2N3904 - E25)
Relay (JQC-3F 6 VOLT)
Wire
Arduino Uno


Arduino Code LM 35 Temperature Sensor float tempC; // create variable to store the temperature in. int tempPin = 0; // Attach vout to analog pin 0. int led = 13; // attach led to pin 13. int fan1 = 3; // attach base of transistor to digital pin 3. int pos = 0; // create variable to store the position of the servo motor. void setup() // Will execute once at the start of the code. { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps pinMode (led, OUTPUT); // sets the led pin 13 up as an output. pinMode (fan1, OUTPUT); // sets the fan1 pin 3 up as an output. } void loop() // code here will continue to replay nutil powered off. { tempC = analogRead(tempPin); // read the analog value from the lm35 sensor. tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade. Serial.print((byte)tempC); // send the data to the computer. if (tempC > 38) // creates bool expression for analyzation. if it evaluates to true, { // the body of the if statement will execute. digitalWrite (led, HIGH); // turns on led. digitalWrite (fan1, HIGH); // turns on fan1. } else // if the if equation evaluates to false the else statement will execute. { digitalWrite (led, LOW); // turns off led. digitalWrite (fan1, LOW); // turns off fan1. } delay(3000); // wait 3 seconds before redoing the loop. }