Good day,
Does anyone have an Arduino code/clue for getting just the max and min temp from the data of the MLX90640 board?
Good day,
Does anyone have an Arduino code/clue for getting just the max and min temp from the data of the MLX90640 board?
I poked around in our github for a bit, and it looks like those values might be grouped into a larger dataframe (eeData) https://github.com/sparkfun/SparkFun_ML … 40_API.cpp
I don’t see a ready-made function for min/max temps, but you could likely change/add a few lines to extract those values from the whole shebang
https://github.com/melexis/mlx90640-library
My AI thinks this will work:
Can I easily extract minimum and maximum temperature values by editing this code a bit? https://github.com/sparkfun/SparkFun_ML … 40_API.cpp
Yes, you can easily extract the minimum and maximum temperature values by modifying the existing code a bit. Here’s an example of how you could modify the process_data function to calculate these values:
1 Add two new variables named min_temp and max_temp, initialized with the maximum possible temperature value (1000).
2 Loop through each pixel in the frameData array and update min_temp and max_temp if a lower or higher temperature is found, respectively.
3 After looping through all pixels, return both min_temp and max_temp.
Here’s an example of how you could modify the code:
void process_data(float *frameData) {
int min_temp = 1000;
int max_temp = -1000;
for (int i = 0 ; i < 768 ; i++) {
// Skip the pixels with value -4.0
if (frameData[i] == -4.0) continue;
// Update min and max temperatures
if (frameData[i] > max_temp) max_temp = frameData[i];
if (frameData[i] < min_temp) min_temp = frameData[i];
}
// Return both the min and max temperatures
return {min_temp, max_temp};
}
Make sure to update the return statement to return a struct or array containing both min_temp and max_temp. You can then access these values by calling the function like this:
auto [min_temp, max_temp] = process_data(frameData);
This will unpack the returned tuple/array into separate variables named min_temp and max_temp, which you can use as needed.