Introduction: Simple Thermometer Using TMP36 and ESP32

The TMP36 temperature IC is a very cheap IC that can be used as a digital thermometer for all kinds of applications from measuring the temperature of your room to measuring the inner temperature your meat, and it costs under $2! This project uses the TMP36 IC as a simple, accurate, easy-to-build and cheap thermometer, that you can make in less than 5 minutes for only $7!!!

Using the TMP36 temperature IC with an ESP32 is subtly different than an Arduino, because but the formula in the datasheet does not apply to the ESP32, due to the way the ESP32 processes the digital signal. This difference is noted under the code, and how the code changes as a result of the ESP32's quirk!

Step 1: Tools and Materials

  • ESP32 Development board - $5
  • TMP36 Temperature Sensor - $1.5
  • 3 pieces of jumper wires - a few cents
  • [OPTIONAL] Breadboard

Step 2: Circuitry

  1. Connect the middle pin of the temperature IC, TMP36, to pin D6 on the ESP32 Development Board.
  2. Connect the left pin with the flat edge of the temperature IC facing towards you, to the 3.3V pin on the ESP32 development board
  3. Lastly, connect the right pin of the temperature IC to the GND pin on the ESP32 development board.

Step 3: Coding

There are very subtle differences in when coding a temperature sensor on the ESP32 board as opposed to the Arduino. For the ESP32 board, we do not need to multiply the raw sensor reading by the voltage, but simply needs to be normalized by the 2^10 bits.

const int tempPin = 2;     //analog input pin constant<br>
int tempVal;    // temperature sensor raw readings
float volts;    // variable for storing voltage 
float temp;     // actual temperature variable
void setup()
{
  // start the serial port at 9600 baud
  Serial.begin(9600);
}
void loop()
{
 //read the temp sensor and store it in tempVal
 tempVal = analogRead(tempPin);
 volts = tempVal/1023.0;             // normalize by the maximum temperature raw reading range
 temp = (volts - 0.5) * 100 ;         //calculate temperature celsius from voltage as per the equation found on the sensor spec sheet.
Serial.print(" Temperature is:   "); // print out the following string to the serial monitor
Serial.print(temp);                  // in the same line print the temperature
Serial.println (" degrees C");       // still in the same line print degrees C, then go to next line.
delay(1000);                         // wait for 1 second or 1000 milliseconds before taking the next reading. 
}

Step 4: Demonstration Video

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017