Getting the MLX90640 IR Sensor Running with an ESP32


#1

Hardware

I’m using the MLX90640 with 32x24 px on a breakout from Sparkfun, you can get it with 55° or 110 ° FOV, see IR / Thermal Camera for Detecting Broad Nest and Winter Cluster

You need a “stronger” microcontroller, an Arduino Uno ist not sufficient, so I tried the ESP32 Feather for this task:

in addition I use the TFT FeatherWing a 2.4" display with 320 x 240 pixel. You can nicely stick the ESP32 Feather on the back of this display.

Initial Setup

https://learn.sparkfun.com/tutorials/qwiic-ir-array-mlx90640-hookup-guide

Wiring

MLX90640 -- Feather Wing TFT / Feather Huzzah32
-----------------------------------------------
GND   --    GND 
3.3V   --   3V3 
SDA   --    SDA 
SCL   --    SCL 

mlx90640_feather-wing-tft_v0.1.fzz (400.7 KB)

Library and code

There is no lib to install! you have to copy the required files from the demo examples in the same folder as the actual code.

Problems with the defaul ESP32 Arduino core, use the fork from stickbreaker!

Test output to Processing

Yeeeaaaaahhhh! It’s working! And makes nice pics with the Processing example

Other projects with TFT display

what a fortuity: it’s for the same 320x240 ILI9341 display, we have used for the (lower resolution) AMG8833 TFT FeatherWing - 2.4 320x240 Touchscreen For All Feathers ID: 3315 - $29.95 : Adafruit Industries, Unique & fun DIY electronics and kits so let’s try to get it working with the MLX90640

TFT display pins default in the library are not the one we need for the Adadfruit Feather Wing

So I changed in User_Setup.h

// For ESP32 Dev board (only tested with ILI9341 display)
// The hardware SPI can be mapped to any pins

#define TFT_MISO 48
#define TFT_MOSI 49
#define TFT_SCLK 50
#define TFT_CS   15  // Chip select control pin
#define TFT_DC   33  // Data Command control pin
//#define TFT_RST   2  // Reset pin (could connect to RST pin)
#define TFT_RST  -1  // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST


#2

Quite an amount of yak shaving again, @clemens - kudos and keep up that spirit!

Interesting to read about the timing issues and the effort your predecessors already have put into that to unlock the MLX90640 on the ESP32 on the first hand. Talking to I2C with tight timing requirements is always a bit tricky, as I recently learned from people chatting about that topic at the Späti around the corner.


#3

There is a MLX90640 camera with case from M5Stack:


#4

Wrong Orientation of the Sensor on the PCB

The MLX90640 sensor I’m using is a Spark-X product (“X” stands for eXperimental) and is a pre-series item for testing the market. It’s sold without guaranty. I think this is not possible in Germany, so I ordert it from an other European country.

On the PCB the sensor has “wrong” orientation, it is 30 - 40 ° 20 ° rotated. And so the picture is twisted also.

The product has left experimental status and is now regular sold on the Sparkfun page but has on the product page still the wrong PCB! Take notice of the solder joint’s positon in relation to the PCB edge.

in the datasheet you can see that the sensor should be nor rotated. The pins should be in parallel to the horizont.

So the Sparkfun orientation is wrong!

When you have a look at the pimoroni sensors it indicates also wrong orientation of the sparkfun products above:

The most interesting thing is the Qwiic IR Array (MLX90640) Hookup Guide - learn.sparkfun.com where you can find this pic. Now the sensor is no more rotated compared with the pics above:


#11

Comparison 55° FOV (Field Of View) and 110° FOV same distance to the radiator.


55° FOV


110° FOV


#12

Ugly, indeed. - This is how the MLX90640 bottom view is drawn in the datasheet:

image


part view as orginally created by Sparkfun (in Eagle library editor; top view):

image


part view in Sparkfun’s breakout Eagle design file (found a version 1.1; part is turned 90° CCW, top view):


So obviously, the better-aligned version 1.2 seem to have never made it into current production run for whatever reason(s) - if the pictured product is the sold one.

But to be honest, let’s rather call it a design quirk than just wrong… these are still prototyping parts, no complaints! ;)


#13

Seems that Sparkfun had the same problems as we now. The “rotated” bottom view on page 56 in the Melexis’ datasheet you posted @weef is inconsistent to page 10 Figure 3 in the same document, that I posted above.

Based on my observation / tests this would be the correct orientation (provided that the sensor was not changed in the meantime):


So I hope this is the currently sold version and not the version as shown on the product page.

Sparkfun calls the SparkX products “experimental” (what I have ordered some month before) but the currend product is not called experimental. So I hope this is corrected. And you can see on the pimoroni part that other have done their homework and performed at least a basic test before going in mass!