Introduction
In this article we learn How to Use Arduino Internal Temperature Sensor, Arduino enthusiasts might be surprised to learn that many Arduino models come equipped with an internal temperature sensor embedded in the processor. This feature is present in ATmega 168A, 168P, 328, and 32P (found in Arduino Uno and Nano), as well as Atmega32U4 (used in Arduino Leonardo). However, it’s worth noting that the ATMega2560, the processor in Arduino Mega, does not include this internal temperature sensor.
The sensor’s accuracy is somewhat limited since it resides within the processor and is influenced by its own heat. The temperature readings can be affected by the processor’s workload and the current flowing through its outputs. With proper calibration, the Arduino’s internal sensor can provide a basic measurement of ambient temperature with an accuracy of around 2ºC. It’s important to allow the processor to cool for at least 10 minutes after powering it off for more reliable results.
Despite its inherent limitations, the internal temperature sensor proves to be intriguing as it enables measurements without the need for external sensors. This feature can be particularly useful for assessing the processor’s status, conducting quick tests on a board, or engaging in temperature measurement projects where low precision and extended intervals between measurements are acceptable.
Hardware Required
Installing Arduino IDE Software
First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide click on How to install Arduino
Steps
Here are some Steps for How to Use Arduino Internal Temperature Sensor:
- Examine the Arduino board’s chip to identify the presence of the internal temperature sensor.
- Connect the Arduino to your computer system.
- Upload the Arduino code designed for the internal temperature sensor.
- Retrieve the temperature reading from the Arduino Serial Monitor.
Code
//For more Projects: www.arduinocircuit.com
// Internal Temperature Sensor
// Example sketch for ATmega328 types.
void setup()
{
Serial.begin(9600);
Serial.println(F("Internal Temperature Sensor"));
}
void loop()
{
// Show the temperature in degrees Celcius.
Serial.println(GetTemp(),1);
delay(1000);
}
double GetTemp(void)
{
unsigned int wADC;
double t;
// The internal temperature has to be used
// with the internal reference of 1.1V.
// Channel 8 can not be selected with
// the analogRead function yet.
// Set the internal reference and mux.
ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
ADCSRA |= _BV(ADEN); // enable the ADC
delay(20); // wait for voltages to become stable.
ADCSRA |= _BV(ADSC); // Start the ADC
// Detect end-of-conversion
while (bit_is_set(ADCSRA,ADSC));
// Reading register "ADCW" takes care of how to read ADCL and ADCH.
wADC = ADCW;
// The offset of 324.31 could be wrong. It is just an indication.
t = (wADC - 324.31 ) / 1.22;
// The returned temperature is in degrees Celcius.
return (t);
}
Serial Monitor Output
For sensor calibration, perform the following steps:
- Take multiple measurements with the sensor.
- Allow the sensor to remain off for a duration of 30 minutes.
- Compare the obtained measurements with those from a calibrated sensor.
- Adjust the values in the expression, specifically 324.31 and 1.22.
Applications
- Climate Monitoring in DIY Projects: Utilize the Arduino internal temperature sensor for basic climate monitoring in do-it-yourself projects, providing a cost-effective solution for hobbyists.
- Energy-Efficient Temperature-Triggered Systems: Employ the internal sensor to create energy-efficient systems that respond to temperature changes, such as activating cooling mechanisms or adjusting device behavior.
- Greenhouse Temperature Control: Implement the Arduino’s internal sensor in greenhouse setups for monitoring and regulating temperature conditions, ensuring optimal growth conditions for plants.