tutorialspinouttools
Sensors · ESP32-C3

TMP36 on OLED: Analog Temperature

Free ESP32 & Arduino tutorial · wiring, code & parts · gokul.builds

Overview & Wiring

What it is: The TMP36 is an analog temperature sensor like the LM35, but with a 500 mV offset so it can read below 0 °C on a single supply. Output is 10 mV per °C with 500 mV at 0 °C — so 750 mV = 25 °C. How it works: Read the output voltage and convert with tempC = (millivolts - 500) / 10. This sketch uses analogReadMilliVolts() for a calibrated reading. Wiring (flat face toward you, pins down — left to right): TMP36 +Vs (left) -> 3V3 TMP36 Vout (middle) -> GPIO0 TMP36 GND (right) -> GND OLED VCC=3V3, GND=GND, SDA=GPIO4, SCL=GPIO5 Libraries: only "Adafruit SSD1306" and "Adafruit GFX Library". On screen / Serial: temperature in °C with one decimal. Gotchas: The TMP36 and LM35 look identical but use different formulas — don't mix them up (a TMP36 read with LM35 math shows ~50° too high). GPIO0 is a boot pin; safe to read but don't force it low during reset.

Circuit Diagram

TMP36 on OLED: Analog Temperature wiring diagram for ESP32-C3

Parts You Need

ESP32-C3 SuperMiniBuy →
0.96" SSD1306 OLEDBuy →

Source Code (Arduino / ESP32)

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1);

#define TMP36 0               // Vout on GPIO0 (ADC)

void setup() {
  Serial.begin(115200);
  Wire.begin(4, 5);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}

void loop() {
  int mv = analogReadMilliVolts(TMP36);      // calibrated millivolts
  float tempC = (mv - 500) / 10.0;           // TMP36: 500 mV offset, 10 mV/°C

  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("TMP36");
  display.setTextSize(3);
  display.setCursor(0, 24);
  display.printf("%.1f", tempC);
  display.setTextSize(2);
  display.print(" C");
  display.display();

  Serial.printf("Temp: %.1f C  (%d mV)\n", tempC, mv);
  delay(300);
}
Browse all tutorials ESP32-C3 pinout Calculators