ESP32 S3 - Control Heating Element
Learn how to control a heating element with your ESP32 S3 microcontroller using a relay module. This beginner-friendly tutorial gives you everything you need to start building heating control projects with ESP32 S3.
What you'll build:
- A circuit connecting the ESP32 S3, relay module, and 12V heating element
- A program that cycles the heating element ON for five seconds and OFF for five seconds
- A foundation for real-world heating automation and temperature control systems
- A starting point for advanced projects like thermostats or incubators

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 .
Overview of Heating Element
A heating element is an electrical component that converts electrical energy into heat when current passes through it. It operates on a 12V DC power supply and is commonly used in warming, drying, and temperature control applications. Because the ESP32 S3 outputs only 3.3V logic signals, a relay module is required to safely switch the 12V heating circuit on and off.
Key Specifications
The heating element runs on a 12V DC power supply, generating heat as current flows through its resistive material. It connects to its power source via two terminals — a positive (+) pin marked in red and a negative (−) pin marked in black. Control is handled indirectly through a relay, which acts as an electronically operated switch between the power supply and the element, allowing the low-power ESP32 S3 to safely manage high-power loads.
Pinout
The heating element uses a simple two-wire interface for power connection.

- Positive (+) pin (red): Connects to the 12V positive terminal of the DC power supply
- Negative (−) pin (black): Connects to the GND negative terminal of the DC power supply
How to Control Heating Element
The ESP32 S3 controls the heating element indirectly through a relay module. The ESP32 S3 cannot directly power 12V heating elements — a relay acts as an electronic switch between the power supply and the heating element, responding to digital HIGH/LOW signals from the ESP32 S3. This allows safe, reliable control of high-power devices using the low-power output of the microcontroller.
Important: If you are new to relays, check out our ESP32 S3 - Relay tutorial first to understand pinout, wiring, and programming basics.
Wiring Diagram
Connect your ESP32 S3, relay module, and heating element carefully, following the diagram below. Ensure all connections are secure before applying power to avoid short circuits or accidental contact with the heating element.
WARNING
Please be careful. It can burn you and your house. This is a serious topic, and we want you to be safe. If you're NOT 100% sure what you are doing, do yourself a favor and don't touch anything. Ask someone who knows! We do NOT take any responsibility for your safety.

This image is created using Fritzing. Click to enlarge image
| ESP32 S3 | Relay | Heating Element / Power Supply |
|---|---|---|
| GND | GND | - |
| 3.3V | VCC | - |
| GPIO (signal pin) | IN | - |
| - | COM | 12V Power + |
| - | NO | Heating Element + (positive) |
| - | - | Heating Element − to 12V Power GND |
Safety Notes
Always double-check all connections before applying power, and never touch the heating element while it is powered on — it reaches temperatures that can cause serious burns. Ensure the work area has proper ventilation during operation, use wire gauge appropriate for 12V current loads, and keep all flammable materials well away from the heating element at all times.
ESP32 S3 Code
The following code demonstrates basic heating element control using the ESP32 S3. It configures a digital output pin connected to the relay, then continuously cycles the heating element ON for five seconds and OFF for five seconds, providing a clear foundation for more advanced temperature control projects.
Code Explanation
The above ESP32 S3 code contains a line-by-line explanation. Please read the comments in the code!
Detailed Instructions
- New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
- Wire the ESP32 S3, relay module, and heating element according to the wiring diagram above.
- Connect your ESP32 S3 to your computer using the USB Type-C cable.
- Launch the Arduino IDE on your computer.
- Select the correct ESP32 S3 board from the Tools menu.
- Choose the COM port your ESP32 S3 is connected to.
- Copy the complete code from the code section above.
- Paste it into a new Arduino IDE sketch window.
- Click the Upload button and wait for the process to complete.
- Observe the heating element turning on and off every 5 seconds.
- Carefully check for heat output (without touching the element) to verify correct operation.
- Pro Tip: Start with short ON times during initial testing to confirm your wiring is correct before running longer heating cycles.
Application Ideas
The ESP32 S3 heating element control setup serves as a solid foundation for a wide range of heating automation projects.
- Thermostat controller: Build a simple thermostat-controlled heating system that activates based on a temperature threshold.
- Pet enclosure heater: Create a temperature regulator to keep small animal or reptile enclosures warm.
- Plant propagation mat: Design a warming mat controller for seedling germination trays.
- Sous vide cooker: Make a DIY sous vide cooking temperature controller for precise water-bath cooking.
- Egg incubator: Develop a small-scale incubator with stable temperature control for hatching projects.
- Drying cabinet: Build a drying cabinet with automated heating cycles for food, herbs, or electronics components.
Video Tutorial
Watch the step-by-step video walkthrough for this ESP32 S3 project below.
...VIDEO /videos/tutorial/KITS_ESP_HEATING_ELEMENT.mp4
...VIDEO
Challenge Yourself
These progressive challenges will help you deepen your understanding of heating control and build more capable projects with the ESP32 S3.
- Beginner: Modify the code to change the ON/OFF time intervals to 10 seconds each.
- Beginner: Add a status LED that lights up whenever the heating element is active.
- Intermediate: Integrate a temperature sensor (DS18B20) to display the current temperature on the Serial Monitor.
- Intermediate: Create a simple thermostat that turns heating on when the temperature drops below a configurable set point.
- Advanced: Build a PID temperature controller for precise heating control with minimal overshoot.