{"id":28755950,"url":"https://github.com/johnbigeon/thermal_cam_micropython","last_synced_at":"2026-04-29T14:05:17.226Z","repository":{"id":298117915,"uuid":"989539475","full_name":"JohnBigeon/Thermal_cam_micropython","owner":"JohnBigeon","description":"Micropython code to display MLX90640 thermal image on ST7735 LCD screen","archived":false,"fork":false,"pushed_at":"2025-06-09T13:25:35.000Z","size":48088,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-09T14:26:43.837Z","etag":null,"topics":["esp32-c3","micropython","mlx90640","st7735","thermal-camera"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JohnBigeon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-24T09:58:37.000Z","updated_at":"2025-06-09T13:25:38.000Z","dependencies_parsed_at":"2025-06-09T14:39:19.904Z","dependency_job_id":null,"html_url":"https://github.com/JohnBigeon/Thermal_cam_micropython","commit_stats":null,"previous_names":["johnbigeon/thermal_cam_micropython"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JohnBigeon/Thermal_cam_micropython","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBigeon%2FThermal_cam_micropython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBigeon%2FThermal_cam_micropython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBigeon%2FThermal_cam_micropython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBigeon%2FThermal_cam_micropython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JohnBigeon","download_url":"https://codeload.github.com/JohnBigeon/Thermal_cam_micropython/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBigeon%2FThermal_cam_micropython/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260281567,"owners_count":22985626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp32-c3","micropython","mlx90640","st7735","thermal-camera"],"created_at":"2025-06-17T03:01:09.728Z","updated_at":"2026-04-29T14:05:17.221Z","avatar_url":"https://github.com/JohnBigeon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thermal imagery MLX90640 and ST7735 with micropython\n\n\n## Concepts\nThe concept of this project is to display the MLX90640 imagery on a ST7735 LCD screen on esp32-c3 board with micropython.\n\n\n\u003ctable align=\"center\"\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cimg src=\"Pictures/thermal_display_v01.jpg\" height=\"300\"/\u003e\u003cbr/\u003e\n      \u003cb\u003eDisplay of the MLX90640 image via a ST7735 LCD display.\u003c/b\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cimg src=\"Pictures/native_micropython_real_time_v01.gif\" height=\"300\"/\u003e\u003cbr/\u003e\n      \u003cb\u003eThermal image display via native micropython strategy.\u003c/b\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cimg src=\"Pictures/optimized_precompiled_real_time_v01.gif\" height=\"300\"/\u003e\u003cbr/\u003e\n      \u003cb\u003eThermal image display via precompiled micropython strategy.\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\n## Components\n### Preparation of MLX90640 for i2c communication\nTo enable the i2c communication of the MLX90640, the i2c pins should be soldered as mentioned here [https://github.com/adafruit/Adafruit_CircuitPython_MLX90640/issues/19].\n\n\n### Wiring\nConnect the devices as follow:\n\n- pin_cam_sda = 20\n- pin_cam_scl = 21\n- pin_scl = 5\n- pin_sda = 2\n- pin_res = 0\n- pin_dc  = 3\n- pin_cs  = 9\n\n\n### Breadboard\n\u003ctable align=\"center\"\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cimg src=\"Pictures/breadboard_v01.jpg\" width=\"200\"/\u003e\u003cbr/\u003e\n      \u003cb\u003eBreadboard integration for debug purpose.\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\n## Software versionning\nDifferent version of this software is proposed:\n\n- *Native_micropython* is based on a micropython firmware with uploaded librairies. It's obviously slow since my code send each pixel individually (via x,y positions). In theory, I should be able to send stream of data, but not able to find it via micropython.\n\n- *Precompiled_micropython* is based on a micropython firmware with embedded ST7735 [https://github.com/russhughes/st7789_mpy]. It's based on the driver written in C, which should be more efficient (i.e.: should send stream of data instead).\n\n- *Precompiled_optimized* is based on a micropython firmware with embedded ST7735 [https://github.com/russhughes/st7789_mpy]. Here, the colorometry conversion is optimized too.\n\n\n### Native micropython installation\n\nThe main script *main.py* should load these two librairies and upload the image received from the thermal camera on the LCD display.\n\n\n#### Micropython firmware\nFirst, upload the generic esp32-c3 firmware via:\n\n```\nesptool --port /dev/ttyACM0 erase_flash\nesptool --port /dev/ttyACM0 --baud 460800 write_flash 0 ESP32_GENERIC_C3-20250415-v1.25.0.bin\n```\n\n\n#### Upload typing\nExecute the following script from you linux terminal:\n\n```\nsudo apt install micropython-mpremote\nmpremote mip install github:josverl/micropython-stubs/mip/typing.mpy\n```\n\nyou should see:\n\n```\nInstall github:josverl/micropython-stubs/mip/typing.mpy\nDownloading github:josverl/micropython-stubs/mip/typing.mpy to /lib\nInstalling: /lib/typing.mpy\nDone\n```\n\n### Precompiled micropython installation\nFollow that:\nhttps://github.com/micropython/micropython/tree/master/ports/esp32\n\n#### Clone ESP-IDF\n\n```\ngit clone -b v5.4.1 --recursive https://github.com/espressif/esp-idf.git\n\ncd esp-idf\ngit submodule update --init --recursive\n\n./install.sh  esp32c3\nsource export.sh\n```\n\n\n#### Clone MicroPython\n```\ncd ..\ngit clone https://github.com/micropython/micropython.git\ncd micropython\n\ngit submodule update --init --recursive\nmake -C mpy-cross\n\ncd ports/esp32\nmkdir -p /home/jbi/Micropython_prod/micropython/ports/esp32/user_c_modules\ncd /home/jbi/Micropython_prod/micropython/ports/esp32/user_c_modules\ngit clone https://github.com/russhughes/st7789_mpy.git\n```\n```\nnano micropython.cmake\n ```\nadd\n```\ninclude(${CMAKE_CURRENT_LIST_DIR}/st7789_mpy/micropython.cmake)\n```\n```\nexport IDF_TARGET=esp32c3\nmake BOARD=ESP32_GENERIC_C3 USER_C_MODULES=/home/jbi/Micropython_prod/micropython/ports/esp32/user_c_modules clean\nmake BOARD=ESP32_GENERIC_C3 USER_C_MODULES=/home/jbi/Micropython_prod/micropython/ports/esp32/user_c_modules -j$(nproc)\n ```\n\n#### Add to the frozen\n```\ncd /home/jbi/Micropython_prod/micropython/ports/esp32\ngit clone https://github.com/russhughes/st7789_mpy.git user_c_modules/st7789_mpy\ncd user_c_modules/st7789_mpy\n```\n\n#### Build with the C extension\n```\ncd ../../\nmake BOARD=ESP32_GENERIC_C3 USER_C_modules=user_c_modules/st7789_mpy clean\nmake BOARD=ESP32_GENERIC_C3 USER_C_modules=user_c_modules/st7789_mpy -j$(nproc)\n```\n\n#### Upload the firmware\n```\ncd build-ESP32_GENERIC_C3/\nesptool --no-stub --chip esp32c3 --port COM69 --baud 115200 write_flash -z 0x0 .\\firmware.bin\n```\n\n\n#### Source of the code\nThe display ST7735 and the sensor MLX90640 are based on the librairies deployed here:\n\n- ST7735 [https://github.com/boochow/MicroPython-ST7735]\n- MLX90640 [https://github.com/michael-sulyak/micropython-mlx90640]\n\n\n\n### Drawback of different strategies\nThe main actual drawback of the *native_micropython* is the slow fps display and the colorometry conversion (around 13s per frame).\nFor fast fps, please refer to the *all .cpp* script here [https://github.com/weinand/thermal-imaging-camera].\n\nThe issue with *Native_micropython* has been discussed here:\n\n- [https://www.reddit.com/r/raspberrypipico/comments/16q4jkj/help_finding_a_fast_library_for_18inch_st7735s/]\n- [https://www.reddit.com/r/raspberrypipico/comments/zx32ak/very_slow_refresh_rate_for_st7735/]\n\nFor precompiled and precompiled and optimized methods, 4.6s and 1.5 s are actually measured.\n\n## Debug purpose\nIf the thermal camera returns no image, please follow the Waveshare tutorial here [https://www.waveshare.com/wiki/MLX90640-D55_Thermal_Camera]\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbigeon%2Fthermal_cam_micropython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnbigeon%2Fthermal_cam_micropython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbigeon%2Fthermal_cam_micropython/lists"}