Hi, welcome to an Arduino tutorial for Robojax.
my name is Ahmad Shamshiri. in this tutorial we are going to learn how we
can use this touchless infrared temperature sensor MLX90614
to measure temperature without touching and displayed on the screen
either as Fahrenheit Celsius Kelvin for ambient and for the object temperature.
or on this large LCD 2004. you can get the code for this project by clicking on the
link below the video in the description which will take you to
www.robojax.com/learn/arduino let's get started with this
I am presenting this tutorial from Canada where I live in Ajax, Ontario.
I have a separate video explaining this mlx nine zero six one four module with the
datasheet and full explanation the link for that videos below this video. I'm not
going to go through that. and this video are going directly to showing you how to
display the temperature on the screen currently this is the 2004 which has
twenty 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
a Fahrenheit or Kelvin whichever you prefer.
or using this LCD 1604 with sixteen characters and two lines where you can
see now it shows the object and ambient and also if you want it can continuously
showing and Kelvin and Fahrenheit. I've separate video explaining the LCD
how to use this and full detail and explanation an I've 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
without touch 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 is.
I 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 rotate and if you select Fahrenheit you
can define or hide Kelvin.
Wiring Explained
now let me explain the wiring for the module I'm gonna show you to this to use
it with the display using the same Arduino . and the module because this
works with a 3.3 volts here from this side from the module this is VCC it has
been connected to 3.3 volts the next one 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 I2C 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 connect them
all in parallel that's okay.
so there is no difference between the two. if you need the wiring diagram for
this it is available as part of my Arduino course at udemy.com. if you want to
learn arduino i have a best seller course on udemy where you can learn
Arduino from ground up with hundreds of projects all course material library
codes wiring diagram everything available in one place. the link for
Arduino courses below this video in the description.
Code explained
now let me explain the code the first thing that you need to do is download
the library for them Melexis you should watched the introduction video for this
and by now you should have already installed that driver for this the
library and the library for the LCD I'm not going to go through that. this line
refers to the Adafruit library which you should have downloaded and installed it
if not watch the video and here these are the two texts that we display
on the LCD and here this text so you can put your own text in any language that
you wish (Latin letters only) so object and ambient. and this is the
address for the for this module because this has I2C module here and I
have four wires for that you need to have the address I will provide you the
ice code I2C scanner you will copy and paste it. I will give you this code
copy and paste it and upload it to your Arduino board. after uploading the code simply
open the serial monitor (set Serial monitor to 9600) so this is a serial monitor and it shows these two
addresses. one address belongs to that one address belongs to the LCD the other
belongs to this (sensor) one. now to get the address for this one because we need it.
let's disconnect the this module I'm just just connecting these two wires
here from the right side and you will see the address is displayed for one of
them so this is now the address for the LCD 0X3F and if I put this back you
will see that it shows two addresses so the other one is 5a is the I2C
address for this. make sure to get the address. now I'm closing this and closing
this type whatever address you get this 0x mean hexadecimal and that is address
so put that the 16 is referring sixteen is referring to a number of
characters if you count it it will be 16 and 2 means two lines. so we will enter
two here. this is their text that it will shown on the screen here let's
save that text if you want to customize it or change it. and if you want to print
the temperature in Celsius printTemp and then inside single quotation put C
capital C it must be capital otherwise it do not work. and if you want to just
show the temperature the object and pressure Celsius and do not want to show
anything then delete everything inside the loop. all of this that I highlighted
so just leave this one and every two seconds it goes and reads it for you.
since because that was Celsius after C I just used D that is for ambient
temperature. and then we have Fahrenheit and after F it was G that's the ambient
and this is the object so the first one this is the object and temperature that you
are pointing to. and the same way Kelvin and after K, L is the ambient so
I use the next letter so you don't make mistake and the first letter is the
actual character that is used for that temperature unit. and we have 2
two seconds in between them. and if you want to do some action based
on amount of temperature for example you want to check if the temperature in
Celsius is greater than 40 and you want to do something this is a function and
do whatever you want to do is here. for example turn on a relay or something or
a buzzer as the temperature is above equal or less than so change this
accordingly.
Demonstration
now let me demonstrate it it shows now the temperatures 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 with this line
is a feels here this is see that D is also serious for the ambient I'm gonna
comment this the rest out by selecting them like that and then right click and select
comment. when I click comment it will add these forward slash and let me upload it.
the code is uploaded it shows in temperature and now it shows in Celsius for object and
ambient and it just rotates it. 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. let me just hold it 33 now thirty three
point six thirty three point five seven so it's very steady and let me point it
to the surface so object is 26 degrees and ambient is 28 so this surfaces may
be cooler. because I was touching it uploading the code a 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 and bered ambient simultaneously.
I turned the 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.
I would like to thank my Patrons from Patreon.com
The subtitle has been typed and corrected by Ahmad Shamshiri on June 30, 2020 .
I did my part to help you learn and use this project. Now it is is your turn.
You can simply subscribe to my channel, thumb up 👍 the video and type simple comment "thank you".
The link to my PayPal account is under the video if you want to send me cash donations. Thank you.
thank you for watching a tutorial from Robojax. if you learned something and
found it useful please thumb up 👍 as this will help my video in the search
algorithm of YouTube. if you have comment our question please post a comment
section below I try to answer a reply. and to get updates of my upcoming videos
make sure to subscribe. if you want to learn Arduino I have a best seller
course on udemy where you can learn or Arduino from ground up with hundreds of
projects all course material library codes wiring diagram everything
available in one place. the link for my new courses below this video in the
description.