Let's Workshop: Keyes MLX90614 IR Temperature Module
Posted by Sebastian Karam on
Here is a quick introduction to using the Keyes MLX90614 IR Temperature module. Hopefully it will provide you with the confidence to intergrate rotary control into your projects.
This example will demonstrate the use of an Arduino UNO reading the temperature from a MLX90614 sensor. Once connected and the program loaded, it will read the ambient and target temperature every second. This will use the Adafruit_mlx90614 library created by Limor Fried/Ladyada for Adafruit Industries.
Components
- 1pcs Arduino UNO or Compatible - LCAA100005
- 1pcs MLX90614 IR Temperature Keyes Red - BDAA100068
- 4pcs Male to Female Jumper Cables - GBAA100002
Wiring
Wire the two boards together as can be seen in the image below, taking care to match the pin numbers.
Coding
The code consists of an include, definitions, 2 functions, setup and loop. First the Adafruit_mlx90614 library is linked to the code. This is followed by the initilisation of the temperature sensor object used by the library. The setup initilises the serial connection and begins communication with the library. The loop calls the ambient and target temperature from the library and ouputs it to the serial connection, pausing for a second and repeating.
Load the code below into the Arduino IDE and upload it to your board.
/* A simple program designed to setup and demonstrate the Adafruit_TempSensor190614 library and TempSensor190614 IR Temperature module - BDAA100068 The program uses the Adafruit_TempSensor190614 library to interface with the temperature module and return the temperature to the serial monitor. Then repeat the request. modified 12 March 2019 by Sebastian Karam - Flux Workshop The Adafruit_mlx90614 library created by Limor Fried/Ladyada for Adafruit Industries https://github.com/adafruit/Adafruit-mlx90614-Library */ #include// include the Arduino wire library #include // include the Adafruit_TempSensor190614 library Adafruit_MLX90614 TempSensor1 = Adafruit_MLX90614(); // create a TempSensor190614 object void setup() { Serial.begin(9600); // initialise the serial connection TempSensor1.begin(); // begin monitoring the sensor object as connected through the SCL and SDA pins } void loop() { Serial.print("Ambient: "); // print to the serial terminal Serial.print(TempSensor1.readAmbientTempC()); // request and print the ambient temperature Serial.println(" degC"); // print to the serial terminal Serial.print("Target: "); // print to the serial terminal Serial.print(TempSensor1.readObjectTempC()); // request and print the ambient temperature Serial.println(" degC"); // print to the serial terminal delay(1000); // pause before looping }
Running
With the board loaded with the program and all the connections made, start the serial monitor. An initial value for the ambient and target will appear. Now target a particular object with the sensor. The output should be as seen below (in this instance, it was pointing at a cup of tea).
What to try next?
- Output the temperature in farenheit using '.readObjectTempF()'.
- Use the output to control a relay
Share this post
- 0 comment
- Tags: Arduino, BDAA100068, IR, Temperature, UNO