Created
August 5, 2021 22:28
-
-
Save dmalawey/c7281836e2a9542a493d36dbcaccdb5e to your computer and use it in GitHub Desktop.
MLX90614 infrared sensor error using Adafruit library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************** | |
This is a library example for the MLX90614 Temp Sensor | |
Designed specifically to work with the MLX90614 sensors in the | |
adafruit shop | |
----> https://www.adafruit.com/products/1747 3V version | |
----> https://www.adafruit.com/products/1748 5V version | |
These sensors use I2C to communicate, 2 pins are required to | |
interface | |
Adafruit invests time and resources providing this open source code, | |
please support Adafruit and open-source hardware by purchasing | |
products from Adafruit! | |
Written by Limor Fried/Ladyada for Adafruit Industries. | |
BSD license, all text above must be included in any redistribution | |
****************************************************/ | |
#include <Adafruit_MLX90614.h> | |
Adafruit_MLX90614 mlx = Adafruit_MLX90614(); | |
float myEmissivity = 0.99; | |
void mlx_set(float emissivity) { | |
mlx.writeEmissivity(emissivity); | |
Serial.println("setting emissivity"); | |
} | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("Adafruit MLX90614 test"); | |
if (!mlx.begin()) { | |
Serial.println("Error connecting to MLX sensor. Check wiring."); | |
while (1); | |
}; | |
} | |
void loop() { | |
while (myEmissivity >= 0.80){ | |
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); | |
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C"); | |
Serial.println(); | |
mlx_set(myEmissivity); | |
myEmissivity = (myEmissivity - 0.01); | |
Serial.print("New emissivity = "); Serial.println(myEmissivity); | |
delay(500); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment