Introduction: Building a Four Channel SolidState Relay

Picture of Building a Four Channel SolidState Relay

For an Arduino project I needed to switch 4 mains devices.
I am always deliberating wether to use a mechanical relay or a solidstate relay.
Solidstate relays used to be relatively expensive, and thus people constructed them from opto couplers and triacs, but there are some cheap SSR chips available. One of my favorites is the 39MF22 that is available for  1.80 euro. So I made a choice to build a solid state relay for my project.
I have to add though that a four channel relay board, ready made, is also not that expensive. So, before you build my solid state relay you may want to check out these options: or even cheaper: . In fact, these may even be slightly less expensive than the Solid state relay board I will be describing here.

Bill of materials:
4x 39MF22 from e.g. dickbest  I believe it can switch 900 mA which is sufficient for most of my applications You could also use PR26MF12. It is pin compatible and switches 600 mA
4x 8 pins dil IC holder
4x LED in color of choice
4x 330 Ohm resistors
4x 2 pins screwconnector
1x 5 pins female header
1x 5 pins male header 90degrees
1x Tic-Tac peppermint dispenser The bigger one: 8.5x2x5 cm
1x piece of PCB 6x4.6 cm

For a snubber:
1x 100 Ohm resistor
1x 100 nF 600 V resistor

OK Stop right here. This circuit is meant to switch AC loads of  110 or 220 Volt. These voltages can and will kill you, so be careful and if you do not feel confident you know what you are doing, you should only use this for low AC voltage loads.

Also, as said, this circuit is for switching AC, it is not for DC. for switching DC a HCT4066 should be considered (depending on the load to be switched)  or a mechanical relay

Step 1: Building a Four Channel SolidState Relay: the Circuit

Picture of Building a Four Channel SolidState Relay: the Circuit

The circuit is fairly easy the output from an arduino or other microprocessor is fed to the 39MF22 via a resistor and an LED that will light when the relay is activated.
The 330 Ohm resistor limits the current to the 39MF22 from a 5Volt output. If a higher output voltage is used, recalculate the value.
In calculating the resistor value for other voltages, take the following in consideration: The 39MF22 has forward voltage of 1.2 Volts. Current should be between 5 and 20 mA. Most green or red LED's have a forward voltage of 2 Volts. Therefore the value of R should be at least (Vcc-3.2)/20  (gives value in kOhm) and at most (Vcc-3.2)/5  (gives value in kOhm).
So for 5 Volts this would be 1.8/20=90 Ohm  till 1.8/5=360 Ohm

This table will save you calculating the value of R2:
Voltage Minimal value Max value
5            90                      360
6          140                     560
7          190                      760
8          240                      960
9          290                    1160
10        340                    1360
11        390                    1560
12        440                    1760
13        490                    1960
14       540                     2160
15       590                     2360
16       640                     2560
17       690                     2760
18       740                     2960
Values in Ohms. Just chose one sort of in the middle of the range for your voltage.

The circuit only shows one channel so you will have to build this 4 times.

Step 2: Building a Four Channel SolidState Relay: the PCB

Picture of Building a Four Channel SolidState Relay: the PCB

The PCB is quite easy. I have included the lay-out for download here. The file is a pdf file in the right size for the so called 'heat transfer method'.
You will find an extensive instruction on how that works in another tutorial here.
If you make your own PCB, make sure to leave some copper around pins 1 3 and 4 as that helps in cooling.
Mounting the board with components is pretty self explanatory, just watch the polarity of the LED.

At the left side of the PCB there is a 5 pin female header: 1 ground pin and 4 signal pins.
I attach to that using a 90 degree angled male header. Angled because I have put the entire board in a small plastic box that will not allow a straight header.

At the right side are the 4 AC mains switches. These function just like regular switches so they must be in series with the load one wants to switch.

The snubber network (the 100 ohm resistor and the 100nF in series) is not found on the PCB. These are connected over the switch contact of the SSR where it connects to the load. 

An informative website on SSR's can be found here.

Step 3: Building a Four Channel SolidState Relay: the Box

Picture of Building a Four Channel SolidState Relay: the Box

I have used a large Tic-Tac peppermint box to encase the pcb. It measures 8.5x2x5 cm and the PCB fits nice and snug.
The signal cable is coming in through a hole at the left. The mains AC switcg cables come in through a hole at the right.
Once you are completely satisfied with its workings one could seal one or both holes with either hot glue or silicone around the wires


mateusz.pieta.35 (author)2016-07-07

is it possible to use it withoud LED`s ? what resistor should i use then ?

sure. use a 470-560 ohm

thats what i thought so ! thanks ! :)

i have ordered AQH3223 which seems to be capable of 1.2A load :)

I think the solid state relay that I use can take 50mA so there is some leeway.
Your AQH also has a nominal 50mA forward current.
You may however encounter another problem as the AQH3223 has a forward voltage of 6 Volts, so that makes my advice on the resistors completely useless and your Arduino might be barely suitable to drive the AQH Led and if it does, the Arduinoport might get overloaded

Hmm, where did you find that 6v forward voltage ? Datasheet say it is 1.21 to max 1.3v. Or am i wrong ?

just one more remark about the AQH3223 it is non-zero cross. That is not a huge problem but it may give a bit more disturbance on the mains line.
However... you can use it to dim a light then if you add a seperate zerocross detector.
The 3213 would have been a zerocross ssri


Thanks for a quick reply.

Correct me if im wrong, but according to AQH3223 max INPUT is 6v. so i should be able to drive it straight from lets say arduino output without LED in the middle, without even using any resistor ? 3223 should take as much current as it needs, right ?

Well I have to correct you coz you are wrong. :-)
Ofcourse you dont need the series LED. I only put that in there to see if the channel was on, but you do need a series resistor. The nominal trigger current of the AQH3223 is 10mA, but recommended is 20mA. The forward Voltage is 1.18 Volt
If you connect it straight to an Arduinopin you will fry your Arduino as you have no control over the current. As the Arduino will give 5 volt and the forward voltage is 1.18 you have 5-1.18 =3.82Volt that has to drop over a resistor at 20mA so that resistor needs to be 3820/20=191 Ohm. Use a 200 ohm resistor

I am wrong. I looked in the max ratings. Apologies

Hello Again,

Do you know what is the current draw of 39MF22 ?

do you mean the maximum current it can process? that is in the datasheet too. it is 900mA. Primary it is 50mA.
However, with 900mA it needs decent heatsink. Usually that is a coppersurface on the pcb, soldered to all 3 kathodes

Well actually im thinking how much current do i need to drive it .

Im using PCF8574 Expander and it can deliver up to 20mA per channel with total 100mA for all of them at the same time.

Let say like regular relay takes 80mA to drive coil - then i would need transistor for ich output to drive relay

I would really like to avoid transistors and use expanders only, but the question is how much current does 39MF22 take to operate

the 39MF22 has a max input current of 50mA. However you dont need to use that much. In the configuration that I use I have yellow LEDs those have a forward voltage of 2Volt. So from the 3 Volt left there is a current of 3000/330=9mA driving it succesfully. Your 20mA/channel therefore is more than enough

ShrutiM5 (author)2016-04-19


How many devices (say, ceiling fans) can a single channel Solid State Relay control?

diy_bloke (author)ShrutiM52016-04-19

Hi Shruti, that depends on the solidstate relay used and the wattage of the devices.
The 39MF22 can take 900mA so if your total load stays below that current you are fine. So at 230 Volts that would be a total Wattage of 207 Watt. A Ceiling fan is usually between 25 and 75 Watts. So I guess it would be safe to switch two.

If you want to switch a higher load, you either have to use a more capable SSR or start using a TRIAC, coz that is usually less pricy than a heavy SSR.
Also consider just using a mechanical relay

ShrutiM5 (author)diy_bloke2016-04-19

Hi, Thank you! Will check the specs. But just as a general question,
If I have to control about 4 fans in a small room.. and I buy a Ready to use relay is this one that I have been looking at okay?

or this, with an opto-coupler

Can it control speed of say, 4 fans minimum?

diy_bloke (author)ShrutiM52016-04-19

The OMRON G3MB can switch 2 ampere so in total that is 440 Watt. So as long as the total of your 4 fans doesnt go beyond 440 Watt (Which it probably wont) it should be OK. I do not know the OMRON well enough to know if it needs a heatsink for full power. But then again, you have two of those on a board so in total you can switch 880 Watt. So if you switch 2 fans per channel, I dont really foresee any problems.
Still, for any inductive load i probably would choose a mechanical relay

If you ask me, both links are the same, just a big difference in price

ShrutiM5 (author)diy_bloke2016-04-20

Thank you for your help!

diy_bloke (author)ShrutiM52016-04-20

my pleasure

fruityfred made it! (author)2015-11-11

Works like a charm, thank you so much for this tutorial!

diy_bloke (author)fruityfred2015-11-12

my pleasure. thanks for your picture

mahadevan (author)2014-10-15


Thanks for the fast reply.

Earlier I have seen you dimmer circuit and I asked PWM question as components are lesser. Actually I need 4 simple tube lights where there is no need of PWM(copper chokes -- which could be inductive while tubelight starting) and 1 fan (here PWM is neede). So I will club this circuit with your other dimmer circuit.

Do you have eagle-scheamtics/board documents? If so, I can customize them for 4 simple SSR and 1 dimmer for PWM control.

Thanks & regards,


diy_bloke (author)mahadevan2014-10-17

yes i remember :-)
I made this in Fritzing. I prefer that one over eagle :-)

But as you can see in step 2 it is a very easy lay-out. should take you 5-10 minutes in eagle to set that up

mahadevan (author)diy_bloke2014-10-19


Thanks for your kind advice. It seems that I can't get (39MF22, PR26MF12, S26MD02 ) in India. So I am planning to use following SSR (PANASONIC ELECTRIC WORKS - AQH3223AJ - SSR, 600V, 1.2A) . Link is

Can I use AQH3223AJ as replacement ?

It seems AQH3223AJ is having random-fire-crossing (as opposed to zero-cross-firing in SSR mentioned by you). So will it be OK to use this part?

As AQH3223AJ support random-cross-firing, can I use it for Fan-Control (inductive load)?

Thanks & regards,


mahadevan (author)mahadevan2014-10-19

Small correction:

I do get 39MF22, PR26MF12, S26MD02 from element14 in India, but I can buy AQH3223AJ for 1.5$ :)

diy_bloke (author)mahadevan2014-10-20

you can use that one as a replacement, but i doubt if the pins would be compatibel so u may have to change your lay out. Yet, if it has random firing be prepared for a lot more spikes on your mains line and i would advise a good filter. Yes can use it for a fan... but use a good filter
Only reason i used the 39mf22 was because it was relatively cheap

mahadevan (author)diy_bloke2014-10-20


Thanks for the reply.

I will ensure in my circuit about the pin compatibility. Thank you very much for your suggestion.

I would like to use the filter, but I am not sure how the circuit looks like with filter. If you don't mind, would you please let me know how a good-filter can be incorporated . You can write here or send an email to me at sgorti at.the.rate with the values for LRC components for the good filter. Maximum Resistive/Inductance load would be less than 100W @220/240V with 50Hz.

Thanks & regards,


mahadevan (author)2014-10-15


Thanks for great circuit & detailed description.

What is equivalent for 39MF22? Can I use S26MD02 as replacement for 220V AC?

Where should I put Snubber (R and C) components? Should they be connected (line or neutral) ? Please let me know.

Can I use this to load tube lights with copper-chokes and electronic chokes with < 60W?

Can I use this to PWM control for fans ( < 60W )?

To reduce accidental shortage on AC lines, can I apply glue on AC lines to avoid short circuits ( Question is any heat transfer area need to be kept for AC side of SSR or not ).

Thanks in advance,


diy_bloke (author)mahadevan2014-10-15

in principle every ssr can be used that is suitable for the load you want to switch. I have chosen the 39mf22 because it was very cheap, but the S26MD02 is certaily useable. It has a different pin lay out though.
A snubber is usually not strictly necessary with a pure Ohmian resistance but if you want to switch a motor i would recommend it.. Usually the snubber is put over the poles of the TRIAC, in this case pin 8 and 6, but one can also try put them over the connections of the load.

I have not tried it myself but I think one could switch a tube light with this.
It is not suitable for PWM control. the reason for that is that the 39mf22 has a built in zerocrossing control. Therefore when you send your pwm signal, it will still wait for the next zerocross and thus screw up your timing.
If it didn't have a zerocross you would still be in the dark because your pwm signal will then switch on the SSR in random phases of the AC cycle and thus may sometimes send full peak and sometimes send 0 volt.
If you want to do kindoff a pwm with AC you have two options: edge/phase cutting or pulse skip modulation. Both techniques are possible with the circuit in this link:

Once you connected your AC lines there is no problem putting some glue on them/in between them.

Good luck

gsandhu2 (author)2014-06-25

I’m working on a project which is about making a rescue
robot . I have struggling with it for 4 months and now all the mechanical works
had been done . but I’m facing difficulty in make the robot to work with rf
module can u plzz help me…

I want make transmitter and receiver that can control the
motion…I mean that receiver should have control 8 dc gear motor and each dc
motor should have a forward and backward botton to control the motion ……can u
kindly help me with this project ….if u can make the circuit board diagram for
the PCB ….or any other suggestion plz reply……mail me at “”

diy_bloke (author)gsandhu22014-06-26

synny, it is kind off a far cry from having questions on a 4 channel solid state relay and designing and building an rf controlled 8 dc back and forth motor project.
I dont want to be unfriendly but you are asking something here. Anyway, as I do not know your platform at all, I will make some suggestions what you can do.
RF transceiver modules can be picked up from for just a few euro's and can easily be controlled by a microprocessor. Presuming you are using a microcontroller in your robot, you can buy again for a few euro, a 2 or 4 channel motordriver from in which you can reverse polarity. you need either 4 or 2. hook these up to a pin of the microprocessor and you can control direction. If you also need to control speed you need 2 pins per motor.

Hook up the receiver and let your program take actionon the motors according to what you send.
Attach the transmitter to another microprocessor, or just to buttons, depending on how sophisticated you want to make it and off u go.

Amother possibility is to buy a ready made transceiver set like for model planes, with the amount of channels you need

Good luck

tiger5248 (author)2013-12-05

I looked up the data sheet for the DIP used here (39MF22). My question is can this really switch 120+ low current voltage? I simply don't see that in the data sheet, but I could be wrong. I would like to use this circuit to switch christmas lights that I am working on. Do you think this will work with one strand of normal christmas lights?

diy_bloke (author)tiger52482013-12-05

Though I cannot try it myself as i have no 120 Volts, I see no reason why it should not. The low current should not make a difference

Ben J (author)2012-10-28

I built your relay design into an Arduino circuit, but the relays don't seem to be working like SPST switches, like I expected (there is no continuity between pin 6 and 8 when the relay is activated).

Please forgive me, as I know very little about electronics - I simply cobbled together a few circuit designs I've come across (5V regulator, Arduino, MIDI input, and your relay design).

diy_bloke (author)Ben J2012-11-03

Ben, sorry for my late reply, I did not see your question come in. Well the 39MF22 is not exactly a single-pole, single-throw switch it is a solid state relay and the switching takes place with a triac.
When you say that thereis no continuity between pin 6 and 8 I get the impression that you just measured that with a multimeter and that will not give proper results.
You really need to see pin 6 and 8 as the poles of a AC current swith. Have you actually tried to swith an AC load with it?
Your picture looked impressive :-) even though i could not really see what was on it because of the burning LED's. Anyway, let me know what you are trying to switch and wether that is an AC load or a DC load

Ben J (author)diy_bloke2012-11-03

Thanks for the reply! :)

Yes, the LEDs are probably a bit too bright, especially that green power indicator.

The relay section will be connected to 1/4" TRS cables for switching channels on a guitar amp - thus, very small current. I'm a bit too gun-shy to do anything with AC at this point; I think I'm a bit of a novice to attempt anything as dangerous as that.

I could've used mechanical relays, but I was attracted to the smaller form factor of SSRs, as I'm trying to make the board as reasonably small as possible, so as to fit into a specific-sized hammond enclosure.

I'm learning things as I go along, and I was pleased with how things turned out, even though it's only a semi-functional circuit. That said, I'm glad that parts and DIY PCB fabrication are as cheap as they are. :)

diy_bloke (author)Ben J2012-11-03

I doubt if the channels on a guitar amp can be switched by a solid state relay, so that is where your problem lies. You do however now have a midi controlled lamp switch :-)
If you do not want to use small relays, use the 4066 (either a HEF4066 or a HCT4066) that is a bidirectional switch (4 per IC I think) that can be controlled with an enable pin

diy_bloke (author)diy_bloke2012-11-03

a HCT4066 costs about 0.25 euro and has 4 channels so that is cheaper than the 4 x 39MF22 (4x1.80) and probably smaller as well

diy_bloke (author)diy_bloke2012-11-03

If you are indeed switching DC then the 39MF22 is not suitable for that. It is better then to use e.g. a HEF 4066 if the current is not too big or otherwise a small reed relay

mikeatboduel (author)2012-10-07

Farnell has the PR39MF51NSZF SSR for just over a £ in the UK.

The datasheet suggests that you might have problems with inductive loads (motors, solenoids) if the voltage rate of change on switching is high (< 100v per us) and suggests in that case a snubber (R and C in parallel) between pins 6 and 8 - they suggest starting values of 0.022uF and 47ohms - what works will vary with the type of load.

So if anyone has problems with erratic switching of motors, etc, they might want to experiment with different values of R and C between those pins.

That should have been "( > 100v per microsecond)", of course.

diy_bloke (author)mikeatboduel2012-10-07

Thanks Mikeatboduel. Netherlands is not the cheapest country where electronics parts (and many other things) are concerned. 1.80 euro's is about 1.45 pounds.

You are right with regard to the datasheet and switching inductive loads is the very reason why i always hesitate vetween a mechanical relay and an SSR. In another tutorial in which I use the 39MF22 I think I indicated use of a snubber network (100R/100nF). I think though it might be better to have that directly over the contacts of the inductive load. E.g. in a socket where it plugs in.

Having said that. I have been using the 39MF22 for some time already to switch pumps and that has not given any problems yet.

diy_bloke (author)diy_bloke2012-10-07

Let me just add that the 39MF22 is suitable for currents up to 900mA. The max load I have been switching with it was 100 wats and the max inductive load might have been 20 wats and that goes very well. If you'd want to switch a 198 wats (the max) inductive load, I would definitely use a snubber and probably a fuse as well, probably even choose a different relay.

About This Instructable




Bio: I am a physician by trade. After a career in the pharmeceutical world I decided to take it a bit slower and do things I ... More »
More by diy_bloke:Working With the Funduino W5100 Ethernet Module.Uploading Data to ThingSpeak With MQTTAdding an MCP23017 I/O Extender to Arduino or ESP8266
Add instructable to: