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.no | Component | Value | Qty |
---|---|---|---|
1. | Arduino UNO | – | 1 |
2. | USB Cable Type A to B | – | 1 |
3. | Relay | – | 1 |
4. | Heating Element | – | 1 |
5. | Power Adapter | 12V | 1 |
6. | DC Power Jack | – | 1 |
7. | Power Adapter for Arduino | 9V | 1 |
8. | Jumper Wires | – | 1 |
Heating Element with Arduino
- 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
- 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
- In the Arduino IDE, define the pin number for the relay in the setup function:
int relayPin = 2;
- In the setup function, set the relay pin as an output using the
pinMode()
function and initialize the serial communication using theSerial.begin()
function:
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
- 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);
- To turn off the heating element:
digitalWrite(relayPin, LOW);
- 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");
}
- 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
Arduino | Sensor |
---|---|
5V | VCC |
GND | GND |
A5 | SIG 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.