Pimoroni Melexis MLX90640 Thermal Camera Breakout

The working code I have is for Arduino. (Would that help you at all?) I had something for the RPi that was ALMOST working, but I seem to have broken something as far as libraries/drivers.

So…If you want something for the RPi, I need some help, first! ha

I had things working (including all of the pimoroni examples), but then I broke something after installing libi2c-dev and adding some additional i2c busses using dtoverlay. I couldn’t get any actual data from the sensors after this.

I’ve gone so far as to wipe the SD card and start fresh, newest kernel, tried to follow the instructions (without and with libi2c-dev installed), yet nothing works. So, can anyone help me out? If you have it working, telling me which kernel and drivers you have and which libraries/modules you had to install would be great.

I would think that I damaged the sensors, but find it unlikely since I have three and all of them still read/write using the Arduino.

1 Like

I can’t help much help unfortunately. I own several Arduino’s but don’t own a MLX90640 camera.
If you have some python code for the MLX90640 post it and I may be able to spot something?

I do have an Arduino with me. So if you have the code for Arduino, I can try it out. Please let me know the steps you took to make it work as well. Do you mean that, if I change the address using the Arduino, I may not be able to interface the sensor with the RPi afterwards?

For working with the single sensor using RPi and read the thermal image, I used the github files from here: https://github.com/pimoroni/mlx90640-library

The I2C address is hardcoded in the pimoroni programs and doesn’t have provisions to do anything with more than one sensor at a time. So, you can change the address of the sensor and the address in the code, but you’re still only going to be using one sensor with each program instance.

I was just trying to make the Arduino program more user friendly (accept address change information from the serial monitor instead of having it hardcoded) and I seem to have written one of my sensors out of range. So, I guess I get to add that to the list of problems to solve before moving forward! Stay tuned, if I get this sorted out. Otherwise, I don’t want to send you something that will give you more headache than help!

The problem is that it’s not just my code that isn’t working. The pimoroni examples have also stopped working. So, it’s deeper than just my poor coding ability ha!

It seems that these sensors MAY be easy to screw up by writing invalid values to their registers, ie. no internal checks against it.

I2C address range should be 0x03-0x77 and (after playing around with my address changing code), I suddenly couldn’t find the sensor in that range. Scanning beyond the valid range shows something at 0x00 and 0x80, but I have the suspicion those aren’t real.

You can change what address the Pimoroni code looks for, for some sensors anyway.
For example if I was wanting to use two BME680’s I change
sensor = bme680.BME680()
sensor1 = bme680.BME680(76)
sensor2 = bme680.BME680(77)

And with the one sensor using the alternate address its
sensor = bme680.BME680(77)

You’d also have to edit some of the other code
if sensor.get_sensor_data(77):
Thats my understanding anyway, I haven’t attempted to do it as of yet. I was at one time wanting to track indoor versus outdoor temps and humidity etc. Just can’t find my round 2it. ;)

Hi ion_four,

you mentioned you have a working code for Arduino for changing the i2c address. Do you mind sharing that?


Hi Arun,

I just had some commands with hardcoded addresses, but decided to it make slightly more user friendly by allowing input from the Serial Monitor. When compiled, it gives some warnings about type conversions, but it seems to work despite this. I tested it by changing a sensor address back and forth, several times and no issues. There are instructions and warnings at the top of the code, but to reiterate…

Be warned, there is no error checking. You enter just the least significant byte of the address in hex. So, default address is 33 and you might want to change it to 34, for example. If you put in an invalid or unintended address (ex. 8438523, cat, dog, 0x33, !@#*&$#), who knows what you will get and it may cause you some big troubles.


1 Like


If you remember any details of how you got the sensors working on the RPi, such as what libraries you installed (using pip3 or apt-get?) and any issues, that would be great. Like I said, I had them working, but installed some other libraries and seem to have broken it, even after a fresh install. :(

I’m also curious what your plans are with the multiple sensors, as I also bought four…suspicious coincidence!

1 Like

Hi ion_four,

On a newly installed Debian OS and after running the “sudo apt-get update” command, I followed the exact steps in the Pimoroni github: https://github.com/pimoroni/mlx90640-library.

Ran the command to install the I2C device library:

sudo apt-get install libi2c-dev



To build the MLX90640 library and examples in LINUX I2C mode:

make clean

To use the bcm2835 library:

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.55.tar.gz
tar xvfz bcm2835-1.55.tar.gz
cd bcm2835-1.55
sudo make install

For dependencies on some example codes:

libav for video example:

sudo apt-get install libavutil-dev libavcodec-dev libavformat-dev

SDL2 for sdlscale example:

sudo apt install libsdl2-dev

Once everything installed, use cd command to the mlx… folder and when under the folder, make the example code:

make examples/hotspot
sudo examples/hotspot

It was working right away for me.

Hi ion-four,
I have added the reply with the steps I took to make it work using the pimoroni github page. The post is under review by the page admin it seems, should be released after the review.

I am using it to monitor the temperature change of a large industrial equipment. To build some sort of condition monitoring prototype :)

btw, thanks much for the code. I will try it out and let you know the result. So as I understand I just need to input “33” for the old address when prompted and “34” (assuming I want it as “34”) for the new address. I do not need to supply it as “0x33” and “0x34”, am I correct?

Yes, supply the addresses as merely “33” and “34” , etc. No leading 0x, no MSB as that’s hardcoded. I had more instructions in the serial monitor output, but my little old Arduino was running out of dynamic memory, so I removed them.

Current address, (enter), New address, (enter), Power On/Off Reset, (enter) and the new address should be written and displayed.

If you’re a more accomplished programmer, please help with the type mismatch warnings and adding error checking would be great. When I first changed it to take serial input I was writing an int (two bytes) to the address byte and seem to have lost one of my sensors doing this. Not terribly amusing, considering the cost of them!

1 Like

Sure, thanks for the information.

Not sure why the admin is taking so long to release my reply on the steps I took, probably due to multiple links in the post.

Let me try this method and see if I can improve on the code, not a pro coder myself though…

Just a guess but they may have concerns about somebody bricking the device while trying it? They could actually be tying it themselves before posting it? Again just a guess on my part, they must have a reason though. The delay may also have something to do with it being the weekend?

My code (posted on an independent site and linked above) is the one with the potential to be dangerous, RE: no error checking. I believe Arun is referring to his instructions on the github site to get the sensor working, since I seem to have not been able to recreate my initial working state.

There are some other references on github to people having issues with the sensors being finicky. Nothing to do with pimoroni, just Melexis. I think I may be on the trail of why a couple of mine stopped working, but no time to deal with it, yet. I’ll post if I get to the bottom of it.

Ok, there is a lot going on in this thread. I missed the link, see it now though d’oh . =)

Looked at the code, I’m a total NOOB with Arduino. I have several UNO’s but haven’t done a whole lot with them yet other than the super simple stuff.
My python skills are average I think, as I’m self taught after buying several raspberry Pi’s. I haven’t had any formal training in any programing language unfortunately. =( That just how things went for me. My job was more hardware related than software. I’m retired now. =)

1 Like

Hi ion_four and alphanumeric,

Just tested your code using Arduino and changed my sensor addresses to 34 and 35 successfully :). Thank you so much. Now trying to test if all three can work together to output the individual readings; modifying the github sample code for that.

Meanwhile, I wrote to them to review and release my comments for the steps I followed for making it work the first time using the Pimoroni github page. Will wait till tomorrow, if no reply I will write it somewhere else and pass you the link.

Thanks again to both of you for the help so far.

Alright, my post is online now. You can see the steps I took to make it read the first time in the above post.