Skip to content

Commit 101d16c

Browse files
author
Jim Lindblom
committed
Adding MLX90614_Set_Emissivity example.
1 parent 8c65cf4 commit 101d16c

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/******************************************************************************
2+
MLX90614_Set_Emissivity
3+
How to read and set the MLX90614's emissivity coefficient
4+
5+
Emissivity is a relative measure of how efficiently an object
6+
radiates heat. A perfect thermal emitter has a emissivity of
7+
1.0, but most real-world objects range from 0 to 1.
8+
9+
For example, human skin has an emissivity of about 0.98.
10+
Shiny metals have a very low emissivity, for example polished
11+
aluminum has an emissivity of 0.05. Painted aluminum has an
12+
emissivity of 0.45. Here's a good reference:
13+
http://www.thermoworks.com/emissivity_table.html
14+
15+
If you get really wacky values after setting the emissivity,
16+
try cycling power to the MLX90614.
17+
18+
To set the emissivity, change the value of the
19+
newEmissivity variable above setup(). Allowable values are
20+
between 0.1 and 1.0.
21+
22+
Hardware Hookup (if you're not using the eval board):
23+
MLX90614 ------------- Arduino
24+
VDD ------------------ 3.3V
25+
VSS ------------------ GND
26+
SDA ------------------ SDA (A4 on older boards)
27+
SCL ------------------ SCL (A5 on older boards)
28+
29+
An LED can be attached to pin 8 to monitor for any read errors.
30+
31+
Jim Lindblom @ SparkFun Electronics
32+
October 23, 2015
33+
https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library
34+
35+
Development environment specifics:
36+
Arduino 1.6.5
37+
SparkFun IR Thermometer Evaluation Board - MLX90614
38+
******************************************************************************/
39+
40+
#include <Wire.h> // I2C library, required for MLX90614
41+
#include <SparkFunMLX90614.h> // SparkFunMLX90614 Arduino library
42+
43+
IRTherm therm; // Create an IRTherm object to interact with throughout
44+
45+
const byte LED_PIN = 8; // Optional LED attached to pin 8 (active low)
46+
47+
float newEmissivity = 0.98;
48+
49+
void setup()
50+
{
51+
Serial.begin(9600); // Initialize Serial to log output
52+
Serial.println("Press any key to begin");
53+
while (!Serial.available()) ;
54+
therm.begin(); // Initialize thermal IR sensor
55+
therm.setUnit(TEMP_F); // Set the library's units to Farenheit
56+
57+
// Call setEmissivity() to configure the MLX90614's
58+
// emissivity compensation:
59+
therm.setEmissivity(newEmissivity);
60+
61+
// readEmissivity() can be called to read the device's
62+
// configured emissivity -- it'll return a value between
63+
// 0.1 and 1.0.
64+
Serial.println("Emissivity: " + String(therm.readEmissivity()));
65+
pinMode(LED_PIN, OUTPUT); // LED pin as output
66+
setLED(LOW); // LED OFF
67+
}
68+
69+
void loop()
70+
{
71+
setLED(HIGH); //LED on
72+
73+
// Call therm.read() to read object and ambient temperatures from the sensor.
74+
if (therm.read()) // On success, read() will return 1, on fail 0.
75+
{
76+
// Use the object() and ambient() functions to grab the object and ambient
77+
// temperatures.
78+
// They'll be floats, calculated out to the unit you set with setUnit().
79+
Serial.print("Object: " + String(therm.object(), 2));
80+
Serial.write('°'); // Degree Symbol
81+
Serial.println("F");
82+
Serial.print("Ambient: " + String(therm.ambient(), 2));
83+
Serial.write('°'); // Degree Symbol
84+
Serial.println("F");
85+
Serial.println();
86+
}
87+
setLED(LOW);
88+
delay(500);
89+
}
90+
91+
void setLED(bool on)
92+
{
93+
if (on)
94+
digitalWrite(LED_PIN, LOW);
95+
else
96+
digitalWrite(LED_PIN, HIGH);
97+
}

0 commit comments

Comments
 (0)