ESP8266 - LM35 Temperature Sensor OLED
This tutorial instructs you how to use ESP8266 to obtain the temperature from an LM35 sensor and show it on an OLED.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Buy Note: If you want a bigger OLED display, use the 2.42 inch OLED Display 128x64 .
Overview of OLED and LM35 Temperature Sensor
If you are unfamiliar with OLED and LM35 Temperature Sensor (including pinout, functionality, and programming), the following tutorials can help:
- ESP8266 - OLED tutorial
- ESP8266 - LM35 Temperature Sensor tutorial
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
See more in ESP8266's pinout and how to supply power to the ESP8266 and other components.
ESP8266 Code - LM35 Temperature Sensor - OLED
Detailed Instructions
To get started with ESP8266 on Arduino IDE, follow these steps:
- Check out the how to setup environment for ESP8266 on Arduino IDE tutorial if this is your first time using ESP8266.
- Wire the components as shown in the diagram.
- Connect the ESP8266 board to your computer using a USB cable.
- Open Arduino IDE on your computer.
- Choose the correct ESP8266 board, such as (e.g. NodeMCU 1.0 (ESP-12E Module)), and its respective COM port.
- Click to the Libraries icon on the left bar of the Arduino IDE.
- Search for “SSD1306” and locate the SSD1306 library from Adafruit.
- Click the Install button to add the library.

- You will be prompted to install some additional library dependencies.
- To install all of them, click the Install All button.

- Copy the code above and open it in the Arduino IDE.
- Click the Upload button in the Arduino IDE to send the code to the ESP8266.
- Place the sensor in hot and cold water or hold it in your hand.
- Check out the results on the OLED display and the Serial Monitor.
※ NOTE THAT:
The code in question will center the text both horizontally and vertically on an OLED display.