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:

  1. A circuit connecting the ESP32 S3, relay module, and 12V heating element
  2. A program that cycles the heating element ON for five seconds and OFF for five seconds
  3. A foundation for real-world heating automation and temperature control systems
  4. A starting point for advanced projects like thermostats or incubators
ESP32 S3 - Controls Heating Element

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Relay
1×Heating Element
1×12V Power Adapter
1×Optionally, DC Power Jack
1×Breadboard
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
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.

ESP32 S3 Heating Element Pinout
  1. Positive (+) pin (red): Connects to the 12V positive terminal of the DC power supply
  2. 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.

The wiring diagram between ESP32 S3 Heating Element

This image is created using Fritzing. Click to enlarge image

ESP32 S3RelayHeating Element / Power Supply
GNDGND-
3.3VVCC-
GPIO (signal pin)IN-
-COM12V Power +
-NOHeating 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.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-controls-heating-element */ #define RELAY_PIN 7 // The ESP32 S3 pin connected to the heating element via the relay // The setup function runs once on reset or power-up void setup() { // initialize digital pin A5 as an output. pinMode(RELAY_PIN, OUTPUT); } // The loop function repeats indefinitely void loop() { digitalWrite(RELAY_PIN, HIGH); // turn on heating element 5 seconds delay(5000); digitalWrite(RELAY_PIN, LOW); // turn off heating element 5 seconds delay(5000); }

Code Explanation

The above ESP32 S3 code contains a line-by-line explanation. Please read the comments in the code!

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Wire the ESP32 S3, relay module, and heating element according to the wiring diagram above.
  3. Connect your ESP32 S3 to your computer using the USB Type-C cable.
  4. Launch the Arduino IDE on your computer.
  5. Select the correct ESP32 S3 board from the Tools menu.
  6. Choose the COM port your ESP32 S3 is connected to.
  7. Copy the complete code from the code section above.
  8. Paste it into a new Arduino IDE sketch window.
  9. Click the Upload button and wait for the process to complete.
  10. Observe the heating element turning on and off every 5 seconds.
  11. Carefully check for heat output (without touching the element) to verify correct operation.
  12. 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.

  1. Thermostat controller: Build a simple thermostat-controlled heating system that activates based on a temperature threshold.
  2. Pet enclosure heater: Create a temperature regulator to keep small animal or reptile enclosures warm.
  3. Plant propagation mat: Design a warming mat controller for seedling germination trays.
  4. Sous vide cooker: Make a DIY sous vide cooking temperature controller for precise water-bath cooking.
  5. Egg incubator: Develop a small-scale incubator with stable temperature control for hatching projects.
  6. 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.

  1. Beginner: Modify the code to change the ON/OFF time intervals to 10 seconds each.
  2. Beginner: Add a status LED that lights up whenever the heating element is active.
  3. Intermediate: Integrate a temperature sensor (DS18B20) to display the current temperature on the Serial Monitor.
  4. Intermediate: Create a simple thermostat that turns heating on when the temperature drops below a configurable set point.
  5. Advanced: Build a PID temperature controller for precise heating control with minimal overshoot.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!