Luo Zeqing
Published © GPL3+

DIY a Thermal Imaging Monitor

In this project, I will DIY a thermal imaging monitor using the ESP32-S2 parallel TFT touch screen and the MLX90640 Thermal imaging camera.

IntermediateFull instructions provided3 hours614
DIY a Thermal Imaging Monitor

Things used in this project

Hardware components

ESP32-S2 Parallel TFT with Touch
×1
MLX90640 Thermal Imaging Camera
×1

Story

Read more

Code

Code snippet #1

Plain text
Void filter_frame(float *in, float *out)	
	{
    if (MLX_MIRROR == 1)
    {
        for (int i = 0; i < 32 * 24; i++)
        {
            out[i] = (out[i] + in[i]) / 2;
        }
    }
    else
    {
        for (int i = 0; i < 24; i++)
            for (int j = 0; j < 32; j++)
            {
                out[32 * i + 31 - j] = (out[32 * i + 31 - j] + in[32 * i + j]) / 2;
            }
    }
	}

Code snippet #2

Plain text
void qusort(float s[], int start, int end) 
{
    int i, j;       
    i = start;      
    j = end;        
    s[0] = s[start]; 
    while (i < j)
    {
        while (i < j && s[0] < s[j])
            j--; 
        if (i < j)
        {
            s[i] = s[j]; 
            i++;        
        }
        while (i < j && s[i] <= s[0])
            i++; 
        if (i < j)
        {
            s[j] = s[i]; 
            j--;        
        }
    }
    s[i] = s[0]; 
    if (start < i)
        qusort(s, start, j - 1); 
    if (i < end)
        qusort(s, j + 1, end);
}

Code snippet #3

Plain text
//Transform 32*24 to 320 * 240 pixel
void interpolation(float *data, uint16_t *out)
	{
	
 
	    for (uint8_t h = 0; h < 24; h++)
	    {
	        for (uint8_t w = 0; w < 32; w++)
	        {
	            out[h * 10 * 320 + w * 10] = map_f(data[h * 32 + w], MINTEMP, MAXTEMP);
	        }
	    }
	    for (int h = 0; h < 240; h += 10)
	    {
	        for (int w = 1; w < 310; w += 10)
	        {
	            for (int i = 0; i < 9; i++)
	            {
	                out[h * 320 + w + i] = (out[h * 320 + w - 1] * (9 - i) + out[h * 320 + w + 9] * (i + 1)) / 10;
	            }
	        }
	        for (int i = 0; i < 9; i++)
	        {
	            out[h * 320 + 311 + i] = out[h * 320 + 310];
	        }
	    }
	    for (int w = 0; w < 320; w++)
	    {
	        for (int h = 1; h < 230; h += 10)
	        {
	            for (int i = 0; i < 9; i++)
	            {
	                out[(h + i) * 320 + w] = (out[(h - 1) * 320 + w] * (9 - i) + out[(h + 9) * 320 + w] * (i + 1)) / 10;
	            }
	        }
	        for (int i = 0; i < 9; i++)
	        {
	            out[(231 + i) * 320 + w] = out[230 * 320 + w];
	        }
	    }
	    for (int h = 0; h < 240; h++)
	    {
	        for (int w = 0; w < 320; w++)
	        {
	            out[h * 320 + w] = camColors[out[h * 320 + w]];
	        }
	    }
	}

Github

https://github.com/adafruit/Adafruit_MLX90640

Github file

https://github.com/Makerfabs/ESP32-S2-MLX90640-Touch-Screen-Thermal-Camera/tree/main/firmware/Thermal_Camera_V2

Credits

Luo Zeqing

Luo Zeqing

46 projects • 14 followers
Makerfabs ESP32/ Lora/ Lorawan, IoT Hardware

Comments