ESP32 - Control Heating Element
This tutorial instructs you how to use ESP32 to control a Heating Element. Based on this tutorial, you will learn how to make a heating system in another tutorial.
Hardware Used In This Tutorial
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Introduction to Heating Element
Pinout
Heating Element usually has two pins:
- Positive (+) pin (red): needs to be connected to 12V of DC power supply
- Negative (-) pin (black): needs to be connected to GND of DC power supply
How to Control Heating Element
If 12V Heating Element is powered by 12V power supply, it emits heat. To control a Heating Element, we need to use a relay in between ESP32 and Heating Element. ESP32 can control the Heating Element via the relay. If you do not know about relay (pinout, how it works, how to program ...), learn about relay in the ESP32 - Relay tutorial
Wiring Diagram
- How to connect ESP32 and controls heating element using breadboard (powered via USB cable)
This image is created using Fritzing. Click to enlarge image
- How to connect ESP32 and controls heating element using breadboard (powered via Vin pin)
This image is created using Fritzing. Click to enlarge image
- How to connect ESP32 and controls heating element using screw terminal block breakout board (powered via USB cable)
- How to connect ESP32 and controls heating element using screw terminal block breakout board (powered via Vin pin)
If you're unfamiliar with how to supply power to the ESP32 and other components, you can find guidance in the following tutorial: How to Power ESP32.
ESP32 Code
The below code repeatedly turns the Heating Element ON in five seconds and OFF in five seconds,
Quick Instructions
- Connect ESP32 to PC via USB cable
- Open Arduino IDE, select the right board and port
- Copy the above code and paste it to Arduino IDE
- Compile and upload code to ESP32 board by clicking Upload button on Arduino IDE
- Check the Heating Element's temperature
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.
Code Explanation
The above ESP32 code contains line-by-line explanation. Please read the comments in the code!
Video Tutorial
Making video is a time-consuming work. If the video tutorial is necessary for your learning, please let us know by subscribing to our YouTube channel , If the demand for video is high, we will make the video tutorial.