by Floris Wouterlood – The Netherlands – April 4, 2022
Summary
A breakout board with on it an AMG8833 8*8 pixel thermal infrared camera is connected with an Arduino Nano. Data are displayed on a 1.3 inch diagonal 240*240 pixel TFT screen with ST7789 controller. With this assembly we have at our disposal, with the smallest Arduino, a true thermal scanning unit.
Introduction
Everyone has seen in his lifetime a ‘thermal’ picture acquired with an infrared sensitive camera. False colors indicate which surfaces are hot and which are cool. Thermal cameras used to be pricey professional items and until recently they were beyond budget for Arduino aficionados. This situation changed completely with the arrival of affordable mini thermal cameras that fit your smartphone. Examples are the FLIR-One and the Seek Thermal.
What counts with every thermal camera is the resolution of the bolometer (the uncooled, on-chip matrix of thermistors that make up the infrared sensor). This resolution is expressed in pixels. Currently the FLIR-One works with a 160*120 pixel bolometer while a top model of the Seek Thermal range is advertised with a 320*240 matrix sensor. Yet while these are very handy heat sensors they are not available in this resolution in an Arduino compatible version.
figure 1. AMG8833 8*8 pixel thermal scanning sensor mounted on an Arduino-compatible mini breakout board. The breakout has six pins of which four are essential: VIN, GND, SCL (clock) and SDA (data). Communication is via the I2C protocol.
To my surprise an 8*8 pixel thermal scanner for Arduinos is on the market since approximately 2020, that is, a sensor mounted on a breakout board with i2c communication and ready to be used with an Arduino (figure 1). This development makes experimenting with thermal scanning within reach of every Arduino hobbyist.
The AMG8833 8*8 matrix infrared sensor
The Japanese electronics giant, Panasonic, produces the Grid-EYE AMG 88 infrared array sensor, a low-cost 8*8 pixel matrix sensor marketed for home appliances, energy saving devices, automatic door sensors and so forth (figure 1).
figure 2 Wiring diagram for an AMG8833, Arduino Nano and 240*240 TFT with ST7789A controller.
Temperature range is 0-80 oC with an accuracy of 2.5 degrees; vertical and horizontal viewing angles are 60 degrees; detection distance (of a human) is approximately 7 meters; frame rate is 10 frames per second. I2C address is 0x69. The breakout device is 3.3V-5V compliant.
Sensor device: probe holder
Typically a thermal imager needs to point towards the object to be scanned. From the designer point of view there are several options. The obvious solution is a ‘camera-like’ assembly wherein the sensor and the display are mounted on opposite sides of an assembly board. Another option is the ‘bench-like’ assembly with the sensor mounted next to the display, thus both pointing in the same direction. As I had constructed some time ago* a bench that includes an Arduino Nano and a suitable display, I took that bench and expanded it with a movable arm, a ‘probe holder’. The design of the probe holder is illustrated in figure 3.
figure 3. Probe holder: wiring scheme and pin connections for the AMG8833 thermal scanner breakout mini board. Note that 4.7k ohm pull up resistors are included in the design. Pull up resistors are essential in the I2C connections between the AMG8833 thermal scanning device and the Arduino.
This probe holder can easily be detached and connected to another bench in my collection.
Electronic components
probe holder
1x 6-pin AMG8833 thermal sensor breakout board
1x double-sided, 28*6 holes soldering prototyping board, 2×8 cm
1x 6-pin pin header socket with long pins
2x 4.7 kΩ resistor
wire
other equipment
Bench with Arduino Nano microcontroller board*
1x 1.3’ 240*240 pixel breakout TFT display, ST7789 controller, SPI interface (single-row, 7-pin header) – wiring diagram see Figure 2.
Wiring
The diagram in figure 2 shows all the wires that connect the microcontroller board, the display breakout and the AMG8833 breakout. Wiring for the thermal scanner breakout is the following.
Nano pin | AMG8833 breakout pin |
3V3 | VCC |
GND | GND |
A5 | SCL |
A4 | SDA |
Pins INT and AD0 of the AMG8833 breakout remain free. INT is a software controllable pin that can switch from LOW to HIGH when the temperature recorded by any of the pixels is above a certain threshold. AD0 is an optional pin meant to set the I2C address. If AD0 is set LOW the address is 0x68, and if set HIGH the address is 0x69. Default (AD0 not connected) is 0x69.
Library
Adafruit Industries provides and maintains the Adafruit_AMG88xx.h library. This software is downloadable from GitHub: https://github.com/adafruit/Adafruit_AMG88xx and is being used in this project. The library comes with several examples: AMG-88xx_interrupt, AMG_88xx_test, pixel_test, thermal_cam, thermal_cam_featherwing and thermal_cam_interpolate.
Sketch
Here we use a sketch that is developed for the Nano-ST7789 TFT combination. It is based on the example ‘thermal_cam’ in the Adafruit library. The library’s’ examples: ‘amg88xx_interrupt’, ‘amg88_xx_test’ and ‘pixels_test’ worked out-of-the-Examples-box while ‘thermal_cam_interpolate’ was not selected for testing because it is written with another display controller in mind (IL19341) and because all interpolations might overwhelm the Nano’s puny microprocessor.
Instructions are straightforward
1. Read the 8*8 thermal matrix. Output is in degrees Celsius per pixel.
2. Print all measured values to Serial Monitor.
3. Compare the values with a [color] lookup table (LUT) to produce a graphical representation of the recorded temperatures on the display.
4. Display on screen.
Once the AMG8833 is initialized it sends a stream of temperature readings from its 64 pixels. This stream is translated into gray values and these are projected onto the display. A 240*240 display is very handy here because each detection pixel of the AMG8833 thermal matrix can be magnified and displayed in a square with display dimensions 30*30 pixels: a matrix of 8 squares horizontal and 8 squares vertical. This the resolution of the Arduino thermal scanner (figures 4,5)!
Because there are 64 squares on display I constructed a gray lookup table (LUT) that contains 64 shades of gray. It must be noticed here that 16-bit color convention in Arduino needs gray levels (and all other colors) to be represented according to the RGB565 scheme.
figure 4. Operational in the bench. A:The result: a 8×8 ‘selfie’ in infrared – my left arm lifted (to manage the photocamera). Temperature blocks displayed according to the 64 gray shades lookup table photographed on screen (enlarged) in B.
In a Table this gray LUT is constructed as follows
Table: Lookup Table 64 shades of gray
block | RGB hex color | hexadecimal gray | RGB565 gray |
0 | 0,0,0 | 000000 | 0x0000 |
1 | 4,4,4 | 040404 | 0x0020 |
2 | 8,8,8 | 080808 | 0x0841 |
3 | C,C,C | 0C0C0C50 | 0x0861 |
4 | 10,10,10 | 101010 | 0x1082 |
5 | 14,14,14 | 141414 | 0x10A2 |
6 | 18,18,18 | 181818 | 0x18C3 |
7 | 1C,1C,1C | 1C1C1C | 0x18E3 |
8 | 20,20,20 | 202020 | 0x2104 |
9 | 24,24,24 | 242424 | 0x2124 |
10 | 28,28,28 | 282828 | 0x2945 |
11 | 2C,2C,2C | 2C2C2C | 0x2965 |
12 | 30,30,30 | 303030 | 0x3186 |
13 | 34,34,34 | 343434 | 0x31A6 |
14 | 38,38,38 | 383838 | 0x39C7 |
15 | 3C,3C,3C | 3C3C3C | 0x39E7 |
16 | 40,40,40 | 404040 | 0x4208 |
17 | 44,44,44 | 444444 | 0x4228 |
18 | 48,48,48 | 484848 | 0x4A49 |
19 | 4C,4C,4C | 4C4C4C | 0x4A69 |
20 | 50,50,50 | 505050 | 0x528A |
21 | 54,54,54 | 545454 | 0x52AA |
22 | 58,58,58 | 585858 | 0x5ACB |
23 | 5C,5C,5C | 5C5C5C | 0x5AEB |
24 | 60,60,60 | 606060 | 0x630C |
25 | 64,64,64 | 646464 | 0x632C |
26 | 68,68,68 | 686868 | 0x6B4D |
27 | 6C,6C,6C | 6C6C6C | 0x6B6D |
28 | 70,70,70 | 707070 | 0x738E |
29 | 74,74,74 | 747474 | 0x73AE |
30 | 78,78,78 | 787878 | 0x7BCF |
31 | 7C,7C,7C | 7C7C7C | 0x7BEF |
32 | 80,80,80 | 808080 | 0x8410 |
33 | 84,84,84 | 848484 | 0x8430 |
34 | 88,88,88 | 888888 | 0x8C51 |
35 | 8C,8C,8C | 8C8C8C | 0x8C71 |
36 | 90,90,90 | 909090 | 0x9492 |
37 | 94,94,94 | 949494 | 0x94B2 |
38 | 98,98,98 | 989898 | 0x9CD3 |
39 | 9C,9C,9C | 9C9C9C | 0x9CF3 |
40 | A0,A0,A0 | A0A0A0 | 0xA514 |
41 | A4,A4,A4 | A4A4A4 | 0xA534 |
42 | A8,A8,A8 | A8A8A8 | 0xAD55 |
43 | AC,AC,AC | ACACAC | 0xAD75 |
44 | B0,B0,B0 | B0B0B0 | 0xB596 |
45 | B4,B4,B4 | B4B4B4 | 0xB5B6 |
46 | B8,B8,B8 | B8B8B8 | 0xBDD7 |
47 | BC,BC.BC | BCBCBC | 0xBDF7 |
48 | C0,C0,C0 | C0C0C0 | 0xC618 |
49 | C4,C4,C4 | C4C4C4 | 0xC638 |
50 | C8,C8,C8 | C8C8C8 | 0xCE59 |
51 | CC.CC,CC | CCCCCC | 0xCE79 |
52 | D0,D0,D0 | D0D0D0 | 0xD69A |
53 | D4,D4.D4 | D4D4D4 | 0xD6BA |
54 | D8,D8,D8 | D8D8D8 | 0xDEDB |
55 | DC,DC,DC | DCDCDC | 0xDEFB |
56 | E0,E0,E0 | E0E0E0 | 0xE71C |
57 | E4,E4,E4 | E4E4E4 | 0xE73C |
58 | E8,E8,E8 | E8E8E8 | 0xEF5D |
59 | EC,EC,EC | ECECEC | 0xEF7D |
60 | F0,F0,F0 | F0F0F0 | 0xF79E |
61 | F4,F4,F4 | F4F4F4 | 0xF7BE |
62 | F8,F8,F8 | F8F8F8 | 0xFFDF |
63 | FC.FC.FC | FCFCFC | 0xFFFF |
In Arduino notation:
int camColors[] = // 64 shades of gray lookup table
{
0x0000,0x0020,0x0841,0x0861,0x1082,0x10A2,0x18C3,0x18E3,
0x2104,0x2124,0x2945,0x2965,0x3186,0x31A6,0x39C7,0x39E7,
0x4208,0x4228,0x4A49,0x4A69,0x528A,0x52AA,0x5ACB,0x5AEB,
0x630C,0x632C,0x6B4D,0x6B6D,0x738E,0x73AE,0x7BCF,0x7BEF,
0x8410,0x8430,0x8C51,0x8C71,0x9492,0x94B2,0x9CD3,0x9CF3,
0xA514,0xA534,0xAD55,0xAD75,0xB596,0xB5B6,0xBDD7,0xBDF7,
0xC618,0xC638,0xCE59,0xCE79,0xD69A,0xD6BA,0xDEDB,0xDEFB,
0xE71C,0xE73C,0xEF5D,0xEF7D,0xF79E,0xF7BE,0xFFDF,0xFFFF,
};
This expression replaces the content of uint16_t camColors[] that is included in the library’s Example sketch.
figure 5. Imaging op a teacup filled with hot water (A) in visible lght, (B) in infrared with a commercial smartphone thermal camera and (C) with the AMG8833 attached to the Arduino bench
Results
A classical way to test infrared cameras is to aim the camera at a cup with hot coffee. As I have at my disposition a modest, smartphone type thermal imager with a 206*156 pixel bolometer I undertook a comparative test. Testing went perfect (figure 5). the entire cup was imaged in 9 pixels ‘hot’. A ‘selfie’ is shown in figure 4A; note that in 4A I added my silhouette with the illustration editing software.
Competing thermal sensor design
A short research into thermal sensors available for the Arduino environment highlighted the MLX90640 thermal sensor with its 32*32 pixel bolometer that offers much more resolution than the AMG8833. An Arduino compatible breakout mini board with an MLX90640 on board is produced by Adafruit Industries (MLX90640 IR Therm Camera) and Pimoroni (PIM365). Prices are reasonable which makes the MLX90640 very attractive for further experimentation. The processing and display of thermal information in 1,024 pixels may go beyond the limited capacity of the Arduino Uno. An ESP8866 or ESP32 may do the job better and faster.
Downloadable sketch:
Sketch named ‘AMG8833_Nano_ST7789_display.ino’
This sketch is packed in a ZIP file.
References:
*Connecting a 240×240 TFT display with ST7789 controller with a NodeMCU ESP8266 or an Arduino Nano. Published December 24, 2019 on this website (section ‘Arduino Bare Basics’)