How to Build a DIY Electronic Temperature Sensor with Arduino for Under

How to Build a DIY Electronic Temperature Sensor with Arduino for Under $10

Building your own DIY electronic temperature sensor with an Arduino is an easy and inexpensive project that can teach you a lot about electronics and microcontrollers. With just a few common components, I was able to build a fully-functional temperature sensor for under $10.

What You Will Need

To build the temperature sensor, I used:

The total cost of these components was under $10, with the Arduino being the most expensive part. The Arduino is reusable for many projects, so the temperature sensor itself can be built for just a few dollars.

How the Temperature Sensor Works

The main component of this project is the TMP36 temperature sensor. This is an analog sensor that provides a voltage output proportional to temperature.

The TMP36 has three pins - ground, voltage in, and voltage out. To use it, I powered it from the Arduino's 5V pin so it would output voltages between 0V and 5V depending on the detected temperature.

I used the 10K ohm resistor as a pull-down resistor on the output pin to allow the voltage to go all the way to 0V at low temperatures.

The Arduino then reads this output voltage and converts it to a temperature using the analog to digital converter (ADC). The Arduino's ADC converts the 0-5V input to a digital value between 0-1023.

By default, each step represents ~4.88mV. Since the TMP36 outputs 10mV per degree Fahrenheit, the temperature can be calculated easily in the Arduino code.

Circuit Diagram

Here is a circuit diagram showing how everything is connected:

The TMP36 gets power from the Arduino's 5V pin. The output pin connects to one of the Arduino's analog input pins through a 10K pull-down resistor.

The LED and 220 ohm resistor are optional - they allow the Arduino to turn on the LED when a certain temperature threshold is exceeded.

Arduino Code

The Arduino code reads the analog voltage from the TMP36, converts it to a temperature value, and prints it to the serial monitor. It also turns on the LED when the temperature goes above a set point.

// Define analog pin for TMP36 output

define TMP36Pin A0

// Define LED pin

define LEDPin 13

// Variables
int ADCvalue;
float tempC;
float tempF;

void setup() {


// Set LED pin as output
pinMode(LEDPin, OUTPUT);


void loop() {

// Read analog voltage from TMP36
ADCvalue = analogRead(TMP36Pin);

// Convert to temperature in Celsius
tempC = (ADCvalue * 0.004882814) - 50;

// Convert to Fahrenheit
tempF = tempC * 9.0 / 5.0 + 32.0;

// Print temperature
Serial.print("Temperature: ");
Serial.print(" C, ");
Serial.println(" F");

// Turn on LED if temp exceeds 28C
if(tempC > 28) {
digitalWrite(LEDPin, HIGH);
else {
digitalWrite(LEDPin, LOW);



This code is very simple and just prints the calculated temperature value every second. The LED provides a visual indicator when a temperature threshold is exceeded.

Building and Testing

With the circuit assembled on a breadboard and the code uploaded to the Arduino, I was ready to test it out.

I verified it was working by blowing on the sensor to change the temperature. I saw the values print out in the serial monitor and the LED turned on and off appropriately.

To improve accuracy, the sensor can be calibrated by placing it in ice water and adjusting the calculation. But even without calibration it was very responsive.

By spending just a few dollars on basic components, this project provided hands-on experience working with an Arduino, reading analog voltages, converting values, and controlling outputs. Building your own sensor from scratch is a great way to learn!