Apologies if this has been reported elsewhere but, if it has, I couldn’t find it. I’ve been doing the Pimoroni project Build a Thermal Camera with Tufty 2350 and MLX90640 - Pimoroni and I ran into some software errors at the end which prevented it from running. With the help of Claude I have modified a few lines of code and got it working successfully. Great project!
The error message reported was:
Error!
File “badgeware/_init_.py”, line 32, in launch
File "/system/apps/thermal_camera/_init_.py, line 19, in
File "/system/apps/thermal_camera/mlx90640.py, line 120, in _init_
File "/system/apps/thermal_camera/mlx90640.py, line 339, in _extract_parameters
File "/system/apps/thermal_camera/mlx90640.py, line 754, in _extract_deviating_pixels
File "/system/apps/thermal_camera/mlx90640.py, line 765, in _unique_list_pairs
TypeError, ‘set’ object isn’t subscribable
I seem to have a dead pixel so maybe that helped trigger the errors but anyway, Claude suggested amending the def _unique_list_pairs block in mlx90640.py to be
def _unique_list_pairs(self, input_list):
input_list = sorted(input_list)
for i, list_value1 in enumerate(input_list):
for list_value2 in input_list[i + 1:]:
yield list_value1, list_value2
I then found the dead pixel was reporting -273 degrees which compressed the useful pixel readings to a point of being unuseful. Claude suggested two fixes in __init__.py
-
Straight after the
try/acceptblock, insert this# pixels the driver flags as faulty come back as -273.15, so we patch them below bad_pixels = mlx.broken_pixels | mlx.outlier_pixels -
The second fix goes inside
update(), in thetry:block. Add the extra second line:try: # Get the frame data from the MLX90640 mlx.get_frame(raw_frame) # replace faulty pixels with their neighbour's reading for p in bad_pixels: raw_frame[p] = raw_frame[p - 1] if p > 0 else raw_frame[p + 1] frame = numpy.array(raw_frame)
Maybe Pimoroni could review this and see if tweaks to the Github code are worthwhile?
Thanks, great project.