Learn how to use Temperature Sensor in Arduino. We will learn about the working of the Temperature Sensor and Analog Input Pins. Currently, we are using Arduino UNO board and LM35 as Temperature Sensor. You can use any Arduino/Genuino Board or any Temperature Sensor and perform this experiment on that. Also, view the output on Serial Monitor. So, let’s start it.
Step 1: Required Components
Temperature Sensor (LM35) x 1
Breadboard x 1
Arduino UNO Board x 1
Step 2: Circuit Time
Make a circuit as per the given diagram. In Temperature Sensor there are three pins are available. The left-sided pin is for VCC, the middle pin is for Analog Output and the right-sided pin is for Ground. Here we have connected the Temperature Sensor to Analog Input Pin A0 of Arduino UNO Board.
Step 3: Code Time
This is the code for Temperature Sensor. Here, we have declared one pin which is for Analog Input and two variables for storing Analog Input and Temperature. In setup, the Serial Monitor is begun at 9600 Baud. In the loop, first fetched the data from the analog pin and stored in the analoginput variable. Then converted the analog input to a temperature in C. Finally printed it to the Serial Monitor.
Step 4: Upload the code to Arduino
Upload the above-given code to the Arduino UNO Board after the components are set as per the Circuit Diagram. The Temperature Sensor will give the analog output to the Arduino, Arduino will convert it into the Temperature and finally, it will show in the Serial Monitor. Screenshot of the output of Serial Monitor is as below.
For information about uploading code to Arduino UNO Click Here.