Qwiic GRID-Eye Infrared Array (AMG88xx) Hookup Guide
Arduino Example Code
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.
SparkFun has written a library to control the Qwiic GRID-Eye. You can obtain these libraries through the Arduino Library Manager. Search for SparkFun GridEYE AMG88 Library and you should be able to install the latest version. If you prefer downloading the libraries manually you can grab them from the GitHub repository:
Example 1 - Serial Visualizer
Once you've installed the Grid-EYE library, restart Arduino. Then go to File > Examples > SparkFun GridEYE AMG88 Library > Example1-SerialVisualizer to open the example sketch.
Once you've set your Board and Serial Port, upload the sketch to your Arduino. Then open the serial monitor. You'll begin to see an 8x8 array of numbers between 0 and 3. The Arduino is mapping the values in between the temperatures between
COLD to values between 0 and 3, these values are then represented by a
. for 0,
o for 1,
0for 2, and
O for 3. Try moving in front of the camera and see if any values change. Play around with the values of
COLD as well to see different ranges of temperatures mapped from 0 to 3. Notice how we use the function
grideye.getPixelTemperature(i) to get the temperature of pixel
i is between 0 and 64. With these temperatures mapped to a grid, the output should look something like the below image.
Example 2 - Using Interrupts
To pull up the next example, go to File > Examples > SparkFun GridEYE AMG88 Library > Example2-UsingInterrupts to open the example sketch.
Once you've loaded this example up to your microcontroller, go ahead and check out the
void setup() loop. We set up how the Interrupts are triggered with the following code.
language:c grideye.setInterruptModeAbsolute(); grideye.setUpperInterruptValue(UPPER_LIMIT); grideye.setLowerInterruptValue(LOWER_LIMIT); grideye.setInterruptHysteresis(HYSTERESIS);
HYSTERESIS are declared above. Opening the serial monitor will display a table of which interrupts have been fired, if any. Play around with the values of
HYSTERESIS and observe their effect on the firing of interrupts. The interrupt table should look similar to the below image, obviously with different interrupts firing depending on what the Grid-EYE is looking at.
Example 3 - Device Temperature
To pull up the next example, go to File > Examples > SparkFun GridEYE AMG88 Library > Example3-DeviceTemperature to open the example sketch. This example is relatively simple, and merely checks the devices temperature. To get device temperature, there are 3 functions we can use,
getDeviceTemperature(), which returns our temperature in Celsius,
getDeviceTemperatureFahrenheit(), which returns our temperature in Fahrenheit
getDeviceTemperatureRaw() returns the raw binary content of the thermistor register. Opening the serial monitor should yield an image similar to the one below.
Example 4 - Processing Heat Cam
Note: Processing is a software that enables visual representation of data, among other things. If you've never dealt with Processing before, we recommend you also check out the Arduino to Processing tutorial. Follow the below button to go ahead and download and install Processing.
This next example involves the Processing IDE. Processing listens for serial data, so we'll need to get our Arduino producing serial data that makes sense to Processing. To pull up the next example, go to File > Examples > SparkFun GridEYE AMG88 Library > Example4-ProcessingHeatCam to open the example sketch. This sketch simply prints a comma separated list of our temperatures over serial for Processing to listen to.
Once this sketch is uploaded, we need to tell Processing how to turn this data into a visualization. The Processing sketch to do this is located in the same folder as Example 4. So go to Documents > Arduino > SparkFun_GridEYE_AMG88_Library > examples > Example4-ProcessingHeatCam > HeatCam and open the HeatCam file in Processing. Attempting to run the sketch will show us available serial ports in the debug window.
Identify which serial port your Arduino is on, for instance, my RedBoard is on COM6, which corresponds to
 in the above image, so I will need to change 0 to 1 in the following line to ensure Processing is listening in the right location.
language:c myPort = new Serial(this, Serial.list(), 115200);
Once I've done this, we should be able to run the Processing sketch and it will give us a nice visualization of the pixels on our Grid-EYE. Move your face or hand in front of the sensor and see what it looks like on the screen. The output should look similar to the below image, which is output from the Grid-EYE being pointed at a glass of ice water and a lava lamp.
Example 5 - Hot Pixel
To pull up the next example, go to File > Examples > SparkFun GridEYE AMG88 Library > Example5-HotPixel to open the example sketch. This example runs through each pixel and finds the hottest one, then outputs the location and temperature of that pixel. It does this by comparing the current
hotPixelValue temperature to the temperature of the current pixel. If the current pixel is hotter, its value is stored in
hotPixelValue. The output of this sketch should look something like the below image.