hi welcome to an Arduino step-by-step course by Robojax
hi welcome to an Arduino lecture from Robojax in this lecture we are going to learn how we can
use this k-type thermocouple with max xx75 to control a load as a heater or cooler so we can
turn it on and off and keep the temperature in certain range either as a cooler or as a heater
let's get started with this
to use it as heater control or cooler control with relay to turn on and off a load and for
that reason I’m using this thermocouple and I’m using this bulb as a heater and cooler how it
works is for heater and cooler we have two different start and stop for heater
I put for heater and cooler you need to have two temperature because you cannot have a one number
for that reason I put 80 100 I put them apart because that demonstration will be easy but
for real application you might have some something very closer for example this might be 80 the start
and the stop instead of 100 it might be 85. it's up to you in the code you can change it so this is
just a demonstration so how it works for a heater because we want a heat or certain temperature
now when the temperature reaches below 80 degrees Celsius the heater control will turn on at this
point so that's why we call it 80 and our stop is set to be 100 now the heater will turn on at
the temperature and the temperature will slowly increase when it reaches 100 degrees we don't
want above that and it will turn off the heater and it will not turn on again until it reaches
80 because this is our range it will stay at this temperature when it goes below 80 it will turn on
and if you want to use it for the cooler the same way we have it but pay attention the start was on
this side now start is on this side so when the temperature reaches 100 degrees we don't want this
to heat up so the cooler or refrigerator will turn on at this temperature for example and it will
reduce the temperature slowly cool it down when it reaches at the stop temperature
in this case 80 degrees the cooler will stop below this this the cooler is not used anyways
so it is off the environment temperature will slowly increase when it reaches back to
100 degrees that could restore and again stop at 80 so we will always keep the liquid or whatever
you have and within the certain temperature range hotter environment you want to control a cooler
with the thermocouple or in a cooler environment you want to use a heater to keep the temperature
a certain level so thermocouple is one of the one of the option because it can go
depending on the type you can go up to 1000 degrees Celsius or even higher
and here is the wiring diagram for the max xx75 from this side this is connected to pin
two three four five and six so you will not make any mistake here for the relay one wire from ac
is connected to the middle one preferably this should be the life and the other wire
is connected to the bulb and from here to the bulb the right pin is connected to the ground
the metal pin is 5 volts it has been connected to 5 volts and the left pin is a signal which is
connected to pin 8 and if you if you're using this relay the wires are different the right pin is the
input has been connected to pin 8 the middle pin is ground it has been connected to the ground
and the left pin is vcc this is connected to 5 volts now let me explain the wiring for the relay
we have vcc we have ground and we have input signal from the left this is connected using
orange wire to 5 volts the middle pin is ground have been connected using red wire to the ground
and the last pin on this side is input it has been connected to pin 8 here for this k-type sensor
to max 6675 I’ve connected all these wire in order as you can see it from this side
I’m just inserting them in order here I’m inserting them from pin 2 to pin 6
like that they are in the same order for this demonstration I’m going to use this ac bulb this
is a plug that will be connected to wall outlet and the light will be turned on at the middle
at this point I have disconnected the wire one of the wire the live wire here and I’ve twisted them
and prepared them these two I will be connected to the relay job of relay is to turn it on by
connecting these two wires turning on the light and disconnecting it turning it off so this can
be a bulb or a fan or any other load the same way the relay will connect it and disconnect it
the two wire that I’ve shown you for the ac bulb is connected
to these two terminals of this relay and if you're using this really it will be
connected exactly the same way to this two last terminals in here and in here
and for this one we have here the negative this will be connected to ground this is
connected to 5 volts and this pin is the signal or the input which will be connected to pin 8.
now let me explain the code
we are defining first you need to download you should have already watched my introduction to
max x675 this is a library that must be included otherwise this will not work
and because we are using this really and this thermocouple these both need five volts and
you didn't need to use a breadboard for that reason I’m defining here
I’m defining here a pin a ground pin pen too and vcc pin pen three for the thermocouple and then
this clock cs and data out these 3.456 these are accordingly
as they appear on this so this is a ground vcc
clock c s and d o so there accordingly so we didn't make mistake in terms of wiring
and then from this class we create an object called thermocouple and we pass these
three pens here these three in here with a comma separated so we pass it to the library and library
will prepare it for usage and uh now we define a relation it if you want you can change it really
on really off is for the relay module we define this low and high so instead of low and high we
know really on what it means so we just use it and also it makes it very easy if you have
a different relief these relays are low trigger with low they will be turned on and with off
with high it will be turned off but if you release the opposite make this high and make
this low otherwise do not touch it and release it is a variable that is holding the initial state of
the relay either on or off so I put hair really off so the load will be initially off regardless
and then temperature unit here one if you want Fahrenheit or kelvin set it to two or three
and then a store temperature and stop temperature or the two values that you set
either for cooler or heater which I just explained it and then control type here is
important that we put either one or two if you put one it will be heater it will act
as a heater and if you set two it will be cooler this is a variable that is holding the temperature
inside the setup initially is a serial monitor so this can be printed
and then we print this text after that we're using pin mode relay pin we set this pin as an output
and immediately using digital right really pin we set it as release set either on and off
and then we go for the vcc pin we set this pin as an output and then immediately we set it high so
this will give us a 5 volts and then GND ground pin for the delay we set it as an output and we
set it as low so this will give us 0 or ground and then we wait 500 milliseconds for the module to
get ready inside the loop we use read temperature so this must be inside the loop every time loop
runs it goes to this function which I’m going to explain it this reads the temperature
and print temperature is a function that is printing that temperature in here
and load control is a function that needs to control the load if you
comment this that it will be turned off it will not work and here if you want to
do something with the pressure let's say if you want to check if the temperature is
greater than or equal 89.5 and you want to do something between these two carla branches curly
parentheses take the action inside this and then we have 1000 millisecond delay after one second it
reads if you want to slow it or speed it up change this if you reduce this number it will read faster
and if you increase it will read slower now relay control a load control is a function
that we check if control type is equal one we say if relay state temperature
start temperature is greater than temperature and stop temperature is also greater than temperature
then we use really control on in this case it will work for cooler but also in the same for the
heater also we check if the soft temperature is lower than temperature then we turn off the relay
this else is for the cooler so this portion acts for the cooler exactly the same
except we have just changed uh the really on and really off that is exactly the same
and then really control is a function when you send the release hit us on and off we check if
it is on we send really pin us really on so we send high to the spin or low
and depending on the type of the relay otherwise we send different one in this case this was on
we send low and this was off we send high and also this is printing the text on the serial monitor
now read temperature is a function that is from k-type sensor from a thermocouple if the unit is
equal to we get a temperature in Fahrenheit and set the temperature variable if it is 3 then it
means get the temperature add it add this value to it so it be it will be kelvin otherwise else means
otherwise it's sales so we read the Celsius temperature this is printing the temperature
this is just printing the temperature in here
and then after that this symbol and then c so we print degree this is a function that is at
the bottom of the code and here after that we just print f k or c depending on the type
if that unit is two we parent f if the unit is three we parent k else mean otherwise you
print c and then we put a new line so it goes to the next line every time it reads
and here print degree these are two hex values that makes that
this degree symbol here the circle small circle and that's the full explanation of the
code now let me demonstrate the heater control for heater control we set this to one
and in heater control pay attention to the start because we are starting
at this point because we want that we want the temperature to be a certain level or higher now
the temperature when it reaches below 80 degrees the heater will turn on the heater will stay on
until it reaches to the stop point which we set in our code to be 100 now at 100 degrees it will stop
and it will stay off until it reaches 80 degrees it will not be on here when it reaches that stop
stop is just stopping it when it reaches at 80 again it will start and the cycle will continue
now the temperature is around 60 degrees and as you can see the heater is on because it is below
this and the heater is on and it's trying to heat it up now we are using a heat gun to heat
it up to reach this 100 to see if it turns off and when it reaches back at 80 it will turn on
now let me apply heat
now at 100 degrees the heater is now turned off because we don't want any temperature above this
and it will cool down slowly until it reaches 80 degrees again it will turn on
now the heater is turned on and the cycle will continue the same way
now let me explain the cooler control we have a
store temperature of 100 degrees Celsius and stop temperature of 80.
initially the temperature increases and reaches 100 degrees the cooler will start or it will turn
on and running until it reaches 80 degrees and it will stop because below this we don't need it
then when the temperature increases this will not turn on here because the starting point is at 100
so it allows it to reach 100 and when it reaches 100 degrees then the cooler will start so you can
adjust this if you want to have a narrow control area for temperature currently it shows 62 degrees
and I think when it reaches 100 degrees it will turn on let me apply heat with this heat gun 70
so now it will reach 100 and now this is our cooler the cooler is turned on
and when the temperature reaches at 80 it will stop
now you see it is 127 degrees because it's a metal
and it when I blow it slowly it penetrated now in inside so that's why it's very hot
so at 80 it will turn off now
now the relay is off and the lure is off
and it will be off until the temperature reaches back to 100 to turn it on thank you for watching
this was how to use this thermocouple sensor as a heater or cooler control with relay and Arduino
please give me a feedback on my course by writing a review it's really appreciated thank you
please make sure to subscribe by clicking at the subscribe button in here thank you
thank you for watching tutorial from Robojax if you learned something and found this useful
please thumb up as this will help my video in the search algorithm of YouTube
if you have comment or question please post it at the comment section below I try to
answer and reply and don't forget subscribe so you get updates on my upcoming videos you