• Pooja Velavan

Interfacing Temperature Sensor with Arduino using TinkerCAD

Simulation software is an interactive tool generally used in experimenting with the circuit design before establishing it in the hardware/PCB board. It helps to analyze the design schematic to check the integrity of its functions and makes sure the efficiency of the design before establishing it in the circuit board.


In this article, let us learn how to Interface Temperature Sensor with Arduino using TinkerCAD. Let's first start with the requirements that we will need to design the circuit with TinkerCAD Software.


Hardware Requirements:


These components are required for manual circuit development, for #simulation purposes TinkerCAD software is sufficient. To build the circuit manually, click on the links given below to buy the components required.


1. Arduino UNO:

Develop a stronger concept in Arduino through this article:- What is Arduino?

Arduino UNO

#Arduino board is a microcontroller that is used to accept inputs from sensors connected and provide an output action on the desired device connected to it. The sensor inputs can be from light-detecting sensors, motion sensors (Ultrasonic or IR), temperature sensors, etc. The output from this device can be received through other output devices such as LED, Buzzer, Serial monitor, etc.


Buy Arduino UNO from here.


2. LM-35 Temperature Sensor:


LM-35 Temperature Sensor

LM-35 #Temperature Sensor is a temperature measuring device, gives an analog output voltage based on the instantaneous change in temperature value. This analog output voltage is proportional to the instantaneous input. It has three pins namely - supply voltage pin (Vcc), Output Voltage pin, and Ground pin (Gnd).


Buy LM-35 Temperature Sensor from here.


3. Jumper Wires:


Jumper Wires


These are the main components that are used to establish the connections between different devices of the circuit. There are three types male to female, female to female, and male to male.


Buy Jumper Wires from here.


Software Requirements:


1. TinkerCAD Software:


TinkerCAD Software LOGO

It is an easy-to-use online simulation #software used for circuit design. It has all the essential electrical components required to built and analyze the circuit.


Visit the TinkerCad website.


Circuit Connection:


Circuit Connection

The connection between the Arduino board and LM35- Temperature sensor by using jumper wires involves simple steps:

  • The supply voltage is the voltage by which the circuit operates, and it needs to be connected to 5V on the Arduino board to power the temperature sensor LM35.

  • The output voltage is the analog pin connected to the A0 pin of the Arduino board through which we receive data.

  • Finally, connect the ground pin of the sensor to the GND terminal in the Arduino board to establish a common ground connection.

Code Explanation:

int temp = A0; //declaring the temperature sensor
float temp_celsius;
float Voltage;
float analog_reading;
float temp_far;

Every program code starts with the declaration of the variables that are required for the execution of the program. The values are declared in the "int" and "float" datatypes. The "temp" is declared to initialize the pin from which the reading is to be taken. The "temp_celsius" declares the temperature reading on the celsius scale. The "analog_reading" is declared to read the values from the input pin. Finally, "temp_far" is declared to read the temperature on the Fahrenheit scale.

void setup()
{
  pinMode(A0, INPUT); //set temp sensor as input
  Serial.begin(9600);
}

The setup( ) function uses pinMode functions to assign the Mode for the pins declared. A0 pin is going to take the input from the Temperature sensor, so it's assigned as input mode. The baud rate is assigned as 9600, it intimates the Arduino to get ready to exchange messages with Serial monitors at a speed of 9600 bits per second.

void loop()
{
  analog_reading = analogRead(A0);
  Serial.print("Analog reading:");//read analog reading 
  Serial.println(analog_reading); 

In the loop function, reads the values from the assigned A0 pin by "analog_reading". Then print the output of the analog_reading.

//converting analog reading to voltage
  Voltage = analog_reading*5/1024;
    // we divide by 1024 as the analog reading from the data pin is between 0 and 1024
    // 5 because 5Volts;
  
  Serial.print("Voltage reading:"); //display Voltage
  Serial.println(Voltage);

The output of the analog_reading is converted into a voltage by multiplying analog_reading with the supply voltage that is 5Volt and dividing with 1024. Then write the print statement to display the voltage reading.

 //reading in celsius: 
  //converting from 10 mv per degree with 0.5V offset
  temp_celsius = 100* (Voltage - 0.5) ;
  Serial.println("Celsius reading:" + String(temp_celsius) + (" C"));
  temp_far = (temp_celsius * 9/5) + 32 ;
  Serial.println("Farenheit reading:" + String(temp_far)  + (" F\n"));
  delay(3000); //give a delay of 3 seconds before repeating the loop
}

Finally, represent the output of the temperature #sensor in the celsius and Fahrenheit scale. For deriving the output in the Celsius scale, subtract the voltage reading with the cutoff voltage and multiply it by 100. For deriving the output in the Fahrenheit scale multiply the celsius reading by 9/5 and add 32 with it. Conversion of Celsius to Fahrenheit is the general formula to be known. Then print the output obtained in degrees Celsius and Fahrenheit scale.


Complete Code:

int temp = A0; //declaring the temperature sensor
float temp_celsius;
float Voltage;
float analog_reading;
float temp_far;

void setup()
{
  pinMode(A0, INPUT); //set temp sensor as input
  Serial.begin(9600);
}
void loop()
{
  analog_reading = analogRead(A0);
  Serial.print("Analog reading:");//read analog reading 
  Serial.println(analog_reading); 
  
  //converting analog reading to voltage
  Voltage = analog_reading*5/1024;
    // we divide by 1024 as the analog reading from the data pin is between 0 and 1024
    // 5 because 5Volts;
  
  Serial.print("Voltage reading:"); //display Voltage
  Serial.println(Voltage);
  
  //reading in celsius: 
  //converting from 10 mv per degree with 0.5V offset
  temp_celsius = 100* (Voltage - 0.5) ;
  Serial.println("Celsius reading:" + String(temp_celsius) + (" C"));
  temp_far = (temp_celsius * 9/5) + 32 ;
  Serial.println("Farenheit reading:" + String(temp_far)  + (" F\n"));
  delay(3000); //give a delay of 3 seconds before repeating the loop
}

NOTE: The default code present in the TinkerCAD window needs to be removed and the program code needs to be written. Download the document and copy-paste the code in TinkerCAD to simulate the circuit.

CODE for Interfacing Temperature Sensor
.
Download • 1KB

Working:


Let us first learn how to work with TinkerCAD #simulation software. Once entered on the TinkerCad page, select circuits, and search for the components required for the connection. The required components are to be dragged and brought to the circuiting screen. The connection needs to be made by selecting the jumper wires. The colors of the wires can be selected in different colors to show distinguish between each connection.


Learn more about TinkerCad in detail.


The Temperature sensor takes the input when there is a temperature change and it shows the following variation in the output voltage and temperature in Celsius and Fahrenheit scale. For every one-degree increase in temperature, there is a 10mV increase in the voltage.


The below image shows the working of the circuit after proper connection and compiling of the coding.

Working of Circuit

In #TinkerCad we have the advantages of simulating the circuit by changing the inputs. Likewise in this circuit, we can change the #temperature by moving the temperature knob. The below image shows the change in output while varying the input.

Working of Circuit with Change in input

The below image is the Serial Monitor in which the changes in the output temperature while changing the input is shown.

Output Screen

Watch the below-given Working video for the practical explanation of designing the circuit and to know more about how the simulation software works.


Video By - Rhea Mantri


Simulation software plays a major role in the building of large circuits as they help to analyze the working of the circuit before it can be built practically. It helps us create a #virtual design of the circuit we want to build and avoid damages to the circuit if in case we don't know, beforehand about the correct circuit connections.


For more projects through TinkerCad click here.


By using this TinkerCad open-source software design your own circuit, run the code in the software, and validate your project ideas.

See also:

  1. Fire Alarm System Project by Interfacing Arduino with Temperature & Gas Sensor using TinkerCad

  2. Smart Street Light Project using Arduino UNO, LDR, and LED

  3. Light Intensity Measurement using LDR sensor and Arduino on TinkerCAD


  • Facebook
  • YouTube
  • Instagram
  • LinkedIn
LearnElectronics
Contact Us
© Copyright - LearnElectronics 2021