Project Overview
I’ve been recently tasked with an interesting project of temperature controlled heater pads, so I designed the whole automation using ATMega microcontroller and relays. The datasheet for the heater mats states that they are 240V and 250W, so we can calculate current of 1.04A and find something that will handle the load.
I’ve decided to use DC 5V 240V Relay Shield Module that can take up to 10A loads. For the purpose of this experiment, I’ve used 2 channel setup, but it could be easily expanded infinitely.
Yizhet 5V 2 Channel-Relay DC 5V 230V Relay Shield Module
I’ll be using DHT11 temperature sensor to read the environment temperature. It also offer humidity readings. The datasheet states that data sampling rate is 2 seconds, which is good enough for the job.
DHT11 Digital Temperature Humidity Sensor
It’s a good idea to use some kind of indication of the current status of the outputs and the temperature for the user. LCD1602 screen will be sufficient to do just that. Additional potentiometer is wired into pin 3 to allow for brightness adjustments.
Total costs of the parts is approximate £50 for 6 relay setup, not including any form of enclosure. In real life scenario, this prototype would be soldered onto custom PCB board.
Schematics
Wiring Overview
Code
The logic is fairly simple. When the temperature of the environment drops below 10°C, bank of relays is activated allowing for 240V supply to power the heater pads.
// 2021 Spawn
// UNO R3
// 240V Heatpad control using DHT11 temperature sensor
// Pin 8 = relay signal
include <dht.h>
include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
dht DHT;
define DHT11_PIN 7
define HEAT_PIN 8
void setup(){
lcd.begin(16, 2);
pinMode(8, OUTPUT);
}
void loop(){
int chk = DHT.read11(DHT11_PIN);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(DHT.temperature-2);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
digitalWrite(8, HIGH);
lcd.print("Heat pads: Off ");
if (DHT.temperature < 10) {
lcd.setCursor(0,1);
digitalWrite(8, LOW);
lcd.print("Heat pads: On ");
} else {
lcd.setCursor(0,1);
digitalWrite(8, HIGH);
lcd.print("Heat pads: Off ");
}
delay(5000);
}
Demonstration
For the purpose of the demonstration, the logic is changed to repeatedly change pin 8 signal (relay control) to on and off every 5 seconds as it’s difficult to test the real life scenario with temperatures lower than 10°C, although the code above is fully functional with this feature.