r9no
Posts: 21
Joined: Sun Feb 24, 2019 8:45 pm

Setting up MLX90640

Tue Feb 26, 2019 4:12 pm

I am currently trying to figure out how to setup the pimoroni MLX90640 (https://shop.pimoroni.com/products/mlx9 ... a-breakout).
I am new to RasPi/Linux etc and i am wondering what steps i need to take now to set it up as i cant find any clear sources showing that process. I am working from this (https://github.com/pimoroni/mlx90640-li ... y-pi-users) as provided on their website but even the ReadMe file doesnt seem like step-by-step intructions to me and i dont know the standard way to get those github folders onto my Pi, if that is even necessary.

My end goal is to have the camera display its output on my monitor like a thermal camera (I am using VNC but a HDMI connection is possible).

Any advice you have on this is appreciated. Thank you.

User avatar
Joel_Mckay
Posts: 289
Joined: Mon Nov 12, 2012 10:22 pm
Contact: Website

Re: Setting up MLX90640

Wed Feb 27, 2019 4:03 am

In general, you need to setup the pi kernel overlays and modules to allow port access.

We maintain a OverlayFS based desktop for our local CNC/3d-printer club, that already has these enabled (we played with the Lepton FLIR modules at one point) along with the recent libraries:
bcm2835 libi2c-dev libavutil-dev libavcodec-dev libavformat-dev

https://sourceforge.net/projects/microm ... spberry-pi
It is a large install needing a 32GB card, but has most of the developer tools you will need for most projects.
Read the FAQ about how to update the OS. Also, read how to disable the read-only mode in order to change system files so you can change the i2c bus speed to get higher frame rates (after verifying the normal setup works of course). ;-)


Once logged in, than:
1. press Ctrl+Alt+t to open a terminal
2. type git clone --depth 1 https://github.com/pimoroni/mlx90640-library.git and press Enter key
3. type cd mlx90640-library/ and press Enter key
4. type make clean and press Enter key to clean off old object files
5. type make and press Enter key to build code
6. type sudo ./fbuf and press Enter key to run the local binary executable
Note the file permission "x" in the mask on Linux filesystems by listing with ls -l

I was able to build it on the club image with the above steps, but have no way of testing your hardware. ;-)

However, I did run into an issue with the instructions posted on the git wiki....
the "make I2C_MODE=LINUX" part of the documentation appears to throw a number of poorly written type-conversion errors, and should be reported to the repo maintainer bug tracker. (I included the screen dump here, as people who google the issue will be able to find this thread in the future.)

Code: Select all

In file included from functions/MLX90640_LINUX_I2C_Driver.cpp:24:0:
/usr/include/linux/i2c.h:68:8: error: redefinition of ‘struct i2c_msg’
 struct i2c_msg {
        ^~~~~~~
In file included from functions/MLX90640_LINUX_I2C_Driver.cpp:23:0:
/usr/include/linux/i2c-dev.h:37:8: error: previous definition of ‘struct i2c_msg’
 struct i2c_msg {
        ^~~~~~~
In file included from functions/MLX90640_LINUX_I2C_Driver.cpp:24:0:
/usr/include/linux/i2c.h:131:7: error: redefinition of ‘union i2c_smbus_data’
 union i2c_smbus_data {
       ^~~~~~~~~~~~~~
In file included from functions/MLX90640_LINUX_I2C_Driver.cpp:23:0:
/usr/include/linux/i2c-dev.h:89:7: error: previous definition of ‘union i2c_smbus_data’
 union i2c_smbus_data {
       ^~~~~~~~~~~~~~
functions/MLX90640_LINUX_I2C_Driver.cpp: In function ‘int MLX90640_I2CRead(uint8_t, uint16_t, uint16_t, uint16_t*)’:
functions/MLX90640_LINUX_I2C_Driver.cpp:51:27: error: invalid conversion from ‘__u8* {aka unsigned char*}’ to ‘char*’ [-fpermissive]
     i2c_messages[0].buf = (__u8*)cmd;
                           ^~~~~~~~~~
functions/MLX90640_LINUX_I2C_Driver.cpp:56:27: error: invalid conversion from ‘__u8* {aka unsigned char*}’ to ‘char*’ [-fpermissive]
     i2c_messages[1].buf = (__u8*)buf;
                           ^~~~~~~~~~
functions/MLX90640_LINUX_I2C_Driver.cpp: In function ‘int MLX90640_I2CWrite(uint8_t, uint16_t, uint16_t)’:
functions/MLX90640_LINUX_I2C_Driver.cpp:93:27: error: invalid conversion from ‘__u8* {aka unsigned char*}’ to ‘char*’ [-fpermissive]
     i2c_messages[0].buf = (__u8*)cmd;
                           ^~~~~~~~~~
<builtin>: recipe for target 'functions/MLX90640_LINUX_I2C_Driver.o' failed
make: *** [functions/MLX90640_LINUX_I2C_Driver.o] Error 1
Let people know if the normal make method works for this, or if you do need the special flag (and need to fix the bugs).
Cheers,
J

kseng123
Posts: 2
Joined: Fri Mar 15, 2019 2:14 am

Re: Setting up MLX90640

Fri Mar 15, 2019 2:22 am

Hi, I,m a new learner in raspberry pi 3. Is it possible for me to just run the c code inside the functions file library of MLX90640? Or l need to use the
code in https://github.com/pimoroni/mlx90640-li ... r/examples , I can't run just the functions and header only?
When l just run the function file such as ( gcc MLX90640_API.cpp -o MLX90640_API.o), it says ( #include "MLX90640_API.h" : no such file or directory).
Anything did l done wrong? can you help me? thank you

r9no
Posts: 21
Joined: Sun Feb 24, 2019 8:45 pm

Re: Setting up MLX90640

Fri Mar 22, 2019 12:25 pm

Thank you for your reply and sorry i took so long to get back to you. This aspect of my project has taken a backseat for a while.
So,
I have followed all of the steps and they make far more sense once you listed them in that way. My problem was, amongst other things, that i had never seen or used the "make" functions before so didnt know how to use them.
I can run ./fbuf and ./interp with no errors however the image does not display on the screen and i have tried reducing the image scale as instructed. The ./test works but i assume the other two programs have better image quality and other features l ike higher framerate which i would like to use.
Any idea why the image wouldnt be showing up for ./interp and ./fbuf ?
I have set i2c baud rate to 1 000 000 as, the the fbuf.cpp code, it asks for baud rate of 1MHz. But this be incorrect.

Here is an image of my coffee using the ./test function - https://imgur.com/a/NcLVNyt :D

Many thanks.

slowpace
Posts: 4
Joined: Thu Aug 16, 2012 2:28 pm

Re: Setting up MLX90640

Mon Jul 08, 2019 1:52 pm

I successfully installed the Thermal Camera following the instructions. I ran the test example to confirm that it was running correctly and then compiled and ran the rawrgb example that sends the stream to gst-streamer-1.0

https://www.youtube.com/watch?v=zHQmrH7CZwA

I am using the Raspberry Pi 4 with 2GB RAM, headless using RealVNC.

Return to “Automation, sensing and robotics”