Copyright 2017-2024 Jason Ross, All Rights Reserved

Infra-red imaging – where different temperatures are shown on a screen as different colours – is used in things from search and rescue to tracking targets from the air, and from paranormal investigation to draught detection. All of this struck me as interesting, so I wanted to give it a try. A few years ago I saw a FLIR camera at work, and it was impressive. The cost was horrendous though. Since then I’ve seen some other infra-red cameras, some with built-in displays, and some that plug into cellphones, but they’ve all had disadvantages. Some depended on the cellphone having the "right" type of USB connector and client software, some took far too long for delivery because they were built in China and some just weren't very good at all.

In the end, I decided I’d try something a little different. Panasonic make an infrared sensor, the Grid-EYE AMG8833, which is nowhere near as expensive as any of the other devices available. It can connect to a Raspberry Pi or an Arduino, and I’ve got a couple of Raspberry Pis hanging around. This seemed to be a decent way to get into infra-red imaging without spending too much

What’s A Grid-EYE AMG8833 Infra-Red Sensor?

The ANG8833 sensor returns 64 values representing an 8 x 8 grid. It can measure between 0 and 80C, with an accuracy of +/-2.5C. That might not sound fantastic, but remember this is a starter project and the raw 64 values can be enhanced with interpolation. It’s got a range of 7m or so (about 22 feet) so you won’t be putting it in a helicopter just yet, but it should work to detect draughts around your house.

Variations Of The AMG8833

Electronic engineers reading this won't be the least bit surprised to learn that the AMG8833 is one of several options of the AMG sensor available. The product name is actually the Grid-EYE, and the component naming scheme is below, so if you see an AMG8853, AMG8835 or anything similar, you'll know it's part of the family:

AMG

8 Number of horizontal pixels

8 Number of vertical pixels

3 or 5 Power supply voltage, 3.3v or 5v respectively

3 or 4 Sensor amplification, high gain or low gain respectively

The AMG8833 is quite a low-level device; there are no handy routines called get_all_pixel_values() or anything like that. To configure it and get data back, we need to send individual values along the I2C bus to the device, and read the data that comes back.

This is the sort of thing that appeals to those of us who were originally hardware engineers - we actually get to build software that talks to real, physical devices! The communications reference is at:

https://na.industrial.panasonic.com/file-download/244456

and

https://na.industrial.panasonic.com/file-download/4105

This looks like most of the other data sheets I used to work with, even down to half of it being in Japanese! There's a lot of raw data in there, not a lot of examples, and the hardware details take up a lot of the document. When the communications details actually start, there are a few interesting details in here:

The device communicates across the I2C bus at 400kHz.

You can set the thermal data to refresh at either 1Hz or 10Hz.

To reduce noise, you can set the thermal data to return moving averages rather than instantaneous values.

There's a thermistor register in the device! This is quite handy if you're building something rather than just experimenting with it. The temperature is returned as a 12 bit value - the 11 Least Significant Bits (LSBs) are the absolute temperature in Celsius, and bit 11 is a sign bit (1 for negative temperature). The resolution of this register is 0.0625C.

The 64 temperature pixels (it's an 8 x 8 sensor after all) contain 12 bit values as well. However, these values are returned as two's complement rather than the absolute values the thermistor register uses. These pixel values have a lower resolution than the thermistor, with a resolution of 0.25C. The 64 pixel values are refreshed atomically and simultaneously, with no external control. This means that the values are never a mixture of old and new. However, as you need to read the values one after the other, there's no guarantee that your code won't get part way through reading them and then they get updated, leaving you with some old and some new values. Given the applications this sensor is generally used for, this is probably less important than it sounds.

The actual communication is easiest if you do it with Python - there are a few libraries around but smbus was the one I started with. This handles the I2C communication, and there are details of how to install this later in this article.

What Do I Need To Get Started?

If you don't have an AMD8833 sensor lying around, you'll need to order one. You can get them as a single component, but I wasn't feeling adventurous and I don't have the facilities to make my own PCBs, so I bought an assembly with Qwiic cable sockets from DigiKey. This means I didn't have to solder pins or cables to the module - I just bought a cable that had the Qwiic socket at one end, and separate sockets at the other. The sockets will connect to the pins on a Raspberry Pi or Arduino. Here's the parts list:

  • SparkFun SEN-14607 Grid-EYE AMG8833 sensor module. NOTE: This module will only work with a 3.3v supply. Some other modules have a power regulator so they can be connected to 3.3v or 5v. DO NOT do that with this module - 5v will destroy it!

https://www.digikey.ca/en/products/detail/sparkfun-electronics/SEN-14607/9083388

  • A Qwiic cable to connect the module to the Raspberry Pi GPIO connectors. This cable comes with a Qwiic connector on one end and female connectors on the other.

https://www.digikey.ca/en/products/detail/sparkfun-electronics/CAB-17261/13629019

I've Got The Parts - What Next?

Before you can do anything else, you need to connect the AMG8833 sensor to the Raspberry Pi. The sensor connects to the GPIO pins on the Raspberry Pi, so you need to decide which ones to use. You're going to need four, and they're shown in the online interactive pinout diagram. The connection details are in the chart below:

GPIO Connection Details
Connection GPIO Pin Number Qwiic Cable Colour
+3.3v Power 1 (Labelled 3v3, but this is the same thing) Red
Ground 9 Black
I2C Clock 5 Yellow
I2C Data 3 Blue

The layout of the GPIO, from https://pinout.xyz/# is shown here:

Diagram of the Raspberry Pi GPIO Pinout

A pair of needle-nosed pliers might be useful to slide the sockets onto the pins. Remember two things though:

  1. Make sure the Raspberry Pi is OFF and unplugged when you connect the cables.
  2. Make sure you connect to the 3.3v supply line, NOT the 5v supply line next to it!

When you've finished, your connections should look something like this:

The GPIO Connections

Connect the other end of the Qwiic cable to the sensor board, like this:

The QWIIC Connection To The AMG8833

A quick note: Some sensor boards expect a 5v supply, and need to be connected to a 5v pin on the GPIO. Whatever you do, make sure you use the correct voltage for the device. Powering a 5v device from a 3.3v supply probably won't do any damage. Powering a 3.3v device from 5v will probably destroy it, and these things aren't cheap.

Now reconnect the power supply to the Raspberry Pi, and switch it back on. If there are no flames, sparks or funny smells, and the system boots up, you're probably fine.

When you've logged in, go to the Raspberry Pi Configuration >> Interfaces panel and enable the I2C interface. Unsurprisingly this enables the I2C bus, so that you can actually communicate with the AMG8833.

The Raspberry Pi Configuration To Enable I2C
The Raspberry Pi Configuration To Enable I2C

The Raspberry Pi might tell you it needs to be rebooted after you've made this change. If it does, let it do it now. When everything is back and logged in, you'll need to install some software to let you use the I2C bus - the Raspberry Pi is running a flavour of Linux after all, so it doesn't install everything like Windows. Open a Terminal windows and run the following:

sudo apt-get install i2c-tools
sudo i2cdetect -y 1

The first command installs the i2c-tools module, the second uses to tools to detect any devices on the I2C bus. The output of this command should look something like this:

The Output of i2cdetect On The Raspberry Pi

In the screenshot above, you can see that there's something sitting at address 0x69. That's the AMG8833. Now we need to start using it. Don't close the terminal window, you'll need it for the next few steps.

Talking to the AMG8833

There's plenty of software on the web that will help you work with the AMG8833 and, as with any other software, some is good, and some is dreadful. I looked around for something that will be a good start and found a Git repository with some code that will display an image from the AMG8833.

Firstly you'll need a copy of Git which, if you haven't heard of it before, is a distributed version control system. You'll need this to download the source code. In a terminal window, enter the following:

sudo apt-install git

You'll also need to install the mathematical modules used by the Python code. It's best to do it now before you start downloading and running the software. Entering this will update your existing installation, and then install the software you need:

sudo apt-get update && \
sudo apt-get upgrade -y \
sudo apt-get install python3-scipy python3-numpy python3-matplotlib

Then, change to your development directory - or create one if you don't already have one:

mkdir Development
cd Development

And download the code from https://github.com/makerportal/AMG8833_IR_cam with:

git clone https://github.com/makerportal/AMG8833_IR_cam.git

Now everything is installed, from the Raspberry Pi's main menu open Thonny from the Programming menu. Then open

IR_cam_interp.py

from

Development/AMG8833_IR_cam/examples

and run it. You should see something like this - it's an image created using interpolation from the AMG8833 sensor on the I2R bus:

A Rather Nice Tray Of Ribs In Infra-Red
A Rather Nice Tray Of Ribs In Infra-Red (You Would Have Liked Them!)
The Tray Of Ribs In Infra-Red
The Same Tray Of Ribs With a Hand Reaching For Them (White Diagonal Area in the Top Right)

Congratulations! You’ve now got an infra-red camera that you can use to check for temperature hotspots in your car’s engine, for cold spots in your house - is it a leak in your weatherproofing or a paranormal presence? Don’t think for a second I’m going near THAT question! You can check for things that shouldn’t be hot, like parts of your car, or for things that should be, like air vents.

Summary

So far you’ve seen how to get an AMG8833, connect it to a Raspberry Pi and then show images that use interpolation to display higher resolutions than the 8x8 the device provides.

This is just a basic configuration for the device, and it’s using the Raspberry Pi to do much more work than it can comfortably cope with. In my next article on this subject, I’ll show how all this can be improved.

Made In YYC

Made In YYC
Made In YYC

Hosted in Canada by CanSpace Solutions