How to Build a Simple Arduino-Based Temperature Sensor for Under $20

Building a simple temperature sensor with an Arduino is an easy and inexpensive way to monitor temperatures. With just a few basic electronic components, you can assemble a fully-functional temperature logger for under $20. Here's a step-by-step guide on how to build your own Arduino temperature sensor.

What You'll Need

To build the temperature sensor, you'll need the following parts:

In total, all of the parts can be sourced for around $20, give or take a few dollars. Having a basic electronics toolkit with wire strippers, cutters, and a soldering iron is also recommended.

How It Works

The TMP36 temperature sensor works by outputting an analog voltage that is proportional to the ambient temperature around the sensor. At room temperature (25°C or 77°F), the sensor will output about 750 mV.

This analog voltage gets fed into one of the Arduino's analog input pins. The Arduino can then use its analog-to-digital converter (ADC) to convert this voltage to a digital value.

Some simple code can then take this digital value and convert it back to a temperature reading, in degrees Celsius, Fahrenheit, or Kelvin. This temperature can then be displayed on the Arduino's serial monitor or used to drive other outputs like an LED or LCD display.

Circuit Diagram

Here is a circuit diagram showing how to connect the components:

How to Build a Simple Arduino-Based Temperature Sensor for Under

The key points in the wiring:

Code

Here is some sample Arduino code to read the temperature sensor, convert the analog input to a temperature, and print it to the serial monitor:

```cpp
// Set analog pin for TMP36 sensor
int tempPin = 0;

// Variables to store temperature values
float tempC;
float tempF;

void setup() {

// Begin serial communication at 9600 baud
Serial.begin(9600);

}

void loop() {

// Read analog voltage from sensor
int reading = analogRead(tempPin);

// Convert to temperature in Celsius
tempC = (reading * 5.0 * 100.0)/1024;

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

// Print temperatures
Serial.print(" C ");
Serial.print(tempC);
Serial.print(" F ");
Serial.println(tempF);

delay(500); // Wait half second and repeat
}
```

This code reads the analog voltage from the sensor pin, converts it to Celsius, then converts Celsius to Fahrenheit. It prints both values to the serial monitor every half second.

Building and Testing

With all the parts assembled, follow these steps:

  1. Build the circuit on a breadboard based on the wiring diagram above
  2. Upload the Arduino sketch to read the sensor
  3. Open the serial monitor at 9600 baud to see temperature output
  4. Verify the readings look reasonable by checking room temperature
  5. Optionally add an LED that blinks when a temperature threshold is exceeded

Once you have it working on a breadboard, you can transfer the circuit to a perfboard or PCB for a more compact and permanent sensor package. Add functions like data logging, alarm outputs, LCD display, etc.

Going Further

Some ideas for enhancing this basic temperature sensor:

By leveraging the Arduino platform, you can build a fully-featured temperature monitor on a low budget. The possibilities are endless!