MEng 125n Laboratory Exercise 7
MEng 125n Laboratory Exercise 7
Exercise No. 7:
Temperature Sensing
Introduction
In this exercise, we will build a simple temperature monitoring system and
display the values to the Arduino Serial Monitor. The value from the LM35
sensor is read and stored into the tempReading variable. Then, the value of
tempReading is multiplied by 0.488 and stored into the correctTemperature
variable. Then, the value of correctTemperature is printed to serial port,
displaying its value in the Serial monitor. A pause of 1000 milliseconds
happens, and the process repeats again.
Learning Outcomes
After this laboratory exercise, student should be able to:
1. discuss the concepts of Temperature Sensing;
2. use the LM35 IC as a Temperature Sensor; and
3. use the programming data type “float decimal numbers” and
arithmetic math function: multiplication (*).
Materials
• 1 – Arduino UNO R3
• 1 – USB Cable (USB-A to USB-B)
• 1 – LM35 Temperature Sensor
• 1 – Breadboard
• Connecting Wires
• Computer with Arduino software
Procedure
void setup()
{
// call a serial monitor communication to view the readings
Serial.begin(9600);
}
Page 26 of 56
Vision: A globally competitive university for science, technology, and environmental conservation.
TP-IMD-04
Mission: Development of a highly competitive human resource, cutting-edge scientific knowledge V0 07-15-2020
and innovative technologies for sustainable communities and environment. No. CET.ME
LM21-01
For instructional purposes only • 1st Semester SY 2020-2021 27
3. Click Verify button to review code for errors. If the code has no
errors and missing commands a message on the window below will
display “Done Compiling” this means your code is
ready to be uploaded into the Arduino microcontroller board.
4. Click Upload button to upload the Arduino Code to the Arduino
microcontroller board.
5. Run the program and open the Arduino Serial Monitor (configurations
of the Serial Monitor in the bottom of the window: checked Autoscroll,
Both NL&CR and 9600 baud). You should see the values of the
temperature in degrees Celsius print out in the Serial monitor. From the
code above, the value will be printed every 1 second.
References
Page 27 of 56
Vision: A globally competitive university for science, technology, and environmental conservation.
TP-IMD-04
Mission: Development of a highly competitive human resource, cutting-edge scientific knowledge V0 07-15-2020
and innovative technologies for sustainable communities and environment. No. CET.ME
LM21-01
28 MEng 125n: Basic Electronics
Page 28 of 56
Vision: A globally competitive university for science, technology, and environmental conservation.
TP-IMD-04
Mission: Development of a highly competitive human resource, cutting-edge scientific knowledge V0 07-15-2020
and innovative technologies for sustainable communities and environment. No. CET.ME
LM21-01