hi welcome to another tutorial from Robojax in this video I am going to show
you how we can use 4 channel solid state relay to control 4 AC load or
AC bulb using Arduino. You can get the code for this by clicking at the link
which is below the video in the description which will take you to
robojax.com/learn/arduino let's get started with this
I have to warn you that working with AC is very dangerous and soon as you connect
this you connect it to AC i do not touch this module
and also do not leave the module on a metallic surface or conductive surface
make sure it's on the plastic or non conductive material. many times you need
to control AC load and this is the best device to do that because it doesn't have contact
and you don't hear a clicks. For that reason solid state relays or prefered
the most . the amount of load that they can control is limited and this shown
here. Each can control up to 2 ampere and if your region voltage at 120V
multiply it by 2 and it would be 240 watts each SSR. if you are living in
Europe and Asia with a voltage of 220 volts or higher then 220 times 2 will
be 440 watts you can control. do not overload it otherwise
this device will die. the module as you can see this is made in Japan
and it is very high quality and they are offered in 5 volts 12 volts 24 volts. here is a
data sheet for G3MB solid state relay a thermal load that can handle is
2 amperes and they have different variation the one that I'm using is G3MB
202P and for this version we will have 5 volts 12 or 24 volts three types
all of them can handle 2 amperes at 100 to 240 volts depending on a region
I will provide this data sheet if in case if you need to read it further
the module is based on the OMRON G 3 MB solid state relay 2 0 2 P these are the
theories of 202P and this is the 5 volts version and there are 12 and 24
volts version or 15 volts and there are different variation of those on the side
of these connectors we have positive DC and then the negative this will be
connected to 5 volts of Arduino this will be connected to the ground and then
it has been labeled as channel 1 2 3 & 4 so 4 channel from Arduino will be
connected to this and all of this from here up to here. if you don't like
this type of connector you can connect this using header type
You can use this DUPONT type connector as you can see this is female
on the other side we have male so this side goes to Arduino and this site will
go and here for each relay we have one LED and the LED will indicate when this
is on this LED 1 is for the first one LED 2 is for this one LED 3 is
for this solid estate really an LED 4 if for this SS R and for each of this
and we have a circuit here that is driving it we have resistors and with
our transistor that control and turn this on and thus this makes it possible
to have a high trigger or low trigger and that so this is really that I have
is high trigger high level and it will be written here when you purchase it
from eBay or Amazon or Aliexpress make sure to purchase the right one that you
want the code that I've written will work for high level and low level
triggers so do not worry about this unless you have a specific technical
preference
let me explain the AC bulb here so this is a table light just to the wall outlet
and the wire goes and will be turned on but I've disconnected one of these two
wires here I've just cut this wire from here now this can be connected to that
relay the relay job is to just connect it so it will be on and disconnected
will be off I've just twisted them and then put some solder so this can be
inserted into connectors with a screw here if the wiring diagram that I've
drawn from this side one two three four four channels channel one goes to 2 and
then 2 goes to 3 3 goes to 4 and channel 4 goes to 5 on this side the plus goes
to 5 volts the minus goes to ground in here or you can put it in one of these
two grounds doesn't matter this is the same ground you can create your AC
bought the way that I just shown you just make make two wires for each load
and connected in here you will connect two wires for each bulb or load that you
have will be to this line this has now disconnected from easy so the two wires
that I shown you for each load will be connected to 1 SS or solid-state relay
and the other two will be here that third one will be here in the fourth one
so the channel starts from this side and here from this side I've connected this
to five volts of Arduino this has been connected to the ground and then from
here it has asserted from channel one two three and four and it has been
connected to pen two three four and five because we don't have been one that's
why I distorted from 2 to 5 and here is from wonderful if you don't like to use
this connectors with a screw use these headers and connected
let me know it fill in the code we define an array of type integers we call
it ffs art and we define the pens hairpin two three four five of digital
for the output to control s out of the state relay so if other pens are
available for this purpose you type something else between two to 13 and
Arduino Uno and other pens and it feels using Arduino mega and others devices
then we define here the trigger type if your module is high trigger type here
high if your module is low trigger type here low and everything else will be
taken care of as long as you type proper high or low
this weight is when I demonstrated I used this time to demonstrate each
channel this is not needed but you have to have it if you are running the code
with the test and we define FF our on an SSR off the solid state relay on and off
which will be used next in the code as an integer type or at high and low
inside the set up we define the serial monitor with a 9600 baud this is the
rate that the serial monitor plants information on the screen and that 9600
must match this number and the lower right corner of the screen so that we
check F trigger type this means F trigger type is high so this is one of
the shortcut or easiest way without typing equal equal high this means if
that is true if the type is high then SS are on equal high and SS are on of equal
low if the relay type that you have is low trigger then SS are on will be low
and for off Ruby high you don't worry about this I'm just
explaining it and inside this loop which goes from zero to three one less than
four we set the Pens as output and this line using pen mode as
I this I become 0 1 2 3 which we'll go and pick up this 2 3 4 & 5
this is SFI type 2 and then next time 3 4 & 5 & we set each pin as an output and
then we using this line we set all the relief off and this will just print this
text from bojack's for some of the states relate once only when we come
into the loop this is the loop and inside the loop we use control
SS our control solid state relay this is a function that I have written which is
below this code I'm going to explain it and it needs for three parameter
parameter one is number of relay so you type either 1 2 3 or 4
whichever relay you want to control and then the type of control that you want
SSR on or FFR off and after the comma you put the amount of time that you want
to keep the SSR on in this case it shows 5,000 millisecond or 5 seconds on this
code will run and will be executed for 5 seconds and this line will keep that
loop waiting after that it goes to this line and this line is turning it off
this is just for illustration purpose and you can change this to whatever you
want and change this to either on or off and set that time that you want for off
you can just even put 0 it will be off will turn it off for you but because
this is looped for your demonstration I'm putting some amount of time to keep
it off but in your application if you really need to keep it off for a certain
time put your time here but if you just want it off just put 0 that would be
enough and then this just shows a loop for us that this loop and in case if you
do a lot of lines and you want to make sure that know that all the items in the
loop have been executed so this is just for information purpose and it will be
printed after that one and the second one will be executed off and after of
this will be printed and again immediately on will be quick
as you can see so when we pass one SSR on and 5,000 this one will come and will
be called number it will become a variable called number and SSR on will
become integer type and it will become control and then this 5,000 will be
called weight and then we check if control this control if equal equal high
F which which means if you set that to on automatically the behind so you don't
worry just put a thought and capital o n it will be high then this code will be
executed if the this control request if no not high this will be recruited the
difference between the two is and here SSR on and SSR off if that is on if
you've sent on it will be on here and at least if you're sent off it will be off
and also we are printing this text does this line do is we say digital right and
SSR number minus 1 the number that you're sending here if it's one we
subtracted one because in our relay array this starts with zero zero one two
three because zero one two three is not human
friendly I've added here minus one because you have to just send one two or
three and even four but for computer we have to subtract it but do not worry
about this I'm just explaining it so this will take up the number and we set
it on so this digital right will turn on the solid state relay and the wait delay
if the amount of weight that you sent and it would keep it waiting
otherwise we use the same exact same line except as a sort of and the same
way time that you sent and that's it
now I'm demonstrating it and this is the code that 5000 Millikan on and 5,000
2000 millisecond off for this as you can see it's controlling only channel 1 and
only the LED is on the light goes on here I've changed the code it says turn
channel 2 on first and then channel 4 and then channel 1 2 seconds and turned
them all off and then go back 3 seconds and 2 seconds and 2 seconds so you can
control your solid states really like this and here now I'm using this loop
this job of this loop is to turn one two three and four one by one and then turn
off one by one as you can see this one will be on now first and then the second
third fourth which I don't have the ball and when it goes to off that this would
be turned off first and then the second one so then this LED will indicate the
sequence of on and off and here is the code I've written a loop to go one by
one loop goes from 0 to 3 and here we say sort of the state control I plus 1
we could uses human-friendly value when you are using it you will not
be using this you just type your own number so it would be easy and this line
will just says on the for loop the place and this will turn off all of them thank
you for watching this was how to use 435th delivered with arduino to control
for AC bulb or AC load if you liked this video and learn something please thumb
up please also subscribe so you you can get
updates of my upcoming videos I have many videos for solid estate and other
relays that you can control it with push button and use it with multiplexer even
16 channel 4 channel 2 and
you