Control Heating Element – Arduino Tutorial

5,180 views

Introduction

Interfacing a 5V SPDT relay module with an Arduino UNO microcontroller to control a DC heating element is a process of using the digital output of the Arduino to control the state of a DC heating element by switching it on or off through a relay module. The relay module acts as an electronic switch that can be controlled by the digital signal generated by the Arduino, the user can turn on or off the heating element by sending digital signals to the relay module.

An SPDT (Single Pole Double Throw) relay is used in this case, this type of relay has a single common contact and two normally open and normally closed contacts. When a digital signal is sent from the Arduino to the relay, it switches the state of the relay, which in turn switches the state of the heating element.

Hardware Components

You will require the following hardware for Control Heating Element with Arduino.

S.noComponentValueQty
1.Arduino UNO1
2.USB Cable Type A to B1
3.Relay1
4.Heating Element1
5.Power Adapter12V1
6.DC Power Jack1
7.Power Adapter for Arduino9V1
8.Jumper Wires1

Heating Element with Arduino

  1. Connect the 5V SPDT relay module to the Arduino Uno as follows:
  • VCC pin to 5V
  • IN1 pin to digital pin 2
  • GND pin to GND
  1. Connect the DC heating element to the relay module as follows:
  • Connect the positive terminal of the heating element to the NC (Normally Closed) pin of the relay
  • Connect the negative terminal of the heating element to the GND
  1. In the Arduino IDE, define the pin number for the relay in the setup function:
int relayPin = 2;
  1. In the setup function, set the relay pin as an output using the pinMode() function and initialize the serial communication using the Serial.begin() function:
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
  1. In the loop function, use the digitalWrite() function to control the state of the relay. For example, to turn on the heating element:
digitalWrite(relayPin, HIGH);
  1. To turn off the heating element:
digitalWrite(relayPin, LOW);
  1. To post the status of the heating element on the serial monitor, use the Serial.println() function:
if (digitalRead(relayPin) == HIGH) {
  Serial.println("Heating element is on");
} else {
  Serial.println("Heating element is off");
}
  1. Upload the code to the Arduino Uno and open the Serial Monitor to see the status of the heating element.

Schematic

Make connections according to the circuit diagram given below.

Wiring / Connections

ArduinoSensor
5VVCC
GNDGND
A5SIG PIN

Installing Arduino IDE

First, you need to install Arduino IDE Software from its official website Arduino. Here is a simple step-by-step guide on “How to install Arduino IDE“.

Code

Now copy the following code and upload it to Arduino IDE Software.

const int RELAY_PIN = A5;  // the Arduino pin, which connects to the IN pin of relay

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin A5 as an output.
  pinMode(RELAY_PIN, OUTPUT);
}

// the loop function runs over and over again forever
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);
}

Working Explanation

In the setup function, the Arduino’s serial communication is initialized and the relay pin is defined and set as an output pin. This is done to ensure that the relay pin is ready to receive digital signals from the microcontroller. In the loop function, the digitalWrite() function is used to control the state of the relay. This function sends a digital signal to the relay pin, which in turn switches the state of the relay, turning the heating element on or off.

The digitalRead() function is used to read the state of the relay. This function reads the digital signal from the relay pin and stores it in a variable. Then, the Serial.println() function is used to display the status of the heating element on the serial monitor. This function displays the state of the heating element on the serial monitor, whether it is on or off.

Applications

  • Temperature Control
  • Industrial Control
  • Robotics
  • Automotive
  • Medical
  • Energy Management
  • Education
  • Home Appliances
  • Environmental Control

Conclusion.

We hope you have found this Heating Element Controlling Circuit very useful. If you feel any difficulty in making it feel free to ask anything in the comment section.