Thermal Camera

by Stargrove1 Feb 20, 2018
Download All Files

Thing Apps Enabled

Please Login to Comment

I uploaded Manauto code - unit boots and halts at first screen - sensor : found but readings: fail.

with the code in stl files - both work fine !

Ps - i did not connect the sd connections nor added the button !

MLX90640 32*24 Thermal Imager Array looks like a huge upgrade over the amg8833.
On Aliexpress it's going for ~£58.

If I had the programming skills, hint hint ;-) I'd be all over it.

That would definitely increase the resolution. Before using this sensor, you might think of getting for example a HT 175 camera with 32x32 sensor which are available at around 90 £.

But does the HT-175 have a interpolated* mode? And where's the fun in just buying a ready made thermal cam! :-)

*I have a vague idea what interpolation is but will pretend I know what I'm talking about in order to convince Stargrove1 to have a look at the sensor ;-)

I am pretty sure they are using interpolation as well, when you have a look at the sample pictures, you can see that the pictures use more than only 32 x 32 pixels. It is very common to increase the optical resolution of a sensor by sw. It simply calculates a value between existing information.

See this article: https://www.cambridgeincolour.com/tutorials/image-interpolation.htm

Thank you for creating this. I am having some problems with the programming part. I purchased the wemos and touchscreen from your ali links and the adafruit thermal camera. I wired based on the latest diagram. I have loaded the sketch (not sure I'm doing everything in arudino right), and I'm getting alot of nonsense on the screen. For the min/max temps i have 0/1077XXXXXX 0/10780XXXXX (the x's keep changing). I also don't understand the part in the instructions about:

for ESP8266 (folders ending with TFT_eSPI) version, TFT_eSPI ZIP import from (https://github.com/Bodmer/TFT_eSPI)
For ESP8266 versions, uncomment the following lines in User_Setup.h:
define ILI9341_DRIVER

define TFT_CS PIN_D8 // Chip select control pin D8
define TFT_DC PIN_D3 // Data Command control pin
define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V

Can you point me to a guide to follow to setup arudino (software), load the right libraries, make the changes in the sketch and load? Thank you again.


since I have merged the code, it is no longer required to adapt the code to the used board as the information is handed from the IDE and included by IFDEF.

If you don't get a compile error, libraries should be fine, if there would be missing something, you usually get a compile error from the IDE.

About the issue with wrong data display, is the visual part working and you can see the thermal image while only the min/max display wrong, or doesn't it work at all? If nothing is working, please download the adafruit example which only drives the amg8833 and forwards the data to the serial monitor to check the connections of the sensor first.

Thanks for responding and helping me figure this out. The visual part is working and I can see the thermal image. It is only the min/max parts that are wrong.

The values should only change if the autoscale function gets called by touching the screen, as you wrote "(the x's keep changing)" does this happen all the time? If so, please check if the touch output is wired correctly

Besides this, the values seem to be wrong, initial values are 25-35 deg. Can you provide a picture of the display to better see the output?

I just found that I introduced a bug while trying to fix another bug. I have uploaded a new version of the arduino sketch. Please flash the latest version and try again. This should fix the temperature display.

I downloaded and attempted to flash the new sketch. 1.jpg is the first error I got. I deleted the "//Draw battery symbol" section and then tried again. 2.jpg is the next error I got, I deleted the "// Update battery every 30s" section and tried again. 3.jpg is the final error I got, not sure how to overcome it.

Since a lot of people had issues with the min/max function in combination with the ESP8266, I simply replaced it by a simple if statement which does the same trick.

I have uploaded the change, can you please check if it works for you? I have flashed both variants to my camera successfully (but the prev. versions worked as well, I am using IDE 1.8.3, perhaps there is a difference in the compiler or at the installed libraries).

Its working now, thank you very much for all your support!!! One last question if I may please, by chance is there a way to display temps in Fahrenheit instead of Celsius (for us non metric folks).

I have added a define, change the line from:

define METRIC;


define IMPERIAL;

before flashing to get Farenheit readings

This worked perfectly. Thanks so much for your support!

Great, have fun with it and I would love to see a "made" here :-)

Made! :o) Thanks again!!

I have modified the sketch, now it supports saving image data to SD:
Moreover I made a small python program which makes a .png image out of this data!

I'd really appreciate it if you could add this link to the description too ^^

If you happen to have some free-time, it would be great if you could make a new / modified model which has an SD-card cutout!

I have attached some processed images:

Cool, thank you for sharing the code. I will add it of course, someone in the comments just asked for this feature. I had a look at the github site, if possible, can you add a schematic (I can provide the fritzing sketch I created for the picture section) showing how to wire up the SD card, as not so experienced users might want to use it too?

Free time .... that would be cool ;-) I try to do it after my business trip next week, as it should be just a slot to the side.

I totally forgot to add, that a "capture image" button is needed too. It would be useful to integrate it into the handle somehow, maybe like a trigger of a gun.
Personally I'd find it very useful to have a way to charge the battery without having to open the top cover. Maybe you could add a small hole for a micro-usb port.

Thanks for including my link!
Here's the schematic: https://easyeda.com/Manuauto/arduino_thermal_camera_with_sd_and_img_processing

I'll update my code soon since I haven't received the 2.8" screen just yet. Currently I use another smaller screen to test things out.

Maybe you could include a link to my small adapter, for those of us using the cheaper boards from Aliexpress: https://www.thingiverse.com/thing:3066479

AMG8833 Thermal Camera Mounting Adapter
by Wi_Zeus

As suggested, I added the link. Thank you

I understand it would cost more, but is it possible to buy a better sensor for this? Basically I'm after building something that could pick up heat from a person up to about 30M away. My intention is to use it for playing airsoft, so making it easier to see snipers hidding in bushes. But these apear to only work up to about 7M. Thanks for your help :)

Sure, If you want to use a Flir Lepton, performance will be way better, but it also costs around 300€. You might wanna also use a better µC as well, like a Raspberry Pi shown in this video https://www.youtube.com/watch?v=X92f6WH-qvg

Thank you, I've looked that up and followed the comments online and what seems best for my needs would be to actually buy a camera and just make a protective case for it. The Seek Thermal Compact looks pretty good, and not much more than the sensor you suggested.

You are right, that might be best option for your needs

Yes it fits in easily, you just need to take care of the wiring

Does an 18650 Battery fin in the case? It would be nice if I could use one!
Measuring with 3D Builder I get reassuring results... ^^

Regarding Error: no matching function for call to 'max(uint16_t&, float&)'

Change (line 105 and 106 in ThermalCameraMod):

uint16_t MinTemp = 25;
uint16_t MaxTemp = 35;


float MinTemp = 25.0;
float MaxTemp = 35.0;

Please note that I have only compiled the code and haven't tested in on actual hardware. At least this gets rid of the error.

Thank you for the hint. I wonder why I didn't get this compile error using the same data type

Hello, thanks for your work, I have decided to make the thermal camera, but I want to be able to capture the image and store it in a sd, I am using the original set proposed by "adafruit" but it throws me an error between the variables "max" and "min "As well as to graph the battery, there is a conflict between the SD library and these variables, I do not know why, I would like to know if you can help me solve this and if you have any idea of how to capture the pixels on the screen and convertilos in an image to record in a micro SD card, a lot of work hahaha, I appreciate any help, suggestion, link, or any other idea that may arise.

I have made some changes to the sketch, it can now save image data to SD. This data has to be converted to an image file with your computer.

How bout directly writing a BMP file, for small pictures filesize wouldn't matter, as it seems an arduino/esp8266 couldn't handle compressed formats like JPG or PNG.

I found a lib to save BMPs, perhaps you can rework your code to get rid of the data conversion:


Hi Joshua, can you give some more details about the errors? I think there are several tutorials about writing a bmp file to sd card (http://www.linksprite.com/tutorial-of-using-jpeg-camera-to-capture-a-picture-and-save-to-sd/), just use them as starting point. I think I have already seen a project like this where sd support was added, I will check if I can find it again.

Hi Stargrove1,

Thanks for the great thermal camera. I printed it out in PETG on a Prusa i3 MK2 and found that the top cap didn't clip on at all.Will be working on a better housing that will utilise the mounting holes in the various boards. I am also very new to this Arduino game and I have found the process of wiring it together very confusing. Could you include a wiring schematic, the photo you have doesn't help much specially with the placement of the switch and the resistor.

Also is it possible to wire the switch in, in such a way that you can use the charging circuit on the battery shield, that would seem like a good idea so that you don't have to take it apart to charge the battery.

Speaking of the battery, how did you wire in the battery, it looks like you have some sort of adapter, the battery shield you recommended has a different connector to what is fitted to most common Lipo batteries.


Hi Stargrove1,

Thanks for the circuit diagram, makes heaps more sense now.

Tim :-)

Hi Tim,

when I made the housing, I left a small gap between the parts and it worked fine when printed in PLA (which I mainly use). Of course its possible that other materials don't fit that well. Usually I avoid to use clips in any way, I prefer screwed designs.

You are not the first persons who asks about the wiring, I thought the table showing the connections is good enough, but I guess I should add a graphical wiring diagram for less experienced users. I will try to add it as soon as I find the time.

The problem with the battery shield is, there is no point to interrupt the power from the shield to the Wemos, as soon as the battery is plugged (and could be charged) the processor is supplied. You would need to modify the shield and add a switch between the shield output and the Wemos input. Right now, the camera needs to be powered to charge the battery, which I was willing to accept.

The connector of the Lipo is from a small drone which was laying around, it fits in a JST-XH connector when the small noses are removed. And at the shield I used the JST connector which fits

Do you think this AMG8833 will do the work?
AMG8833 3-5v 8*8 I2C IR Infrared Temperature Thermal Camera Imaging Sensors Grid-EYE Breakout Board For Arduino Raspberry Pi
Thanks in advance for an answer.

Hi Kris, I am pretty sure this will work. It is the correct chip and the shown screen shot is the result of reading the ir array by the adafruit example. Last time I checked AliExpress, the price was around 50€

Thanks :-)
Take care

Today I have succeeded to put parts together, do the wiring and upload firmware to Wemos.
I got first temp readings but I couldn't find the firmware with temp scale you showed in the movie.
Could you tell me which one should I choose?
Thanks in advance.

Hi Kris,

I am happy to see your progress, actually both firmwares used in my screenshots/movie are added as arduino sources along with the stl files. Just download the zip "Arduino_sketch.zip", unzip and flash either ThermalCameraMod.ino (more advanced interpolation, more colors, lower framerate) or Thermal_cam_interpolate.ino (simple interpolation, fewer colors, higher framerate, based on adafruit example). Both include the temperature graph.

It worked :-)
I am just waiting for powerbank and I will share final photos of my camera :)
Take care!

Great, I am glad to hear that it is working now. Have fun with the camera

I wrote a lengthy question yesterday but then pressed the wrong button and it vanshed. So once again!

Thank you for all your hard work in designing and uploading this, Stargrove1.
I've now received all the parts to make your version of the thermal cam. While I was buying stuff from Ali-ex I bought a " esp8266 oled 18650" which is an all in one development board, Esp-12+0.96" black and white ssd1306 oled+ battery holder+5 direction keypad.This http://www.raspberrypiwiki.com/index.php/WEMOS_ESP8266_Board_with_OLED_%26_18650_Battery_Holder .It arrived weeks before the wemos minis did so have been tinkering.
I would like to use your sketch on the all in one, as well as build your version :-). I was super excited when I found your project and bought two sensors :-I. I have found and soldered wires on the SDA, SDC of the all in one dev board so I can plug the amg8833 in to the dev board as I2C works in parallel. I'm fine with the hardware side but software is another matter altogether and as a noob I have no idea where to start in converting sketches from one form of hardware to another.
Example of thermal cam running on a tiny oled https://hackaday.io/project/1389-grid-eye-ble-capable-thermal-camera

How would you go about converting sketches between hardware or would you not bother and just start from scratch?
I've googled far and wide for an answer but nothing was really forth coming.

It depends, I avoided to start from scratch, since nearly all processors are programmably with the arduino IDE, the grid eye sensor is driven correctly and most of the displays are easily controllable by libraries. Usually, only the IOs needs to be adapted. In the case of the camera, I had to replace some libraries which were only for the Teensy 3.2, but that is way less effort than starting with a new programm.

I am not a professional as well :-)

Thanks for the reply!

Hopefully I'll be printing the case today! I had a problem trying to get more ground and vcc points to the other shields from the battery shield but that was solved by soldering extra wires to the 3.3v and gnd pins from said shield.

So essentially the Arduino IDE programming syntax works on all the boards in the board manager section. You just have to change the IO(pins), replace with more compatible libraries if you switch hardware and comment out // sections and definitions you have no need for?

A lot of those small boards are compatible with arduino IDE and could be programmed in C. The two softwares I adapted were created for Teensy 3.2 and Adafruits Feather series, both are programmable with arduino IDE, for the Teensy version a special display driver with higher performance was used, I went for the standard driver which was working, but quite slow, then I found an optimized driver for the ESP processor which I added for better performance. Since the boards have different IOs, the I2C/SPI pins are different and need to be changed in the setup. The rest was my personal requests like temperature value display, battery gauge, autoscale feature.

Did you ever experience phantom sensors on the D1 mini? Got everything plugged in and running but the wemos is saying that the sensor is plugged in but it's not.
I changed ThermalSensor back to amg to match the other examples. Makes other amg8833 sketches easier to read and compare.

// let sensor boot up
bool status = amg.begin();

// check status and display results
if (!status) {
while (1) {

Seems like the D1 mini is ignoring the code to check for the thermal sensor as I'm not getting any error text when the sketch is uploaded and run on the wemos but without the thermal cam plugged in!.

And could you please upload your very latest sketch as I ran into some errors when compling:

no matching function for call to 'min(uint16_t&, float&)'

I've fixed it but as a noob I'm not sure if it's the right way or not.

Just a quick update!

Fixed! Got the thermal sensor working!!!

Just need to build a couple of rails for the 3.3v and gnd then stick it in the the printed box!!

Thanks a lot Stargrove 1 for sharing this great project, seems very cool !
Gatchaman, I have the same error than you :
"no matching function for call to 'min(uint16_t&, float&)'
I've fixed it but as a noob I'm not sure if it's the right way or not."
Do you remember how did you fix this problem ? I have got this error with both codes (adafruit code and Kasprzak) with wemos.

Hello ucino,

have you imported all required libraries as described under software?

Adafruit AMG88xx Library
Adafruit ILI9341
Adafruit GFX Library
for ESP8266 (folders ending with TFT_eSPI) version, TFT_eSPI ZIP import from (https://github.com/Bodmer/TFT_eSPI)

If Arduino IDE could not compile something, usually a library is missing.

Hello Stargrove1,
Thanks for your reply.
I have installed Adafruit AMG88xx Library v. 1.0.2, Adafruit ILI9341 1.0.12, Adafruit GFX Library 1.2.3 and imported yesterday the zip from github.

I have this error message :
"ThermalCameraMod.ino/ThermalCameraMod.ino.ino: In function 'void SetTempScale()':
ThermalCameraMod.ino:467: error: no matching function for call to 'max(uint16_t&, float&)'
MaxTemp = max(MaxTemp, pixels[i]);

ThermalCameraMod.ino.ino:467:39: note: candidates are:
In file included from [...]/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2/algorithm:62:0,
from [...]/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/Arduino.h:254,
from sketch/ThermalCameraMod.ino.ino.cpp:1:

[...]/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare)
max(initializer_list<_Tp> __l, _Compare __comp)

[...]/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed:
[...}/ThermalCameraMod.ino/ThermalCameraMod.ino.ino:467:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short unsigned int'
MaxTemp = max(MaxTemp, pixels[i]);

and there is other.
and at the final :
[...]/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed:
[...]ThermalCameraMod.ino.ino:467:39: note: deduced conflicting types for parameter 'const _Tp' ('short unsigned int' and 'float')
MaxTemp = max(MaxTemp, pixels[i]);
exit status 1
no matching function for call to 'max(uint16_t&, float&)'

Maybe it's a conflict beetwen library that I have installed before ?

My programming skills are limited, but it seems that the max function has an conflict with the data types. You can try to downlaod the arduino IDE and copy it to a new location, then install the required libraries again and try to flash.

Thanks for your feedback. I have used an other OS (ubuntu) and make a fresh install of arduino 1.8.5, installed all the libraries and for the wemos, and I still have this error. So it seems it's not a library conflict.

If I comment this line, the compilation is ok :
// MaxTemp = max(MaxTemp, pixels[i]);
It's strange that
MinTemp = min(MinTemp, pixels[i]);
doesn't make a problems.

It's also strange that I have this problem with both codes of adafruit and Kasprzak.

Stargrove1 do you knox if you can compile the actual code of adafruit and Kasprzak that is in the zip ?

Yes of course, others has been able to compile as well, as you mentioned the MinTemp in the same context is working properly. As you can see in the screenshots, both versions of the sw has been flashed successfully.

As a workaround, you can replace the line "MaxTemp = max(MaxTemp, pixels[i]);" by:

if (pixels[i] > MaxTemp) { MaxTemp = pixels[i];}

This will also return the maximum of the two values which is used for the temperature scaling

Great, well done, it works very well :) Thanks a lot. Now il will try the hardware :)

Wow... it works so well ! Fantastic job, thanks a lot Stargrove for this hard job and so cool result !!!
If someone have a black screen, please consider that Pin D3 and D8 have been swapped.
Next step will be the battery, and then the printing :)

I am glad you like it, actually it was pretty simple, Adafruit and Kris did a great job with their code, the rest was no big deal.

Regarding the swapped pins, did that happen in your setup or is it a failure in the description I need to update?

oups i did a wrong manip I have flaged my reply :)

Let's add it an other time :

Thanks a lot for your reply. You did also a great job explaining clearly this project.

Here some ideas for updating :

  • In fritzing and in the picture table, update D3 and D8 swap ?
  • in the comments of Kasprzak update D1 and D2 swap ? (and maybe D3 and D8 I didn't care about them)
  • In the thingiverse description of this project, update maybe about this part :
    "For ESP8266 versions, uncomment the following lines in User_Setup.h:
    define ILI9341_DRIVER
    define TFT_CS PIN_D8 // Chip select control pin D8
    define TFT_DC PIN_D3 // Data Command control pin
    define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V"
    -> maybe you could add that is for the TFT_eSP library ?
    -> this is already uncommented now : define ILI9341_DRIVER ; define TFT_CS PIN_D8 // Chip select control pin D8 ; define TFT_DC PIN_D3 // Data Command control pin , you maybe can add "Check that ... is already uncommented" ou you can delete it ?
    -> this line need effectively to be uncommented : define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V"
    -> I don't know if the previous line (#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)) need to be uncommented, I have commented it but this is maybe a mistake ?

Thanks a lot for your feedback. You made also a great job explaining all the steps clearly.

Here some ideas for things that maybe could be updated:

  • the picture of fritzing and and the picture of the table need to be updated for D3 and D8 ?
  • the comments of Kasprzak code, at the start, need to be updated for AMG833 : D1 and D2 needs to be swapped ? (and maybe for D3 and D8, I didn't care ?)

On other way to improve the tutorial is maybe about this, in the description of the thingiverse page :
"For ESP8266 versions, uncomment the following lines in User_Setup.h:
define ILI9341_DRIVER
define TFT_CS PIN_D8 // Chip select control pin D8
define TFT_DC PIN_D3 // Data Command control pin
define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V"

  • Saying that's for version, TFT_eSPI ;
  • define ILI9341_DRIVER ; #define TFT_CS PIN_D8 // Chip select control pin D8 ; and #define TFT_DC PIN_D3 // Data Command control pin are already uncommented ;

  • this "define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V"" is commented and effectively need to be uncommented ;
  • There is something I'm don't know : there is "#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)" it's uncommented by default, I commented it but maybe it's not necessary to comment it, no ?I did wrong commenting it ? (as "define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V seems similar, but I'm not sure)

Sorry for the late response, but I am glad that you already got it fixed by yourself.

I have uploaded the latest sketches already, I haven't done any change in addition.

I hope so see a built picture from your camera here in Thingiverse

I found this thread about checking I2C pins and inserted the code into a sketch for the cam. Ran the code then took the code out of the sketch and the cam worked. Very strange.....
Post #41315

There is a lot going on in the case, and I need to get rid of the extra wires I soldered on to the 3.3v and ground. So far I have managed to avoid the magical blue smoke.....
One more question before I leave you alone ;-). The image on the screen has been flipped 90 degrees to the left. So if I was to put my fingers at the top of the cam then my fingers would appear coming in from the left on the screen. Before I go back into the sketches to look for how to rotate the image 90 degrees to the right did you ever run into that problem?

https://www.youtube.com/watch?v=NQ5eJJgpIh0 Check the post by Daniel Draghici which looks interesting.
Thank you for all your work!!!!!! :-D

I didn't have any issues with the I2C connection, the adafruit example to read the array to serial worked right out of the box.

About the rotation, I think it is not 100% clear since the pcb is a square, I just turned the camera pcb to fit the orientation of my display, I think it is actually 90° rotated to the datasheet, but this was also the case in the sketches I used to adapt.

The flipp is already done by the sw as both examples have been built to point the camera to the front while the display is on the back, you can see it at my sample pics


Hi Stargrove. Please double check your pins for I2C on your wiring diagram ...... ;-)
Oh and I figured out how to correct the image rotation problem.......just rotate the sensor :-D, but that causes parts not to fit in the moddified case.

Yes you are right, thank you for the correction, I have updated the table.

Please check out my version of your cam. :-)

Nice one, I like the solution with the power bank in handle, I thought of it too, then I saw the battery shield and included it in the housing. How is the performance of the "camera"?

So far so good on the performance side!!! In the future I might enlarge and hollow out your handle so I can incorporate the battery.

Have a look at this https://www.youtube.com/watch?v=B0bwkED03-g
Just got my lens through the post and I have no idea if and what effect it will have on the cam as the 8x8 resolution might be too low plus I'm going to have to add the abilty to attach the lens to the camera case which might take some time as I'm not going to be near my printer for a while.

When I get the chance I'll design a lens holder that attaches to the main body using magnets.

Where did order the lens? I am afraid the "resolution" 8 x 8 is to low for enhanced detail as shown in video, but I am crossing fingers, perhaps you upload a comparison like done in the video.

The lens came from Ali-X for £8 a piece. Yeah it's only a 8x8 sensor but you never know a cheap 16x16 sensor could come out in the future and atleast the lens will be here if and when they do sell them :-).

Got the lens and manually placed it in front of the cam at what I guessed was the max focal length and it zoomed in from what I saw on the screen.

Wish I had carried on tinkering with my cheap UNO which I bought 3-4 years ago that has been sitting here gathering dust....... Sigh...

Humble Bundle are doing DIY Electronics books bundle. Might invest in it.

Printing out a 5% mock up to see if my parts can fit in your case.

Comments deleted.

Thank you, the code is part of the download files, both variants are added in an zip file