• Home
  • Prakash
    • R and D
    • Smart Home
  • Basics
    • Capacitors
      • Color codeing Disc Capacitor Capacitor characterstics Polarity Non Polarity Series Connection Parallel Connection
    • Diodes
      • Zener Diode Light Emitting Diode Signal Diode Photo Diode
    • Inductors
    • Transistor
      • Silicon Germenium NPN PNP MOSFET SCR
    • Resistors
      • Color codeing 4-Band 5-Band Series Parallel Potential Meter
    • Logics
      • Analog Logic
      • Digital Logic
      • Hexa Decimal Numbers
      • Octal Numbers
      • Binary Fraction
      • Binay to Decimal
    • OP-Amplifiers
      • Basics
      • Oscillators
      • Transistor Switch
      • 555 IC circuits
      • Waveform Generators
      • 741 IC Circuits
    • Power supply
      • Transformer
      • Halfwave Rectifier
      • Fullwave Rectifier
      • Bridge Rectifier
      • 78xx Series
      • 0 to 30v Regulator
  • Modules
    • H-Bridge
      • L293D Bridge
      • Relay Bridge
    • RF 434MHz Modules
    • Relay Modules
    • Push to ON switch
    • Push to OFF switch
  • Sensors
    • Analog sensors List-1
      • LDR Photo Diode Solar Cell Transducers Temperature Humidity Sensor Soil Moisture Ranger Sensor Range Detection
    • Analog sensors List-2
      • Flame Sensor Force Sensor Flex Sensor Ambient Sensor Motion Sensor Vibration Sensor Sound Sensor UltraSonic Sensor GrayScale Sensor
    • Digital Sensors
      • Touch Sensor Tilt Sensor Signal
    • 3-Axis Sensor
    • Gyro Sensor
  • Projects
    • Embedded
      • Mini Projects 8051 Arduino NodeMCU MSP430 Raspberry IOT ARM
    • C #
      • Visual Basic Visual Studio
    • Matlab
    • VLSI
    • PHP-HTML
    • Contribute
  • Downloads
  • Technology

Arduino Temprature


How to connect Temperature Sensor to Arduino Uno?

The LM35 IC has 3 pins-2 for the power supply and one for the analog output.It is a low voltage IC which uses approximately +5VDC of power.The output pin provides an analog voltage output that is linearly proportional to the Celsius (centigrade) temperature. Pin 2 gives an output of 1 millivolt per 0.1°C (10mV per degree).So to get the degree value in Celsius, all that must be done is to take the voltage output and divide it by 10-this give out the value degrees in Celsius.
LM35Sensor.png
The circuit connections are made as follows:
  • Pin 1 of the LM35 goes into +5V of the arduino
  • Pin 2 of the LM35 goes into analog pin A0 of the arduino
  • Pin 3 of the LM35 goes into ground (GND) of the arduino

Program for Temperature Sensor Circuit

Before getting a Celsius reading of the temperature,the analog output voltage must first be read. This will be the raw value divided by 1024 times 5000. It is divided by 1024 because a span of 1024 occupies 5V. Here we get the ratio of the raw value to the full span of 1024 and then multiply it by 5000 to get the millivolt value. Since the output pin can give out a maximum of 5 volts (1024), 1024 represents the possible range it can give out. The raw voltage over this 1024 (value) therefore represents the ratio of how much power the output pin is outputting against this full range.Once we have this ratio, we then multiply it by 5000 to give the millivolt value. This is because there is 5000 millivolts in 5 volts.Refer here for more about analog voltage calculations. Once this analog voltage in millivolts is calculated, we then can find the temperature in Fahrenheit by the equation: ((Celsius * 9)/5 + 32).At the end of this program,a delay of 5000ms is included to take the temperature reading every 5 seconds.
//initializes/defines the output pin of the LM35 temperature sensor
int outputpin= A0;
//this sets the ground pin to LOW and the input voltage pin to high
void setup()
{
Serial.begin(9600);
}
//main loop
void loop()
{
int rawvoltage= analogRead(outputpin);
float millivolts= (rawvoltage/1024.0) * 5000;
float celsius= millivolts/10;
Serial.print(celsius);
Serial.print(" degrees Celsius, ");
Serial.print((celsius * 9)/5 + 32);
Serial.println(" degrees Fahrenheit");
delay(1000);
}
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Terms and Conditions -
Privacy Policy -

Contact Us

Name

Email *

Message *