I purchased 4 pieces of MLX90640 Thermal Camera Breakout from Pimoroni and trying to make it work on a Raspberry pi 3 B+. I am able to get the thermal image from a single sensor after installing the libraries. Now, I need to connect multiple (trying to connect 3 at the moment) sensors to the I2C port and get the data from all three. Understood from some forum that I2C address can be changed for the sensors to make it work. However, unable to do that after multiple tries. Anyone can help?
It has to be changed in hardware and software. Most of Pimoroni’s i2c breakouts have an address change jumper on the back side. Unfortunately the MLX90640 doesn’t appear to have that option. =(
That may be because the chip used on the board doesn’t support that option or there just wasn’t room on the board to add that functionality. Even if it was there it would limit you to two cameras. Your option would be one of two selectable addresses.
Bummer but I don’t think what you want to do is doable. Not easily anyway. You might be able to add your own wire jumper to switch the address if you can figure out what pin to ground or tie high etc. You need to the schematic for the board to do that and some good soldering skills.
Hmm… thanks for the reply. I am really at a loss with these sensors on my hand. Having individual RPi for single sensor doesn’t make sense. Please let me know if you find any method to change the I2C address.
In your case that is a bit of a bummer. You can change the address on other Pimoroni sensors so you can use two, just not on that thermal camera. My BME680 for example has an address change jumper on the back. Its marked ADDR+1 and it says i2c 0x76 or 0x77
And many of the other breakouts have that same function. Unfortunately, you just happen to have one of the very few that don’t support address change.
I have several Pi’s with multiple i2c devices hooked up. So far I haven’t had to change any addresses, none of them have the same address and I’m only using 1 of each different sensor.
I don’t own a thermal camera so I have no idea if you can fudge it to change the address? Wish I could be more help.
I wish if I had that option to change the address :(
Thanks again for your response
You can change the address on the MLX90640. You just need a small piece of code to change the address in EEPROM. I’ve done it several times on these sensors and will post the code if there’s still interest. If you want to figure it out for yourself, page 19 in the datasheet. First you need to overwrite that register with 0x0000, write new address, POR (power on/off reset) and then it should be changed.
Thanks a ton. If you have the code to change this, please pass to me. If you can put in any common link, I can download it from there too. Which development board did yo use to overwrite the register?
Nice, that type of thing is above my current skill level. Might be something I’d try down the road though, if the need arises.
@anarayanan I would run i2cdetect on that Pi with no MLX90640’s connected. That will tell you if anything else you may have connected is using an i2c address. That way you don’t accidentally use one already in use.
If you don’t have anything else connected to i2c there is no real need to do it though.
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.
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
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. ;)
you mentioned you have a working code for Arduino for changing the i2c address. Do you mind sharing that?
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.
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!
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 make I2C_MODE=LINUX
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 ./configure make sudo make install
For dependencies on some example codes:
sudo apt-get install libavutil-dev libavcodec-dev libavformat-dev
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.
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?