Arduino Nano ESP32 - Control Heating Element

This tutorial provides instructions on how to use Arduino Nano ESP32 to control a Heating Element. Based on this tutorial, you will learn how to make a heating system in another tutorial.

Hardware Preparation

1×Arduino Nano ESP32
1×USB Cable Type-C
1×Relay
1×Heating Element
1×12V Power Adapter
1×(Optional) DC Power Jack
1×Breadboard
1×Jumper Wires
1×(Recommended) Screw Terminal Adapter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
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. We appreciate your support.

Overview of Heating Element

Pinout

Arduino Nano ESP32 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 Arduino Nano ESP32 and Heating Element. Arduino Nano 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 Arduino Nano ESP32 - Relay tutorial

Wiring Diagram

The wiring diagram between Arduino Nano ESP32 and Heating Element

This image is created using Fritzing. Click to enlarge image

Arduino Nano ESP32 Code

The below code repeatedly turns the Heating Element ON in five seconds and OFF in five seconds,

/* * This Arduino Nano ESP32 code was developed by newbiely.com * * This Arduino Nano ESP32 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-esp32/arduino-nano-esp32-controls-heating-element */ #define RELAY_PIN D2 // The Arduino Nano ESP32 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); }

Detailed Instructions

  • Connect Arduino Nano 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 Arduino Nano 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 Arduino Nano ESP32 code contains line-by-line explanation. Please read the comments in the code!

Video Tutorial

※ 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!