@tutorial: Homemade 220V AC Heater PID temperature control

This setup is an AC 220 volts PID control for temperature. In previous tutorials, if you remember, we have made a PID temperature control for DC voltage and a TRIAC AC voltage control. A lot of you asked me for a combination between those two videos.

External Link: https://electronoobs.com/eng_arduino_tut39.php

by: ELECTRONOOBS on 2026-08-16

So, today we will read the temperature with a thermocouple, detect the zero cross of the AC voltage, create the PID control and change the firing angle at the TRIAC gate and by that control the temperature of a 220V heater.

~Part list

1 x Arduino NANO/UNO LINK eBay

1 x MAX6675 LINK eBay

1 x K-Type thermocouple LINK eBay

1 x i2c LCD LINK eBay

1 x BTA16 TRIAC: LINK eBay

1 x MOC3020: LINK eBay

1 x 220V AC heater: LINK eBay

1 x Full-bridge rectifier: LINK eBay

1 x EL817: LINK eBay

2 x push button: LINK eBay

3 x 1k resistor: LINK eBay

2 x 47k resistor: LINK eBay

1 x 200 resistor: LINK eBay

1 x 100R resistor: LINK eBay

Wires LINK eBay


Wire, soldering iron, solder, etc...

~PART 1 - Detect the zero-cross

Ok, below you can see the 220V sine wave. As you can see it passes the same amount of time below 0V as above 0V. We need to detect the moment when the wave passes from negative to positive or vice-versa. Why? Well, after the zero-cross, if we send a firing pulse to the TRIAC, we could control the amount of the wave will pas and by that the amount of power as we will se later. So in order to be synchronized, we need to detect the zero-corss.

Implementing AC 220 volts PID control for temperature setup, combining previous DC and TRIAC AC voltage control tutorials.
Implementing AC 220 volts PID control for temperature setup, combining previous DC and TRIAC AC voltage control tutorials.

So, witha microcontroller we need to detect that zero-cross. How we do that? well we use two components and those are a full-bridge rectifier and an photocoupler. We do that because the microcontroller can't work with negative voltages and above 5V. The full-bridge rectifier will give only positive wave and the photocoupler will lower the voltage to 5Vpp. Now we could read that signal with an Arduino. See the signal below.

Implementing AC 220 volts PID control for precise temperature regulation.
Implementing AC 220 volts PID control for precise temperature regulation.

As you can see in the photo above on the 5Vpp signal, we have a los pulse each zero cros now. With the Arduino is very easy to detect that. We will see later in the code, an interruption made on digital pin D8. To read that pulse, the next scheamtic was used for the full-bridge rectifier and the photocoupler.


Implementing AC 220 volts PID control setup for precise temperature regulation.
Implementing AC 220 volts PID control setup for precise temperature regulation.
~PART 2 - Read the temperature

ow to read the thermocouple with the amplifier mdoule and the Arduino. make the connections as below.

Implementing AC 220 volts PID control for precise temperature regulation.
Implementing AC 220 volts PID control for precise temperature regulation.

Ok, see the scheamtic above. Connect the K-type Thermocouple as shown and connect the the SPI pins to D13, D10 and D9. To test the circuit, upload the enxt example code and open the serial monitor at a baud rate of 9600. Heat the thermocouple and see the resuls. Ok, now we know how to measure temperature with the K-type thermocouple. Now we have to see how to control the power applied to the AC heater using the TRIAC.


~PART 3 - Final schematic

Ok, see more about TRIAC control on the past tutorial here. Below you have the final schematic for this project. We have the rectifier and photocoupler to detect the zero-cross, then the

Implementing AC 220 volts PID control for temperature in a setup combining previous DC voltage and TRIAC AC voltage control tutorials.
Implementing AC 220 volts PID control for temperature in a setup combining previous DC voltage and TRIAC AC voltage control tutorials.

We detect the zero-cross, measure the temperature, calculate the delay of the firing pulse with the PID control and create the pulse on the "Firing_pulse" fin connected to the MOC3020 optocoupler that will apply a pulse to the TRIAC. This will control the amount of power that will pass to the AC heater as you can see in the photo below.

Implementing AC 220 volts PID control setup for precise temperature regulation.
Implementing AC 220 volts PID control setup for precise temperature regulation.

The small bit of code below is the one taht creates the small firing pulse of 100us. With the delayMicroseconds(maximum_firing_delay - PID_value); we control the delay between the zero-cross and the firing pulse and by that the amount of the wave that will pass. In the photo below the amout of wave is more or less 50%.

~PART 4 - Code

Make sure you mount the schenatic as before. Downlaod the code and uplaod it to the Arduino. Read all the comments in the code to understand more. The code is simple. Remember to install the i2c liquid crystal library and the MAX 66 75 in order to be able to compile this code.


In short words, it goes like this. The interruption on digital pin D8 will detect the zero cross of the main AC signal. Next, we create the PID value and map that from 1 microsecondsv to 7.4 milliseconds and that will be the delay between the zero-cross detection to the firing angle pulse. The rest of the code is for the push buttons read, measure the temperature and fix the setpoint with the buttons. Compile and upload.

So, there you have it. I could now set the temperature and it will stay there thanks to the PID control. The temperature sometimes has 2 or 3 degrees error but for now that is a good result. In my case, the setpoint step is 5 degrees but you could change that in the code of you want.


Implementing AC voltage PID control setup for temperature stabilization using 220 volts AC.
Implementing AC voltage PID control setup for temperature stabilization using 220 volts AC.

Leave a comment

Please login in order to comment.

Comments

ADVERTISERS
ADVERTISERS
PCBWAY