In this example we will connect an MLX90614 thermometer to an MBed 1768
The MLX90614 is an infrared thermometer for non-contact temperature measurements. Both the IR sensitive thermopile detector chip and the signal conditioning ASIC are integrated in the same TO-39 can. Integrated into the MLX90614 are a low noise amplifier, 17-bit ADC and powerful DSP unit thus achieving high accuracy and resolution of the thermometer.
The thermometer comes factory calibrated with a digital SMBus output giving full access to the measured temperature in the complete temperature range(s) with a resolution of 0.02°C.
The user can configure the digital output to be pulse width modulation (PWM). As a standard, the 10-bit PWM is configured to continuously transmit the measured temperature in range of -20 to 120°C, with an output resolution of 0.14°C.
Parts List
| Label | Part Type | |
|---|---|---|
| MBED1 | mbed | |
| U1 | MLX90614 |
Layout
Code
We used the online compiler and imported the following into it
https://os.mbed.com/components/MLX90614-I2C-Infrared-Thermometer/
[codesyntax lang=”cpp”]
#include "mbed.h"
#include "mlx90614.h"
DigitalOut myled(LED1); //displays I2C wait
I2C i2c(p28,p27); //sda,scl
Serial pc(USBTX,USBRX); //serial usb config
MLX90614 IR_thermometer(&i2c);
//setup an MLX90614 using MLX90614 library from
// http://mbed.org/users/aquahika/libraries/MLX90614/lsixz6
float temp; //temperature in degrees C
int main() {
while (1) {
myled=1; // if led1 on - waiting on I2C
if (IR_thermometer.getTemp(&temp)) {
//gets temperature from sensor via I2C bus
myled=0;
//print temperature on PC
printf("Temperature is %5.1F degrees C\r\n",temp);
}
//wait for device to produce next temperature reading
wait(0.5);
}
}
[/codesyntax]
Testing
using a terminal program such as TeraTerm you should see something like this
Temperature is 26.4 degrees C
Temperature is 27.0 degrees C
Temperature is 27.0 degrees C
Temperature is 26.9 degrees C
Temperature is 27.0 degrees C
Temperature is 26.9 degrees C
Temperature is 26.8 degrees C
Temperature is 26.8 degrees C
Links
MLX90614 non-contact infrared temperature sensor module iic Interface GY-906


