Categories
TUTORIALS

How to make an Infrared Thermometer with Arduino

Learn how to wire and code a basic DIY button-triggered thermometer that can measure and display temperature readings from an MLX90614 IR temperature sensor on an LCD screen

To make the thermometer you will need to integrate 3 individual components, a button, IR temperature sensor, and an LCD display. First, you will set up a button that will trigger your temperature measurement. Second, you will set up and communicate with the MLX90614 temperature sensor via an I2C connection. Third, you will connect to an LCD screen to displau the temperature readings.

Button Setup and Code

You will need to connect four male to male wires from your Arduino to the breadboard. Connect the voltage source 5V pin on Arduino to one of the long vertical red ‘+’ bus rows on the breadboard and the ground GND pin on the Arduino to the one of the other long vertical blue ‘-‘ bus rows. This will allow you to create multiple connections to +5V supply and ground on the breadboard. Then, connect the third wire from digital pin 10 to one leg of the button. Through the same leg but on the other side of the button connect the leg to ground through a pull-down resistor (10 kOhm). The pulldown resistor allows us to define the OFF state of the button as the LOW voltage reading since the circuit directly connects digital pin 10 to ground through the resistor. When the button is pressed down it connects the circuit through the other leg of the button which is wired to the +5V supply, resulting in a voltage reading of HIGH, which we denote ON.

In addition to the button wiring, a red LED on Arduino digital pin 13 is connected through to ground, so that the button state can be visualized.

Here is how we implement that in the Arduino code:

MLX90614 IR Sensor Setup and Code

It is assumed that the MLX90614 sensor you are using is mounted on a printed circuit board with 4 male header pins soldered on for connectors. You will need 4 male to female jumper wires to make all the necessary connections. Connect the Vin pin on the sensor to the +5V power supply ‘+’ rail on the breadboard and the GND pin on the sensor to the ground ‘-‘ rail on the breadboard. Then connect the two I2C connectors, SCL and SDA, on the sensor to the SCL and SDA pins on the Arduino.

There is a very nice tutorial on I2C communication protocol on the Arduino Docs site, which I quote from here, “The I2C protocol involves using two lines to send and receive data: a serial clock pin (SCL) that the Arduino Controller board pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices.”

Here is how we implement that in the Arduino code:

Click here for the Wire/I2C library from Arduino

Click here for the MLX90614 IR Temperature Sensor library from Sparkfun

LCD Display Setup and Code

The wiring for the LCD Display is the most involved, but your hard work will pay off since we can use the Arduino LiquidCrystal Library for super easy coding. There is a nice detailed tutorial on Arduino Docs for using Liquid Crystal Displays (LCD) with Arduino.

The pins you will need to connect include

  • Register select (RS), which allows you to digitally control which memory register you are communicating with. There is a data register for storing characters to display and an instruction register for storing instructions for the LCD
  • Read/Write (RW), which controls whether the display is in read or write mode
  • Enable (E), which digitally enables writing characters to the display
  • Data Bit pins 0-7 (DB0…DB7), which correspond to the bits of data you actually write to the LCD data register
  • V0 – display contrast which is wired in series with a current limiting 1 kOhm resistor
  • VSS and VDD are the +5V power supply and ground pins respectively
  • A (LED-) and K (LED+) are the LED backlight voltage supply and ground pins respectively, a current limiting 220 Ohm resistor is placed in series with the LED voltage supply in

Here is some basic code for the LCD Display:

Click here for the LiquidCrystal Library from Arduino

Putting it all together in a complete circuit

Congrats! you have now set up all the individual components and are ready to integrate them together. Below, are complete circuit diagrams and schematics along with the complete plug and play code to get the sensor up and running.

Complete Code

Parts List

ComponentQuantityLink
Arduino Uno R3 Board 1To Buy
MLX90614 IR Temperature Sensor1To Buy
Datasheet
LCD1602 Module Display Screen1To Buy
ELEGOO Starter Kit
830 Tie-Points Breadboard1To Buy
Red LED1LED Kit To Buy
ELEGOO Starter Kit
220 Ohm, 1 kOhm, 10 kOhm Resistor1 of eachELEGOO Resistor Kit
ELEGOO Starter Kit
Button1To Buy
ELEGOO Starter Kit
Breadboard Jumper Wires12 m-m, 4 m-fJumper Wire Kit
ELEGOO Starter Kit

Video Demonstration

References

Libraries:

https://www.arduino.cc/reference/en/language/functions/communication/wire/

https://www.arduino.cc/reference/en/libraries/liquidcrystal/

https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library

Other Tutorials:

I2C –https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library

LCD-https://docs.arduino.cc/learn/electronics/lcd-displays

Wire and Program a Button-https://docs.arduino.cc/built-in-examples/digital/Button

Make a noncontact IR thermometer-https://circuitdigest.com/microcontroller-projects/ir-thermometer-using-arduino-and-ir-temperature-sensor

Interface MLX90614 Non-contact Infrared Temperature Sensor with Arduino-https://lastminuteengineers.com/mlx90614-ir-temperature-sensor-arduino-tutorial/#how-do-infrared-thermometers-work

Arduino Style Guide-https://docs.arduino.cc/learn/contributions/arduino-writing-style-guide

Extra Reading:

PullUp Resistors https://learn.sparkfun.com/tutorials/pull-up-resistors/all

Leave a Reply

Your email address will not be published. Required fields are marked *