Electronic – chessboard pattern data from IR sensor MLX90640

sensor

I'm developing an algorithm using esp32 with MLX90640 IR sensor.

After I read data frames and calculated the temperature, the temperature values see a strong chessboard-pattern style. See images below (raw temperature data)

temperature visualize

Part of measured values:

I marked some obviouslly abnormal points.

And here is my core measuring code :

    int expectFrame = 0;
    int subPagesRead = 0;
    while (true) 
    {
        while (subPagesRead < 2) {
            vTaskDelay(250 / portTICK_RATE_MS);
            status = MLX90640_GetFrameData(0x33, mlx90640Frame);
            if (status != expectFrame) {
                continue;
            }
            expectFrame = 1 - expectFrame;
            subPagesRead++;
            float tr = MLX90640_GetTa(mlx90640Frame, &mlx90640) - TA_SHIFT;
            MLX90640_CalculateTo(mlx90640Frame, &mlx90640, emissivity, tr, mlx90640To);
        }
        // output mlx90640To
        memset(mlx90640Frame, 0, sizeof(mlx90640Frame));
        memset(mlx90640To, 0, sizeof(mlx90640To));
        subPagesRead = 0;
    }

Am I measuing in a wrong way? Or any other possible reasons?

(This frame is calculated at 4Hz refresh rate on a esp32 chip)

Best Answer

So I opened an issue in the official github API library repo. And @LBuydens at Github pointed out the lack of power decoupling capacitors could be a reason leading to this striped pattern. Then I read the data sheet again, and found this paragraph at the very end:

Power supply decoupling capacitor is needed as with most integrated circuits. MLX90640Bxx is a mixed-signal device with sensors, small signal analog part, digital part and I/O circuitry. In order to keep the noise low power supply switching noise needs to be decoupled. High noise from external circuitry can also affect noise performance of the device. In many applications a 100nF SMD plus 1μF ceramic capacitors close to the Vdd and Vss pins would be a good choice. It should be noted that not only the trace to the Vdd pin needs to be short, but also the one to the Vss pin. Using MLX90640Bxx with short pins improves the effect of the power supply decoupling.

With the help of our hardware engineer adding these two capacitors, I finally got a normal frame. Though small temperature difference still exists (likely < 0.5 degrees), it can be ignored.

Temperature measured now