hi welcome to an Arduino step-by-step course by Robojax
hi welcome to another lecture from objects in this lecture we are going to learn how
to display the object and ambient temperature measure touchless with this malaxis mlx 90614
infrared temperature sensor we're going to display it on the smaller screen
with four line or with the two line let's get started with this
I have separate video explaining this mlx module with the data sheet and full explanation this
video I’m not going to go through that in this video we're going directly to showing
you how to display the temperature on the screen currently this is the 2004 which has 20 characters
and four lines and it can display the object and ambient temperature at the same time you
can set the unit from the code there to display as Fahrenheit or kelvin whichever you prefer
or using this lcd 1604 with 16 characters and two line where you can see now it shows the object
and the ambient and also if you want it can continuously showing and kelvin
and Fahrenheit a separate video explaining their cd how to use this and full detail and
explanation a separate video for that make sure to watch that video and also make sure that you
are able to display some text on it before coming to this video and also make sure to
watch and run the introduction video so you are able to measure the temperature touchless and
display it on the serial monitor and then come to this otherwise you might have some
issue and you don't know where the problem I’ll provide you two codes one would be for this module
so it can display on the same time object and ambient temperature for the selected value either
Celsius Fahrenheit or kelvin and the code that will display let's say for Celsius
object and ambient at just root it and if you select Fahrenheit you can do Fahrenheit or kelvin
now let me explain the wiring for the module I’m going to show you to this
to use it with the display using the same Arduino and the module because this works
with the 3.3 volts here from this side from the module this is vcc it has been connected
to 3.3 volts the next pin is ground it has been connected to ground of Arduino and then this is
scl and sda white and black have been connected here to scl and sda
and for the lcd this is ground ground have been connected here to ground of Arduino the next one
is vcc it has been connected using red wire to this five volts of Arduino then orange is
sda it has been connected here to a4 and last one is scl clock pin it has been connected to a5
if for some reason you need to connect multiple of different devices with I square c
put two wires from here to a breadboard and connect everything parallel to the same pin you
can connect up to 128 devices if you're using this module this is exactly the same the same
pin as this one so there is no difference between the two here is the wiring diagram for the module
vn is connected to 3.3 volts ground is connected here to this ground or we have extra ground here
scl is connected to the last pin which is labeled as scl and then
sda is connected to the next one from the last for this module ground is connected
here to the ground vcc is connected using red wire to 5 volts sda is connected to analog 4
scl is connected to analog 5. or you can connect it to breadboard and from breadboard connected
to the sensor and to the module doesn't matter because on the same line you can connect up to
128 different devices so you can correct them all in parallel that's okay
now let me explain the code you should have already watched the introduction video to this
you should avoid the introduction video to the module and introduction video to this one because
you should have already installed the library this line is the library for the
mlx 90614 temperature sensor and we are creating a character oh
this is the object and this is ambient these are the text that is displayed
on the on the screen here if you want to change it and put something else
according to your language you can do so here but make sure to keep the
double quotation and then from this class we create an object called mlx
with this constructor and this is a inclusion of the lcd library this is the address for the
lcd which I have explained it before the number of characters a number of lines and from this library
we are we have created this object passing these three values here with a comma so the cd will
work this is initializing the serial monitor this is just printing it on the screen we initialize
the wire begin which is needed for ice currency communication this is initializing the lcd this is
controlling the backlight this is printing the first line text this goes to character 0 of line 1
which moves to the next line in here and then it prints infrared temperature
and waits for two seconds and then this is clearing the screen starting from this row
starting from zero to the end of the character so this because we have defined it at the top of the
code inside the loop if you want to print the temperature in Celsius just put this print and
that's a single code c this will print it on the screen and it waits for two seconds
because we have two seconds after that we print d after c the next letter is d so this is object and
the next letter is the ambient sometimes people need ambient temperature so it prints it and wait
for two seconds and if you want Fahrenheit inside the single could put Fahrenheit wait for 2 seconds
so it will display it if you want to delete it just remove it will not be displayed and after
f we have g so this is the ambient in Fahrenheit this was Celsius and ambient and Celsius because
the next letter was intuitive I used that and the same way we have kelvin and next letter after
k was l this is ambient in kelvin so this will display if you want to take some action based on
temperature get temperature let's say Celsius and if the temperature is above 40 you want to take
some action do the action between this opening and closing curly parenthesis that will happen in here
the temperature has been explained in my initial videos introduction I’m not going through that
watch that video it has been explained there and then print temperature this line
clears line one from zero to the maximum all line this is clearing the previous values
and this gives the temperature whatever type you pass if it was c it will get c f k whatever
unit so it gets the value and the source is a variable called tmp and then this sets the cursor
character 0 line 1 line 1 and if the request c type is equal c Celsius then it gets the name type
name like zero that's the first name which is the object so this is getting the text from this array
here from this array 0 means this and 1 means this portion
so it prints it and it press a space if I show you here you will see that it prints this
if I show you here this is a text and this is a space and then print the temperature
and then after printing the temperature we print the Celsius the degree symbol this round symbol of
degree so 223 of type character will print at that and then we print the c after that
because this is temperature in Celsius this is the ambient for the Celsius we print this
one which is the word ambient with space and then temperature and then the sample and then
Celsius the same way we do Fahrenheit print Fahrenheit and this is a Fahrenheit for ambient
this is in kelvin the temperature and kelvin for ambient
this function clear character receives the row which is either one two three or four whatever you
have and we have start and n end which is stop so this goes with a for loop goes from start to stop
one two three up to fifteen and every time it goes I changes zero one two three up to fifteen it goes
to that character and rho which we have if we have row one and this is let's say two it goes to one
character two row one and sets the cursor and then prints this two five four means blank so it clears
that character it goes to clear the next character so one by one it clears all the characters
and that was a full explanation of the code
now let me demonstrate it shows now the temperature in kelvin Fahrenheit Celsius
for ambient and for the object and this value that you have you might not need it so
let me change the code so you can get only Celsius this line it says Celsius this is c the d is also
Celsius for the ambient I’m gonna comment this the rest out by selecting them like that and then
right click comment when I click comment it will add these forward slash and let me upload it code
is uploaded it shows infrared and now it shows in Celsius for object and ambient and it just
rotates and it does the same thing so you can do the same way for
Fahrenheit or other units or kelvin if you want and here it now shows my body temperature 31.95
and let me get closer
thirty three point five seven that's immediate let me just hold it 33
now 33.6 33.57 so it's very steady and let me point it to the surface
so object is 26 degrees and ambient is 28 so this surface is maybe cooler
because I was touching it uploading the code
I have separate code for this so I don't have to modify the code for the values
and here right now I’ve set it to temperature so it shows object and ambient simultaneously
right off that's how you see it
33.4
so you can select different units Fahrenheit or kelvin as well and both of these will be displayed
at the same time on the lcd thanks for watching this was how to display the temperature from this
infrared touchless sensor on the lcd 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 to subscribe to get updates on my upcoming videos