Simple Thermometer Using TMP36 and ESP32
by TechMartian in Circuits > Microcontrollers
15877 Views, 13 Favorites, 0 Comments
Simple Thermometer Using TMP36 and ESP32
![t.jpg](/proxy/?url=https://content.instructables.com/FXA/NFTG/J5V3S697/FXANFTGJ5V3S697.jpg&filename=t.jpg)
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!
Tools and Materials
![2016-08-01 20.41.54.jpg](/proxy/?url=https://content.instructables.com/FFX/OMFW/J5V3S1KS/FFXOMFWJ5V3S1KS.jpg&filename=2016-08-01 20.41.54.jpg)
![2016-08-01 18.32.35.jpg](/proxy/?url=https://content.instructables.com/FHQ/GS4H/J5V3S11E/FHQGS4HJ5V3S11E.jpg&filename=2016-08-01 18.32.35.jpg)
![2016-08-01 20.40.20.jpg](/proxy/?url=https://content.instructables.com/FCQ/WVQS/J5V3S10N/FCQWVQSJ5V3S10N.jpg&filename=2016-08-01 20.40.20.jpg)
![2016-08-01 18.33.47.jpg](/proxy/?url=https://content.instructables.com/FKS/POTD/J5V3S11R/FKSPOTDJ5V3S11R.jpg&filename=2016-08-01 18.33.47.jpg)
![2016-08-01 18.33.58.jpg](/proxy/?url=https://content.instructables.com/FOT/LL3M/J5V3S11Q/FOTLL3MJ5V3S11Q.jpg&filename=2016-08-01 18.33.58.jpg)
- ESP32 Development board - $5
- TMP36 Temperature Sensor - $1.5
- 3 pieces of jumper wires - a few cents
- [OPTIONAL] Breadboard
Circuitry
![Screen Shot 2017-08-02 at 11.03.30 PM.png](/proxy/?url=https://content.instructables.com/FSG/KF8A/J5V3S0G0/FSGKF8AJ5V3S0G0.png&filename=Screen Shot 2017-08-02 at 11.03.30 PM.png)
![Screen Shot 2017-08-02 at 11.04.24 PM.png](/proxy/?url=https://content.instructables.com/FDJ/JNOP/J5V3S0G4/FDJJNOPJ5V3S0G4.png&filename=Screen Shot 2017-08-02 at 11.04.24 PM.png)
![2016-08-01 20.45.08.jpg](/proxy/?url=https://content.instructables.com/F8P/24PN/J5V3S1JP/F8P24PNJ5V3S1JP.jpg&filename=2016-08-01 20.45.08.jpg)
![2016-08-01 20.45.46.jpg](/proxy/?url=https://content.instructables.com/FTK/5HXJ/J5V3S1JQ/FTK5HXJJ5V3S1JQ.jpg&filename=2016-08-01 20.45.46.jpg)
- Connect the middle pin of the temperature IC, TMP36, to pin D6 on the ESP32 Development Board.
- 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
- Lastly, connect the right pin of the temperature IC to the GND pin on the ESP32 development board.
Coding
![Screen Shot 2017-08-07 at 1.01.01 AM.png](/proxy/?url=https://content.instructables.com/FZ3/TAAO/J5Y8156W/FZ3TAAOJ5Y8156W.png&filename=Screen Shot 2017-08-07 at 1.01.01 AM.png)
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. }
Downloads
Demonstration Video
![Interfacing TMP36, Temperature Sensor with ESP32](/proxy/?url=https://content.instructables.com/F1W/XAIB/J5V3S0DF/F1WXAIBJ5V3S0DF.jpg&filename=Interfacing TMP36, Temperature Sensor with ESP32)