About:
In this tutorial, we are going to get the analog input from the LM35 temperature sensor and display the information onto the serial window as raw data, Celsius and Fahrenheit.
What Is an LM35 Temperature Sensor?The LM35 is one kind of commonly used temperature sensor that can be used to measure temperature with an electrical o/p comparative to the temperature (in °C). It can measure temperature more correctly compare with a thermistor. This sensor generates a high output voltage than thermocouples and may not need that the output voltage is amplified. The LM35 has an output voltage that is proportional to the Celsius temperature. The scale factor is .01V/°C.
The LM35 does not need any exterior calibration and maintains an exactness of +/-0.4°C at room temperature and +/-0.8°C over a range of 0°C to +100°C.One more significant characteristic of this sensor is that it draws just 60 microamps from its supply and acquires a low self-heating capacity. The LM35 temperature sensor available in many different packages like T0-46 metal can transistor-like package, TO-92 plastic transistor-like package, 8-lead surface mount SO-8 small outline package.
STEP 1: Set Up Arduino IDE for SurilliMake sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine).
STEP 2: The CircuitryThe circuitry is very simple. Follow the figure below to set up your hardware.
- Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload.
- After it is uploaded, the LM35 will start working.
- Observe your results on serial monitor of Arduino IDE.
int val;
int tempPin = 5;
void setup()
{
SerialUSB.begin(9600);
}
void loop()
{
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
float farh = (cel*9)/5 + 32;
SerialUSB.print("TEMPERATURE = ");
SerialUSB.print(cel);
SerialUSB.print("*C");
SerialUSB.println();
delay(1000);
SerialUSB.print("TEMPERATURE = ");
SerialUSB.print(farh);
SerialUSB.print("*F");
SerialUSB.println();
}
That's it! After uploading this code on you Surilli board, the sensor will start working.
If you have any queries, feel free to contact us at surilli.io.
Comments