Making a simple Arduino temperature sensor

Recently I decided to play more with an Arduino starter kit that I bought from Amazon (Arduino Uno R3 Board Starter Kit) and make a simple temperature sensor from it. Now when it comes to using the Arduino kits, I had no idea where to start. After some research, I made one reading the temperature in C, F and also the voltage.

Heres a simple guide:

  1. Connect the TMP36/2N3904 temperature sensor to your arduino by connecting the sensor’s VCC pin to the Arduino’s 5v port.
  2. Then the ground pin on the sensor to the GND port on the Arduino
  3. Finally connect the temperature sensor’s VOUT pin to the Arduino’s A0 port.


And thats it on the hardware side, now for the software.

//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36’s Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures

* setup() – this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer

void setup()
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
void loop() {
// {
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);

// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;

// print out the voltage
Serial.print(voltage); Serial.println(” volts”);

// now print out the temperature
float temperatureC = (voltage – 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage – 500mV) times 100)
Serial.print(temperatureC); Serial.println(” degrees C”);

// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(” degrees F”);

delay(250); //waiting 60 seconds

Then hit verify, then press upload. Open up the serial monitor and you should start getting something like this….

If you do, then well done, you have a basic temperature sensor.

You can copy and paste these results into a text document and save the file as a CSV file to import into Excel to make graphs from it if you wish.


Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *