top of page
IMG_20170503_173438.jpg

Post

Projects Arduino: How to measure the temperature with an Arduino board and a temperature sensor


Measure temperature with an arduino sensor
Measure temperature with an arduino sensor


Hi there!!!


Welcome to Makersgeneration, your go-to destination for kids' science lab and where scientific activities are being taught.


If you are a regular to this platform, then you are not new to the Arduino development platform. For newcomers, Arduino helps us bring all our electronic gadget ideas to life. It is an excellent platform that comes in handy when exploring and learning about electronics and programming for kids. Arduino offers a simple interface and a wide range of sensors with endless possibilities for creative projects.


For today's project, we will be working on Arduino temperature sensor project. The sensor featured in this project will be the "LM35 Temperature sensor". As the name implies, this sensor enables us to measure the current temperature of a particular place in real-time. COOL RIGHT!!!?


With the LM35 sensor and an Arduino board at our disposal, we can definitely play the role of a weather reporter... LOL.


LM35 Temperature sensor

  • LM35 is a temperature sensor that outputs an analog signal which is proportional to the instantaneous temperature.

  • The output voltage can easily be interpreted to obtain a temperature reading in Celsius. The advantage of lm35 over Thermistor is it does not require any external calibration.

  • LM35 sensor uses the basic principle of a diode, whereas the temperature increases, the voltage across a diode increases at a known rate. By precisely amplifying the voltage change, it is easy to generate an analog signal that is directly proportional to temperature.


Temperature sensor pinout (electronicshub.org)
Temperature sensor pinout (electronicshub.org)

Project requirements

  • Arduino Nano/Uno board

  • LM35 Temperature sensor

  • Compatible USB cable

  • Breadboard

  • 3 Jumper wires

Material required
Material required


Building the circuit


The circuit for this project is pretty straightforward. All you need to do is connect the three pins on the LM35 sensor to the respective pins of the Arduino Uno/Nano board via jumper wires.


Follow the table below to make the connection:

TEMPERATURE SENSOR

ARDUINO BOARD

+Vs

5V

Analog output (Vout)

A0

GND

GND


Schematic of Arduino Nano board and LM35 temperature sensor
Schematic of Arduino Nano board and LM35 temperature sensor


Schematic of Arduino Uno board and LM35 temperature sensor
Schematic of Arduino Uno board and LM35 temperature sensor


Schematic used
Schematic used


Arduino temperature sensor code


// Set analog pin the LM35 Vout pin will be connected to
const int sensorPin = A0;

// Create variable to store various values
float sensor_value;
float voltage;
float temperatureC;
float temperatureF;

void setup(){
    // Begin serial communication at 9600 baud rate
    Serial.begin(9600);
}

void loop(){
    // Get voltage reading to voltage
    sensor_value = analogRead(sensorPin);
    
    // Convert sensor reading to voltage
    voltage = sensor_value * (5.0 / 1024.0);
    
    // Convert voltage reading to temperature in Celsius
    temperatureC = voltage * 100;
    
    // Convert voltage reading to temperature in Fahrenheit
    temperatureF = (temperature * 9.0 / 5.0) + 32.0;
    
    // Print temperature in Celsius
    Serial.print("Temperature: ");
    Serial.print(temperatureC);
    Serial.print("\xC2\xB0");    // print degree symbol
    Serial.print("C ");
    
    // Print temperature in Fahrenheit
    Serial.print(temperatureF);
    Serial.print("\xC2\xB0");    // print degree symbol
    Serial.print("F ");
    
    delay(1000); // Wait for one second before next reading
    
}


To run the code:

  • Open the Arduino IDE, copy the code above, and paste it into the IDE's open window.

  • Navigate to Tools >> Select Board type (Arduino Uno or Nano) >> Select the correct Port assigned to your board.

Select the Arduino board
Select the Arduino board

  • To see the result of the temperature being read: Go to the top-right corner of the IDE and click on the icon below the exit button - The Serial monitor screen should pop up with the readings from the sensor.

Serial monitor showing temperature read by the sensor in degrees Celsius and Fahrenheit
Serial monitor showing temperature read by the sensor in degrees Celsius and Fahrenheit


Explore more


This project can be featured in a more advanced system. For example, you can make use of this project to automate fan control... Cool!!!


You can tell the system to turn on/off a connected fan depending on the temperature of the environment.


Pseudo-code sample:

if (temperature > 30);
    turn on fan
else if (temperature < 30);
    turn off fan



Online after-school and summer camps in Silver Spring Maryland



You and your children are looking for nice activities to have fun and learn new things and skills. Come join us starting in May and this summer for more online classes such as:


  • Python coding for kids and teens

  • Coding for elementary school students

  • Make video games

  • Electronics

  • Digital modeling (Create cars, rockets, rings, etc) for 3D printing

  • and much more

  • with the following link: Online after-schools

And the STEM summer camp for your kids is organized in Silver Spring Maryland nearby Washington DC to have fun and learn more about robotics, coding, droning, and more. Check the link right here:



Other cute things to make and hand-crafts for kids


If you are looking for more ideas for STEM projects to do with your kids, take a look at these other activities:



Newsletter, follow, subscribe, and like the social media


If you like online STEM activities, consider subscribing to the newsletter and social media for updates, and don't miss any STEM events. Don't forget to subscribe to the newsletter at the bottom of our website ''www.makersgeneration.net'' for more events, tutorials, and freebies.



Subscribe to the Facebook group if you have yet registered. Content and tutorials are shared daily: Create and build STEM projects for kids



We can be reached at: contact@makersgeneration.net if any questions.



See you on soon.

Categories

Recent Posts

Archive

Search By Tags

Follow Us

Comments

Share Your ThoughtsBe the first to write a comment.
bottom of page