EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #105 background imageLoading...
Page #105 background image
To use it, we only have to determine the current temperature t in Celsius. We
will use the TMP36 voltage output temperature sensor from Analog Devices.
3
Its cheap and easy to use.
To connect the TMP36 to the Arduino, connect the Arduinos ground and
power to the corresponding pins of the TMP36. Then connect the sensors
signal pin to the pin A0that is, the analog pin number 0:
As you mightve guessed from its vendors name, the TMP36 is an analog
device: it changes the voltage on its signal pin corresponding to the current
temperature. The higher the temperature, the higher the voltage. For us, its
an excellent opportunity to learn how to use the Arduinos analog IO pins.
So, lets see some code that uses the sensor:
InputDevices/Temperature/SensorTest/SensorTest.ino
const unsigned int TEMP_SENSOR_PIN = A0;
Line 1
const float SUPPLY_VOLTAGE = 5.0;
-
const unsigned int BAUD_RATE = 9600;
-
-
void setup() {
5
Serial.begin(BAUD_RATE);
-
}
-
-
void loop() {
-
const float tempC = get_temperature();
10
const float tempF = (tempC * 9.0 / 5.0) + 32.0;
-
Serial.print(tempC);
-
Serial.print(" C, ");
-
Serial.print(tempF);
-
Serial.println(" F");
15
delay(1000);
-
}
-
-
const float get_temperature() {
-
const int sensor_voltage = analogRead(TEMP_SENSOR_PIN);
20
const float voltage = sensor_voltage * SUPPLY_VOLTAGE / 1024;
-
return (voltage * 1000 - 500) / 10;
-
}
-
3.
http://tinyurl.com/msard-analog
report erratum discuss
Increasing Precision Using a Temperature Sensor 87
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino Pro Mini and is the answer not in the manual?

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals