SparkFun MLX90614: an example that runs
Yes. You can use the SparkFun MLX90614 library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (IR thermometer, MLX90614). The example below, "Read an object and the room with IRTherm", runs on the Arduino Uno R3.
Built in on Mokxi: #include <SparkFunMLX90614.h> and it builds, with nothing to install. Free, and no account needed.
What SparkFun MLX90614 does
The infrared thermometer as IRTherm: begin(), setUnit(TEMP_C | TEMP_F | TEMP_K), read(), object(), ambient(), minimum() and maximum(). That is what SparkFun MLX90614 covers. The sketch below uses it on the Arduino Uno: “Read an object and the room with IRTherm”.
The SparkFun MLX90614 library's interface (the IRTherm class), for the MLX90614 infrared thermometer on I2C.
read() fetches the object and ambient temperatures from the chip together; object() and ambient() return what it fetched in the unit set last, and minimum() and maximum() the lowest and highest each has been since the sketch began. TEMP_RAW is the chip's own 16-bit number (0.02 K a step).
The calls follow release 1.1.0 of the library, so a sketch written here builds on a real board too. The example is the one Mokxi's own tests build and run, so what is printed here is what runs.
| Library Manager name | SparkFun MLX90614 |
|---|---|
| Author | SparkFun |
| Include | #include <SparkFunMLX90614.h> |
| Boards | every board Mokxi compiles for but ATtiny85 |
| In the simulator | Simulated: it runs against the part the way it does on the bench. |
| Parts it drives | IR thermometer, MLX90614 |
Install it
It builds on every board Mokxi compiles for but ATtiny85.
In Mokxi it is built in: #include <SparkFunMLX90614.h> and the sketch compiles, with no download, no zip and no Library Manager.
On a real board, install "SparkFun MLX90614" by SparkFun from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add SparkFun MLX90614 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.1.0, so a sketch written here builds there too.
- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi
The calls you will use
In the order a sketch meets them.
IRTherm therm
Makes therm, the IRTherm object the calls below are made on.
therm.begin()
Starts it up. Call it once in setup(). Arguments: address.
therm.setUnit(TEMP_C)
Sets the unit to the value you pass in.
therm.read()
Returns the value as a whole number.
therm.object()
Returns the object as a decimal number.
therm.ambient()
Returns the ambient as a decimal number.
Example: Read an object and the room with IRTherm
On the Arduino Uno R3. It runs in the browser exactly as printed.
#include <Wire.h>
#include <SparkFunMLX90614.h>
IRTherm therm;
void setup() {
Serial.begin(9600);
Wire.begin();
therm.begin();
therm.setUnit(TEMP_C);
}
void loop() {
if (therm.read()) {
Serial.print("Object: ");
Serial.println(therm.object(), 1);
Serial.print("Ambient: ");
Serial.println(therm.ambient(), 1);
therm.setUnit(TEMP_F);
Serial.print("Object F: ");
Serial.println(therm.object(), 1);
therm.setUnit(TEMP_C);
} else {
Serial.println("no reading");
}
delay(500);
}Wiring
- Arduino Uno R3 A4 to IR thermometer, MLX90614 SDA
- Arduino Uno R3 A5 to IR thermometer, MLX90614 SCL
- Arduino Uno R3 5V to IR thermometer, MLX90614 VIN
- Arduino Uno R3 GND to IR thermometer, MLX90614 GND
Try SparkFun MLX90614 without installing anything
Open the example, change the sketch, and keep your version in a free account.