# Seg 5: Schematic diagram and experiment of LM35

1. Schematic circuit

By the connection diagram shown in Figure 8-2, this experimental schematics is easily draw in Figure 8-3. Note that, we should design the circuit by the pin connection of temperature sensor.

Figure 8-3 Schematic circuit

8-4 Circuit diagram

1. Code

Run Program 8.

 01 // Program 8: use sensor to measure your environmental temperature 02  03 void setup() { 04   05   Serial.begin(9600);         //set the baud for serial communication 06 } 07   08 void loop() { 09   10   int n = analogRead(A0);    //read the voltage from A0 11   12   float vol = n * (5.0 / 1023.0*100);   //computation of temperature 13   14   Serial.println(vol);                   //output temperature 15   delay(2000);                           //wait for 2s for display 16 }

Open the serial monitor on the Arduino software platform, we can see the Celsius temperature sensed by the temperature sensor LM35. Note that, the baud of monitor should be the same as the above code, which can be seen in Figure 8-5.

Figure 8-5 the temperature value on the Arduino monitor

From Figure 8-5, we know that the environmental temperature is about 24.44 in this experiment.

1. Key points and summaries
2. We should know the features about the temperature sensor. For example, in such experiment, the temperature of LM35 is linearly proportional to the voltage. By this relationship, we can get the formula about the temperature and voltage.
3. We should the connection about the sensor logs. As for LM35 in this experiment, let the full-face having characters facing us. Then the left is connected to 5V port on the Arduino board, the right leg is a GND port, which should connect to the GND port on Arduino board, and the middle leg should connect to the analog port on the Arduino board, which can output the concrete value about temperature.
4. The output temperature value can be seen on the serial monitor. But, the baud for the monitor should be unanimous with the baud set in the experimental code.

# Seg 4: Experimental principle of LM35

1. Experiment and code
1. Experimental principle

The principle of such experiment is very simple. The voltage data is sensed by the temperature sensor LM35, which would be sent to the analog port (A0 is used in this experiment) on the Arduino board. Then the Celsius (Centigrade) temperature can be output by the linear relationship between the voltage and temperature. For example, in this experiment, we know the linear relationship for the temperature LM35 by one Celsius temperature/10mV. Thus, we can get the voltage value n from the analog port A0 connected LM35 on the Arduino board. Not that, the data n is discrete and located on the range of 0~1024. So, we should change the discrete data n into a continuous voltage to get the Celsius temperature. In fact, the computation is simple. We know that, as for the analog ports A0~A5, the value range is 0~1024, and 1024 is corresponding to 5V. Therefore, if we know the value in A0 port, then we can obtain the discrete voltage value within 0~1024; i.e., the value is n. Then, we can compute the Celsius temperature. Assume that the continue voltage in port A0 on Arduino board is denoted by U. Then, we have the following compute formula by the principle A0 and the linear relationship between Celsius temperature and the continuous voltage.

,

where vol is the Celsius temperature we should compute, n can be achieved from analog port A0 on the Arduino. Therefore, we can compute the continuous voltage in A0 by equation (1). Then, we substitute the U into equation (2), the Celsius temperature can thus be obtained. In addition, the value of vol (i.e., Celsius temperature) could display on the serial monitor on the Arduino software platform.