This is only a preview of the July 2023 issue of Silicon Chip. You can view 38 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Dynamic NFC/RFID Tag":
Articles in this series:
Items relevant to "Reciprocal Frequency Counter":
Items relevant to "Pi Pico Thermal Camera":
Items relevant to "Railway Carriage Uncoupler":
Items relevant to "Replacing Vibrators, Pt2":
Purchase a printed copy of this issue for $11.50. |
A thermal infrared camera measures hot or cold spots
compared to the surrounding area. This is extremely
useful in diagnosing hot spots in electronic circuits,
which may indicate a failing component or the need
for a heatsink. They can be pricey, but not this one, a
DIY version that’s easy to build.
Pi Pico-based
Thermal Camera
IR
thermal cameras have many
uses beyond those listed above,
such as checking for overheating
mechanical bearings or identifying
areas of heat loss in a building.
Panasonic produces the AMG8833
Infrared Array Sensor (“Grid-EYE”)
that detects IR emissions on a 64-pixel
8 × 8 array. It uses the I2C serial protocol, so it can easily interface with a
Raspberry Pi Pico running the Pico
Mite operating system.
Objects emit infrared energy in
proportion to their temperature; the
higher the temperature, the more IR
energy is emitted and the higher its
frequency. For really hot objects, the
frequency extends into the visible
wavelengths, which is why hot objects
are seen to glow. By measuring this
energy, we can get a pretty good idea
of the temperature. There are some
pitfalls, which we will mention later.
With the Grid-EYE sensor, each
pixel has a viewing angle of approximately 7.5°, so the overall sensor has
a viewing angle of 60° (7.5° × 8). Each
pixel has a tolerance of ±2.5°C when
operated within specification. We can
minimise this error by calibrating the
sensor, as described below.
Also, there can be random operating ‘noise’ of up to ±2.5°C per pixel.
To reduce this, the sensor is used in
moving-average mode, which averages
two readings when the sensor is set up
for a 10Hz frame rate or 20 readings
when for a 1Hz frame rate.
If the raw output of the Array Sensor is displayed directly on an LCD
screen, it appears very ‘blocky’. Still,
it can easily be upscaled using a
62
Silicon Chip
technique called bilinear interpolation to give the appearance of many
more data points. The PicoMite Thermal Camera can upscale by factors of
two, four or nine. These factors were
chosen as they make the best use of
the screen width.
Below the thermal image display is
a text read-out showing the maximum,
minimum and average temperatures
and the current operating mode.
As mentioned above, the Array Sensor can sample at 10 FPS (frames per
second) or 1 FPS. The former is most
suited to fast-changing subjects, while
the latter better smooths out random
noise in the sensor, giving a more stable and accurate output.
Bilinear interpolation
This involves drawing an imaginary
straight line between two data points,
then generating new data points in
between that lie on that line. It’s a simple technique that produces a much
smoother-looking result than the more
basic ‘nearest neighbour’ technique
that gives a blocky image.
More complicated interpolation schemes like trilinear, bicubic,
Lanczos or anisotropic interpolation
involve considerably more processing (arithmetic) than bilinear. In this
case, their advantages are minor; bilinear gets us most of the improvement
compared to no filtering with very little processing.
Object emissivity
The ‘fly in the ointment’ for a thermal camera is that objects vary in emissivity. An ideal IR emitter is called a
Australia's electronics magazine
by Kenneth Horton
‘black body’ with 100% electromagnetic emission/absorption.
Shiny objects like mirrors have an
emissivity closer to 0%. If you point
an IR thermometer or camera at them,
you will measure the temperature of
an object that the mirror is reflecting,
not the mirror itself.
Luckily for us, many electronic components are dark colours and will have
an emissivity of 90%+, so a thermal
camera will measure their temperature
accurately. Human skin has an emissivity of 97-99.9%, so IR thermometers also work well for measuring our
temperature.
This isn’t a fatal flaw but be aware
that the temperature measurements
of metallic objects using this IR camera could be inaccurate. It isn’t just
well-polished metal surfaces either;
even rough, oxidised aluminium
only has an emissivity of about 20%,
with polished metal surfaces usually
below 5%.
A known work-around to measuring
the temperature of shiny surfaces (eg
stainless steel pipes) is to apply some
matte painters tape, which has a better emissivity. For more information,
see: https://w.wiki/6R6E
Circuit details
As shown in Fig.1, the hardware
for the project is relatively straightforward, consisting of just three modules:
the Infrared Array Sensor, a Raspberry
Pi Pico running the PicoMite operating system (MMBasic) and a 1.8-inch
SPI TFT LCD screen with a resolution
siliconchip.com.au
Fig.1: the Thermal Camera circuit is straightforward, with the IR sensor array (MOD1) communicating with the
Raspberry Pi Pico over an I2C bus (SDA/SCL) and the LCD screen being driven over an SPI bus (CS, SCK & MOSI). The
only other components are the pushbutton for changing modes (S1) and a 39W resistor to set the LCD backlight current.
of 128 × 160 pixels and an ST7735
controller.
The sensor array is connected to the
Pico via an I2C interface, while communications with the LCD screen are
over an SPI interface. The only passive components are a pushbutton to
change modes and a 39W resistor to
set the current at which the display
backlight operates. The following Pico
GPIO pins are used:
• GP08: LCD data/control (D/C)
• GP09: LCD chip select (CS)
• GP10: LCD SPI clock (SCK)
• GP11: LCD SPI data (MOSI)
• GP15: LCD reset (RST)
• GP18: pushbutton sensing
• GP20: AMG8833 I2C data (SDA)
• GP21: AMG8833 I2C clock (SCL)
The double-sided PCB is a carrier
for the three modules, the pushbutton
and the resistor. The display runs from
a 5V DC supply from the Pico. On the
Pico board, this is stepped down by a
regulator to 3.3V. That 3.3V runs the
RP2040 microcontroller on the Pico
and is also available off-board, where
it is used to power the AMG8833 IR
sensor array.
The Array Sensor is available from
the usual auction sites pre-mounted
on a breakout board, and you can find
the display on the same sites. There are
some suggested links in the parts list.
The prototype was powered via the
USB port on the Pi Pico, but there are
also pads on the PCB for an external 5V
power supply. This way, the Thermal
Camera can be powered by a battery.
The pushbutton is connected so that
siliconchip.com.au
it pulls the GP18 pin to GND when it
is pressed. The Pico has an internal
pull-up current enabled on that pin,
so its voltage is high when the button
is not pressed and goes low when it’s
pressed, allowing the digital input to
sense the change.
Software operation
The basic flow of the program is as
follows:
1. Initialise the PicoMite, LCD
screen and IR sensor array
2. Restore the calibration data and
last pushbutton settings
3. Load the colour spectrum from
the table
4. Enter the main loop
Read 64 pixels from the sensor
and adjust with the calibration data
b. Calculate the maximum, minimum and average temperatures
c. Convert the absolute temperatures to points on the colour
spectrum
d. Interpolate the intermediate
colour values for each row using
bilinear interpolation
e. Interpolate the intermediate
colour values for each column
using bilinear interpolation
f. Update the display
g. Check the pushbutton state
h. Delay if necessary
Repeat items a-h above indefinitely
a.
The rear of the enclosure (86 × 33.4
× 57.3mm) has a cutout for the
AMG8833 IR sensor; you can
also see a small cutout
for the Pi Pico’s USB
connector on the
lip.
July 2023 63
by Silicon Chip), they will be plated,
and nothing else needs to be done. If
you etch the board yourself, those nine
vias need to be drilled and short wire
links soldered between the top and
bottom layers in each location.
The LCD screen and switch mount
on the underside of the PCB, while the
Pi Pico and IR sensor are on the top.
For convenience, the three modules can be mounted via socket strips
rather than soldering them directly to
the PCB. You can cut them from longer
strips if you don’t have 6-pin and 8-pin
sockets. The resistor can be mounted
on either side of the board.
The switch is a two-pin or three-pin
SIL-type vertical pushbutton that solders directly to the PCB. Alternatively,
there is a provision in the 3D-printed
enclosure to mount other types of
pushbutton below the LCD screen and
The Raspberry Pi is mounted on pin headers in sockets to make it easy to replace.
wire them up to the pads on the board
using short connecting wires.
LCD screen limitations
good imagination), and the span from
Once plugged into its socket, the IR
Although the LCD screen is, in the- yellow through green to cyan seems sensor is secured to the board by two
20mm-long M2.5 machine screws and
ory, a standard item, displays from particularly compressed! Also, the
different suppliers have different char- display is extremely sensitive to the nuts with 3D-printed spacers (Fig.4)
acteristics. One display tested had the viewing angle and must be viewed between the PCB and sensor. One of
red and blue colours reversed, whilst head-on to get the full spectrum of the spacers for the IR sensor has a cutthe latest batch had random pixels at colours. Otherwise, adjacent colours out to fit around an SMD component
next to the module's mounting hole.
the bottom and right-hand side of the blend into each other.
With the IR sensor array and LCD
display. As a result, three constants are
attached to the PCB, now is also a good
defined to allow the program to be tai- Construction
The Thermal Camera is built on a time to plug the Raspberry Pi Pico into
lored to the attached display:
double-sided PCB coded 04105231 its sockets.
' Set to false for RGB displays
that measures 60 × 52.5mm. The comYou can print the custom-made
and true for BGR displays
ponents are mounted as shown in enclosure in two parts (body and lid),
Const BGR_display = False
Figs.2 & 3.
shown in Fig.5. The STL 3D printer
' Some ST7735 displays have a
There are nine vias on this board. files (available to download from
pixel alignment problem! Try = 2
If you are using a commercially- siliconchip.com.au/Shop/6/202) are
Const HRES_offset = 0
produced board (such as the one sold optimised for 0.2mm layer height,
' Some ST7735 displays have a
pixel alignment problem! Try = 1
Const VRES_offset = 0
Despite the display supposedly
having 65,536 colours, they can’t
actually show that many. Firstly,
RGB(247,251,247) is one step down
from white but looks significantly dimmer. The difference between this and
the next step down, RGB(239,247,239),
is less noticeable, as is each subsequent step.
For dimmer values, the less effect
each step has. RGB(127,127,127) is
very dim, and RGB(63,63,63) is almost
black! Another, more technical way
of saying this is that the display has a
very high gamma value.
As a result, it is difficult to get
more than about 38 distinct colours
across the spectrum (even with a
64
Silicon Chip
Figs.2 & 3: components are mounted on both sides of the board. On one side are
the Raspberry Pi Pico and IR sensor, both plugged in via header strips. The LCD
screen, pushbutton and resistor are mounted on the other side, although the
resistor can go on either side.
Australia's electronics magazine
siliconchip.com.au
0.4mm wall thickness and 100% fill.
Note that the first layer of the screw
holes is filled as it gives a more pleasing appearance to the front and back
of the case – just drill them out after
printing. The holes in the lid are countersunk under the top layer and are
best cleared with an 8-10mm drill by
hand.
The PCB assembly is held in the
case by four 25mm-long M3 machine
screws and nuts, with 3D-printed spacers between the display and the PCB
at the opposite end to the connector.
It is necessary to insert the display
into the case first, insert the machine
screws from the front of the case, place
the spacers over the screw shafts and
then plug the PCB onto the display.
Finally, secure it with the nuts.
Loading the software
It is assumed that readers are familiar with loading PicoMite software,
which was described in the article
on the PicoMite in the January 2022
issue (siliconchip.au/Article/15177).
Briefly:
1. Download the PicoMite operating
system from http://geoffg.net/picomite.
html and unzip the file.
2. To load the operating system onto
the PI Pico, plug the USB cable into
a PC while holding down the white
button.
3. The Pi Pico will appear as a USB
drive. Copy/drag the file PicoMitexx.
xx.xx.uf2 onto that drive.
4. Connect to the PicoMite’s USB
serial port using your preferred serial
terminal emulator (eg, TeraTerm or
PuTTY).
5. Once connected, enter each of
these commands in turn, but note that
many of them reset the Pi Pico, so the
USB connection is lost and will need
to be restored before entering the next:
The pushbutton is visible on the
back of the PCB at upper left. A few
different compatible types can be
obtained.
camera.bas” file into the PicoMite,
again using your preferred serial terminal emulator or MMEdit. Use the
“Autosave” or “XMODEM receive”
commands, depending upon your
preference.
8. If you’d prefer to skip most of the
above sequence, you can download the
“Thermal camera (RGB).uf2” or “Thermal camera (BGR).uf2” file from the
Silicon Chip website and upload it in
the third step above. That’s equivalent
to running all the configuration commands and loading the BASIC code.
The only difference between the two
files is the expected LCD screen configuration, so if the displayed colours
are wrong, load the other file.
Operation
The pushbutton has the following
functions:
• Short press (less than 1.5 seconds): cycles the display scaling factor through 1, 2, 4 and 9
• Long press (more than 1.5 seconds): toggles between 1 FPS and 10
FPS
Fig.4: 3D-printed spacers are used rather than off-the-shelf types since we
can make them exactly the right dimensions, and you can print them at the
same time as the case. Note the cut-out in one to clear an SMD
component near the mounting hole on the IR
sensor module.
OPTION RESET
OPTION CPUSPEED 252000
OPTION SYSTEM SPI
GP10,GP11,GP12
OPTION LCDPANEL
ST7735,RP,GP8,GP15,GP9
OPTION SYSTEM I2C GP20,GP21
6. The following two commands
are optional; the first shows you what
you have configured, while the second
lets you verify that the LCD screen is
working:
OPTION LIST
GUI TEST LCDPANEL
7. Finally, load the “Thermal
siliconchip.com.au
Fig.5: the 3D printed enclosure
base and lid. The holes do not
go all the way through because
it gives a neater result to drill
the thin panels after printing the
case than print the case with the holes.
Australia's electronics magazine
July 2023 65
Parts List – Raspberry Pi Thermal Camera
1 double-sided PCB coded 04105231, 60 × 52.5mm
1 Raspberry Pi Pico
1 3D-printed enclosure (body & lid)
4 3D-printed spacers
1 AMG8833 Grid-EYE IR sensor array breakout board module with pin order
VIN, GND, SCL, SDA, INT & ADO
[AliExpress www.aliexpress.com/item/33012193094.html]
1 1.8-inch 128×160 pixel SPI LCD TFT screen with ST7735 controller
[Tempero Systems TS-S006; eBay; AliExpress www.aliexpress.com/
item/1005003797803015.html {1.8 inch option}]
1 SPDT momentary PCB-mounting subminiature pushbutton switch (S1)
[Altronics S1493 or APEM TP32P0]
1 39W 5% ¼W axial resistor
2 20-pin headers, 2.54mm pitch
2 20-pin header sockets, 2.54mm pitch
1 8-pin header socket, 2.54mm pitch
1 6-pin header socket, 2.54mm pitch
2 M2.5 × 20mm panhead machine screws and hex nuts
4 M3 × 25mm panhead machine screws and hex nuts
4 No.2 × 6mm countersunk head self-tapping screws
• Very long press (more than 10 seconds): enters calibration mode
Note that the frame rates are sensor
refresh times, not screen refresh times.
At 10 frames per second, the screen
update time is longer than 1/10th
of a second for scale factors 4 and 9.
At scale factor 4, the display will be
updated approximately every 220 ms
and, at scale factor 9, every 700ms.
This is because the bilinear calculations take some time to complete for
higher scaling factors.
In calibration mode, the sensor
is set to 1 FPS, and 10 readings are
taken over a 10-second period. These
are then averaged, and the correction
factors for each pixel are stored in
non-volatile memory. Good results are
obtained by holding the sensor perfectly still 2-3cm from a white sheet
of paper.
If the button is pressed during calibration, calibration is abandoned, and
the correction factors are cleared. We
recommend letting the sensor stabilise
for at least one minute with power on
before performing calibration.
Software tweaks
In the software, the constant “Fahrenheit” can be set to “true” to display
temperatures in Fahrenheit rather than
centigrade/Celsius.
The constant “Minimum_span”
sets the minimum temperature span
for the display when there is little temperature variation across the
It’s critical you purchase a
module with the same output pin
layout as the one shown above.
whole display. This prevents wildly
varying colours for minimal temperature changes. Lower values make the
display more sensitive when there is
an almost uniform temperature gradient.
Speeding up the refresh rate
The latest version of the Pico
Mite firmware (“PicoMiteV5.07.06.
uf2”) allows the CPU speed to be
increased from the old maximum
speed of 252000 to 378000 with the
command:
Option CPUspeed 378000
This means that, with a scale factor of 4, the display will be updated
approximately every 165ms rather
than 220ms and, at scale factor 9, every
520ms rather than 700ms. However,
note that this is ‘overclocking’ the
RP2040 processor and it’s possible
that it won’t work on every board or
under all conditions. Still, most Pico
boards should be capable of running
SC
at this speed.
Dual-Channel Breadboard
Power Supply
Our Dual-Channel Breadboard PSU
features two independent channels each
delivering 0-14V <at> 0-1A. It runs from
7-15V DC or USB 5V DC, and plugs straight
into the power rails of a breadboard, making it
ideal for prototyping. Photo shows both the Breadboard
PSU and optional Display Adaptor (with 20x4 LCD) assembled.
Both articles in the December 2022 issue – siliconchip.au/Series/401
SC6571 ($40 + post): Breadboard PSU Complete Kit
SC6572 ($50 + post): Breadboard PSU Display Adaptor Kit
66
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
|