ECE 110/Equipment/IR Thermal Sensor
$$\newcommand{E}[2]{#1_{\mathrm{#2}}}$$
Introduction
The MLX90614 IR thermal sensor is a device capable of measuring temperatures from a distance. It is a four-pin device that comes in a round package. In ECE 110, these are attached to a module that makes them easier to use - among other things, the module regulates the voltage (so you can use either a 3.3 V or 5 V source) and provides the necessary pullup resistors for the communication pins so that they are high be default.
Note: This sensor uses the data and clock lines (SDA and SCL); as a result, it cannot be used at the same time as the ECE 110/Equipment/Color Sensor unless you disable one device's pullup resistors!
Leads
- 1 (left): Supply voltage $$\E{V}{in}$$, typically 5 V
- 2: GND
- 3: SCL - clock signal
- 3 (right): SDA - data signal
Operation
The sensor actually produces two different temperature readings - one based on the frequency of infrared light it detects (the remote temperature) and one based on the physical temperature of the sensor itself (the ambient temperature). The MLX90514 library takes care of the heavy lifting in terms of converting the data signal into meaningful temperature readings.
Sample Code
The code below is slightly adapted from https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library -- the Serial baud rate is now 9600 and the pins are labeled.
/******************************************************************************
MLX90614_Serial_Demo.ino
Serial output example for the MLX90614 Infrared Thermometer
This example reads from the MLX90614 and prints out ambient and object
temperatures every half-second or so. Open the serial monitor and set the
baud rate to 9600.
Hardware Hookup (if you're not using the eval board):
MLX90614 ------------- Arduino
VDD ------------------ 3.3V
VSS ------------------ GND
SDA ------------------ SDA (A4 on older boards) (pin 20)
SCL ------------------ SCL (A5 on older boards) (pin 21)
An LED can be attached to pin 8 to monitor for any read errors.
Jim Lindblom @ SparkFun Electronics
October 23, 2015
https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library
Development environment specifics:
Arduino 1.6.5
SparkFun IR Thermometer Evaluation Board - MLX90614
******************************************************************************/
#include <Wire.h> // I2C library, required for MLX90614
#include <SparkFunMLX90614.h> //Click here to get the library: http://librarymanager/All#Qwiic_IR_Thermometer by SparkFun
IRTherm therm; // Create an IRTherm object to interact with throughout
void setup()
{
Serial.begin(9600); // Initialize Serial to log output
Wire.begin(); //Joing I2C bus
if (therm.begin() == false){ // Initialize thermal IR sensor
Serial.println("Qwiic IR thermometer did not acknowledge! Freezing!");
while(1);
}
Serial.println("Qwiic IR Thermometer did acknowledge.");
therm.setUnit(TEMP_F); // Set the library's units to Farenheit (sic)
// Alternatively, TEMP_F can be replaced with TEMP_C for Celsius or
// TEMP_K for Kelvin.
pinMode(LED_BUILTIN, OUTPUT); // LED pin as output
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
// Call therm.read() to read object and ambient temperatures from the sensor.
if (therm.read()) // On success, read() will return 1, on fail 0.
{
// Use the object() and ambient() functions to grab the object and ambient
// temperatures.
// They'll be floats, calculated out to the unit you set with setUnit().
Serial.print("Object: " + String(therm.object(), 2));
Serial.println("F");
Serial.print("Ambient: " + String(therm.ambient(), 2));
Serial.println("F");
Serial.println();
}
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Notes
- The PCB mount takes care of some important installation issues, such as resistors on the SDA and SCL lines. If you were to use the MLX90614 all by itself, you would need to add to 4.7 k$$\Omega$$ resistors between the 3.3 V signal and the SDA / SCL lines.
References
- Infrared Thermometer - MLX90614 from SparkFun
- GY-906 MLX90614 Non-Contact Precision Thermometer Module from ProtoSupplies