Reading MLX90640

Hello,
i have issues with serial reading of a MLX90640 IR thermal camera,
sensor from adafruit.
As I tried it with a Arduino uno and mega, error message says that memory is not big enough when i want to upload the script with the basic example from this library.

Has anyone inclueded this IR camera in his project without using a raspberry pi. I was hoping for a serial read with an arduino and then maybe visualizing in matlab or python on a usb-connected computer.

Thanks in advance

Yes, I've used this camera with a Teensy 4.0 and 3.2" TFT.

If you don't do any processing, and just hose all the data out from I2C to serial, I think you should be able to do that easily on a Uno.

This sensor contains a 24x32 array of IR thermal sensors which means you get 24x32 float per reading.

the sketch allocates this at the start

float frame[32*24]; // buffer for full frame of temperatures

On a UNO a float takes up 4 bytes of SRAM, so just this array will require 24x32x4 = 3072 bytes of SRAM.

➜ You UNO has only 2048 bytes available... so this is a no go

More generally, there are dependencies on other libraries which add their own toll to this, and in total the simple sketch requires 8627 bytes of SRAM (and that does not even take into account the run time needs on the stack).

➜ Your MEGA only has 8192 bytes available, so that won't work there either.

You need a more capable hardware, the Teensy 4.0 for example as mentioned by @anon73444976 would do


regarding the dynamic needs, the getFrame() or begin() function that reads the data in requires a temporary array (created on the stack) for 834 entries of size uint16_t ➜ that's 1688 bytes required just there

so best to get a MCU with lots of SRAM

Internally in the sensor, the pixel values are not floats.
The results only become floats after processing, which could be done in . . . Processing.

fair point.

a global static buffer could be allocated and the getFrame() method could be rewritten to grab this buffer (an array uint16_t frame[834];) which would be used rather than the stack and returned directly, without the final transformation int float.

begin() should also use this buffer instead of the stack

that would save 1384 bytes and leave 949 bytes for the stack and dynamic allocation on a MEGA

if there are no other big memory allocations, that might work.

thanks a lot for your response so far. What I don't understand. Why is already the upload of the script an issue with the memory. Shouldn't it just become a problem, when I start the code and data is flowing from the IR-Sensor to the arduino?

I've got one WEMOS D1. At least the upload seems to work. But when I open the Monitor, there is absolutely nothing showing up. Even though, there is some "Serial.println" in the Library-Example "MLX90640_simpletest". I just don't get it, because i should have at least the output "Adafruit MLX90640 Simple Test" from
Serial.println("Adafruit MLX90640 Simple Test");

Try putting a Serial.flush (); after the first Serial.print.

Quote from post #7:
Try putting a Serial.flush (); after the first Serial.print.

Which one of the following is a literate style of the above?

1. Try putting a Serial.flush (); after the first Serial.print ();.
2. Try putting a Serial.flush () after the first Serial.print ().
3. Try putting a Serial.flush() after the first Serial.print().
4. Try putting a Serial.flush after the first Serial.print.

Does it matter?
Give it a try in word tune if you want

Yes! It matters for cryptic people.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.