Results 1 to 1 of 1

Thread: DIY Temperature Sensor + Arduino

  1. #1
    iShot the Sheriff jdbnsn's Avatar
    Join Date
    Jan 2006
    Location
    Normal
    Posts
    8,241

    Default DIY Temperature Sensor + Arduino

    This tutorial is the work of Daniel Andrade and copied here with his permsission. For more great projects visit http://www.danielandrade.net


    Today I am going to show you how to build a simple temperature sensor using one LM35 Precision Temperature Sensor and Arduino, so you can hookup on your future projects. The circuit will send serial information about the temperature so you can use on your computer, change the code as you will. I’m planning to build a temperature sensor with max/min + clock + LCD, and when I get it done, I will post here.

    Parts:

    - Arduino (You can use other microcontroller, but then you will need to change the code).
    - LM35 Precision Centigrade Temperature Sensor, you can get from any electronic store. Here is the DATA SHEET.
    - BreadBoard

    Assembling:

    This is a quick and simple step. Just connect the 5V output from arduino to the 1st pin of the sensor, ground the 3rd pin and the 2nd one, you connect to the 0 Analog Input.

    Down goes some pictures that may help you, click to enlarge:










    Here is the Arduino Code, just upload it and check the Serial Communication Option.

    You can also download the .pde HERE.

    /*
    An open-source LM35DZ Temperature Sensor for Arduino. This project will be enhanced on a regular basis
    (cc) by Daniel Spillere Andrade , http://www.danielandrade.net
    http://creativecommons.org/license/cc-gpl
    */

    int pin = 0; // analog pin
    int tempc = 0,tempf=0; // temperature variables
    int samples[8]; // variables to make a better precision
    int maxi = -100,mini = 100; // to start max/min temperature
    int i;

    void setup()
    {
    Serial.begin(9600); // start serial communication
    }

    void loop()
    {

    for(i = 0;i< =7;i++){ // gets 8 samples of temperature

    samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
    tempc = tempc + samples[i];
    delay(1000);

    }

    tempc = tempc/8.0; // better precision
    tempf = (tempc * 9)/ 5 + 32; // converts to fahrenheit

    if(tempc > maxi) {maxi = tempc;} // set max temperature
    if(tempc < mini) {mini = tempc;} // set min temperature

    Serial.print(tempc,DEC);
    Serial.print(" Celsius, ");

    Serial.print(tempf,DEC);
    Serial.print(" fahrenheit -> “);

    Serial.print(maxi,DEC);
    Serial.print(” Max, “);
    Serial.print(mini,DEC);
    Serial.println(” Min”);

    tempc = 0;

    delay(1000); // delay before loop
    }
    This tutorial is the work of Daniel Andrade and copied here with his permsission. For more great projects visit http://www.danielandrade.net
    Last edited by jdbnsn; 12-09-2008 at 11:08 AM.
    "At the midpoint on the journey of life, I found myself in a dark forest, for the clear path was lost..." -Dante Alighieri

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •